container_base_dispatch.hpp revision 302408
1// -*- C++ -*-
2
3// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library.  This library is free
6// software; you can redistribute it and/or modify it under the terms
7// of the GNU General Public License as published by the Free Software
8// Foundation; either version 2, or (at your option) any later
9// version.
10
11// This library is distributed in the hope that it will be useful, but
12// WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14// General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this library; see the file COPYING.  If not, write to
18// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19// MA 02111-1307, USA.
20
21// As a special exception, you may use this file as part of a free
22// software library without restriction.  Specifically, if other files
23// instantiate templates or use macros or inline functions from this
24// file, or you compile this file and link it with other files to
25// produce an executable, this file does not by itself cause the
26// resulting executable to be covered by the GNU General Public
27// License.  This exception does not however invalidate any other
28// reasons why the executable file might be covered by the GNU General
29// Public License.
30
31// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32
33// Permission to use, copy, modify, sell, and distribute this software
34// is hereby granted without fee, provided that the above copyright
35// notice appears in all copies, and that both that copyright notice
36// and this permission notice appear in supporting documentation. None
37// of the above authors, nor IBM Haifa Research Laboratories, make any
38// representation about the suitability of this software for any
39// purpose. It is provided "as is" without express or implied
40// warranty.
41
42/**
43 * @file container_base_dispatch.hpp
44 * Contains an associative container dispatching base.
45 */
46
47#ifndef PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
48#define PB_DS_ASSOC_CNTNR_BASE_DS_DISPATCHER_HPP
49
50#include <ext/typelist.h>
51
52#define PB_DS_DATA_TRUE_INDICATOR
53#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
54#undef PB_DS_DATA_TRUE_INDICATOR
55
56#define PB_DS_DATA_FALSE_INDICATOR
57#include <ext/pb_ds/detail/list_update_map_/lu_map_.hpp>
58#undef PB_DS_DATA_FALSE_INDICATOR
59
60#define PB_DS_DATA_TRUE_INDICATOR
61#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
62#undef PB_DS_DATA_TRUE_INDICATOR
63
64#define PB_DS_DATA_FALSE_INDICATOR
65#include <ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp>
66#undef PB_DS_DATA_FALSE_INDICATOR
67
68#define PB_DS_DATA_TRUE_INDICATOR
69#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
70#undef PB_DS_DATA_TRUE_INDICATOR
71
72#define PB_DS_DATA_FALSE_INDICATOR
73#include <ext/pb_ds/detail/splay_tree_/splay_tree_.hpp>
74#undef PB_DS_DATA_FALSE_INDICATOR
75
76#define PB_DS_DATA_TRUE_INDICATOR
77#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
78#undef PB_DS_DATA_TRUE_INDICATOR
79
80#define PB_DS_DATA_FALSE_INDICATOR
81#include <ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp>
82#undef PB_DS_DATA_FALSE_INDICATOR
83
84#define PB_DS_DATA_TRUE_INDICATOR
85#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
86#undef PB_DS_DATA_TRUE_INDICATOR
87
88#define PB_DS_DATA_FALSE_INDICATOR
89#include <ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp>
90#undef PB_DS_DATA_FALSE_INDICATOR
91
92#define PB_DS_DATA_TRUE_INDICATOR
93#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
94#undef PB_DS_DATA_TRUE_INDICATOR
95
96#define PB_DS_DATA_FALSE_INDICATOR
97#include <ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp>
98#undef PB_DS_DATA_FALSE_INDICATOR
99
100#define PB_DS_DATA_TRUE_INDICATOR
101#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
102#undef PB_DS_DATA_TRUE_INDICATOR
103
104#define PB_DS_DATA_FALSE_INDICATOR
105#include <ext/pb_ds/detail/pat_trie_/pat_trie_.hpp>
106#undef PB_DS_DATA_FALSE_INDICATOR
107
108namespace pb_ds
109{
110namespace detail
111{
112  // Primary template.
113  template<typename Key, typename Mapped, typename Data_Structure_Taq,
114	   typename Policy_Tl, typename Alloc>
115    struct container_base_dispatch;
116
117  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
118    struct container_base_dispatch<Key, Mapped, list_update_tag,
119				   Policy_Tl, Alloc>
120    {
121    private:
122      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
123      typedef typename at0::type			    	at0t;
124      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
125      typedef typename at1::type			    	at1t;
126
127    public:
128      typedef lu_map_data_<Key, Mapped, at0t, Alloc, at1t>	type;
129    };
130
131  template<typename Key, typename Policy_Tl, typename Alloc>
132    struct container_base_dispatch<Key, null_mapped_type, list_update_tag,
133				   Policy_Tl, Alloc>
134    {
135    private:
136      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
137      typedef typename at0::type			    	at0t;
138      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
139      typedef typename at1::type			    	at1t;
140
141    public:
142      typedef lu_map_no_data_<Key, null_mapped_type, at0t, Alloc, at1t> type;
143    };
144
145  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
146    struct container_base_dispatch<Key, Mapped, pat_trie_tag, Policy_Tl, Alloc>
147    {
148    private:
149      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
150      typedef typename at1::type			    	at1t;
151
152    public:
153      typedef pat_trie_data_<Key, Mapped, at1t, Alloc> 		type;
154    };
155
156  template<typename Key, typename Policy_Tl, typename Alloc>
157    struct container_base_dispatch<Key, null_mapped_type, pat_trie_tag,
158				   Policy_Tl, Alloc>
159    {
160    private:
161      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
162      typedef typename at1::type			    	at1t;
163
164    public:
165      typedef pat_trie_no_data_<Key, null_mapped_type, at1t, Alloc> type;
166    };
167
168  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
169    struct container_base_dispatch<Key, Mapped, rb_tree_tag, Policy_Tl, Alloc>
170    {
171    private:
172      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
173      typedef typename at0::type			    	at0t;
174      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
175      typedef typename at1::type			    	at1t;
176
177    public:
178      typedef rb_tree_data_<Key, Mapped, at0t, at1t, Alloc> 	type;
179    };
180
181  template<typename Key, typename Policy_Tl, typename Alloc>
182    struct container_base_dispatch<Key, null_mapped_type, rb_tree_tag,
183				   Policy_Tl, Alloc>
184    {
185    private:
186      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
187      typedef typename at0::type			    	at0t;
188      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
189      typedef typename at1::type			    	at1t;
190
191    public:
192      typedef rb_tree_no_data_<Key, null_mapped_type, at0t, at1t, Alloc> type;
193    };
194
195  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
196    struct container_base_dispatch<Key, Mapped, splay_tree_tag,
197				   Policy_Tl, Alloc>
198    {
199    private:
200      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
201      typedef typename at0::type			    	at0t;
202      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
203      typedef typename at1::type			    	at1t;
204
205    public:
206      typedef splay_tree_data_<Key, Mapped, at0t, at1t, Alloc> 	type;
207    };
208
209  template<typename Key, typename Policy_Tl, typename Alloc>
210    struct container_base_dispatch<Key, null_mapped_type, splay_tree_tag,
211				   Policy_Tl, Alloc>
212    {
213    private:
214      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
215      typedef typename at0::type			    	at0t;
216      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
217      typedef typename at1::type			    	at1t;
218
219    public:
220      typedef splay_tree_no_data_<Key, null_mapped_type, at0t, at1t, Alloc> type;
221  };
222
223  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
224    struct container_base_dispatch<Key, Mapped, ov_tree_tag, Policy_Tl, Alloc>
225    {
226    private:
227      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
228      typedef typename at0::type			    	at0t;
229      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
230      typedef typename at1::type			    	at1t;
231
232    public:
233      typedef ov_tree_data_<Key, Mapped, at0t, at1t, Alloc> 	type;
234  };
235
236  template<typename Key, typename Policy_Tl, typename Alloc>
237    struct container_base_dispatch<Key, null_mapped_type, ov_tree_tag,
238				   Policy_Tl, Alloc>
239    {
240    private:
241      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
242      typedef typename at0::type			    	at0t;
243      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
244      typedef typename at1::type			    	at1t;
245
246    public:
247      typedef ov_tree_no_data_<Key, null_mapped_type, at0t, at1t, Alloc> type;
248  };
249
250  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
251    struct container_base_dispatch<Key, Mapped, cc_hash_tag, Policy_Tl, Alloc>
252    {
253    private:
254      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
255      typedef typename at0::type			    	at0t;
256      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
257      typedef typename at1::type			    	at1t;
258      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2>	at2;
259      typedef typename at2::type			    	at2t;
260      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3>	at3;
261      typedef typename at3::type				at3t;
262      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> 	at4;
263      typedef typename at4::type			    	at4t;
264
265    public:
266      typedef cc_ht_map_data_<Key, Mapped, at0t, at1t, Alloc, at3t::value,
267			      at4t, at2t> 			type;
268  };
269
270  template<typename Key, typename Policy_Tl, typename Alloc>
271    struct container_base_dispatch<Key, null_mapped_type, cc_hash_tag,
272				   Policy_Tl, Alloc>
273    {
274    private:
275      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
276      typedef typename at0::type			    	at0t;
277      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
278      typedef typename at1::type			    	at1t;
279      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2>	at2;
280      typedef typename at2::type			    	at2t;
281      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3>	at3;
282      typedef typename at3::type				at3t;
283      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> 	at4;
284      typedef typename at4::type			    	at4t;
285
286    public:
287      typedef cc_ht_map_no_data_<Key, null_mapped_type, at0t, at1t, Alloc,
288				 at3t::value, at4t, at2t>    	type;
289  };
290
291  template<typename Key, typename Mapped, typename Policy_Tl, typename Alloc>
292    struct container_base_dispatch<Key, Mapped, gp_hash_tag, Policy_Tl, Alloc>
293    {
294    private:
295      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
296      typedef typename at0::type			    	at0t;
297      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
298      typedef typename at1::type			    	at1t;
299      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2>	at2;
300      typedef typename at2::type			    	at2t;
301      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3>	at3;
302      typedef typename at3::type				at3t;
303      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> 	at4;
304      typedef typename at4::type			    	at4t;
305      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 5> 	at5;
306      typedef typename at5::type			    	at5t;
307
308    public:
309      typedef gp_ht_map_data_<Key, Mapped, at0t, at1t, Alloc, at3t::value,
310			      at4t, at5t, at2t> 		type;
311  };
312
313  template<typename Key, typename Policy_Tl, typename Alloc>
314    struct container_base_dispatch<Key, null_mapped_type, gp_hash_tag,
315				   Policy_Tl, Alloc>
316    {
317    private:
318      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 0>	at0;
319      typedef typename at0::type			    	at0t;
320      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 1> 	at1;
321      typedef typename at1::type			    	at1t;
322      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 2>	at2;
323      typedef typename at2::type			    	at2t;
324      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 3>	at3;
325      typedef typename at3::type				at3t;
326      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 4> 	at4;
327      typedef typename at4::type			    	at4t;
328      typedef __gnu_cxx::typelist::at_index<Policy_Tl, 5> 	at5;
329      typedef typename at5::type			    	at5t;
330
331    public:
332      typedef gp_ht_map_no_data_<Key, null_mapped_type, at0t, at1t, Alloc,
333				 at3t::value, at4t, at5t, at2t>	type;
334  };
335} // namespace detail
336} // namespace pb_ds
337
338#endif
339