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