3 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
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
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.
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.
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
31 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
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
43 * @file common_type.hpp
44 * Contains common types.
47 #ifndef PB_DS_COMMON_TYPES_HPP
48 #define PB_DS_COMMON_TYPES_HPP
50 #include <ext/pb_ds/detail/type_utils.hpp>
51 #include <common_type/assoc/template_policy.hpp>
52 #include <ext/pb_ds/assoc_container.hpp>
60 template<typename Key,
63 typename pb_ds::detail::default_hash_fn<
68 std::allocator< std::pair<const Key, Data> > >
69 struct hash_common_types
72 typedef typename Allocator::size_type size_type;
75 pb_ds::test::hash_load_check_resize_trigger_t_<
80 no_access_half_load_check_resize_trigger_policy;
83 pb_ds::test::hash_load_check_resize_trigger_t_<
88 access_half_load_check_resize_trigger_policy;
91 pb_ds::test::hash_load_check_resize_trigger_t_<
96 no_access_one_load_check_resize_trigger_policy;
99 pb_ds::test::cc_hash_max_collision_check_resize_trigger_t_<
103 no_access_half_max_col_check_check_resize_trigger_policy;
106 pb_ds::test::cc_hash_max_collision_check_resize_trigger_t_<
110 access_half_max_col_check_check_resize_trigger_policy;
112 typedef pb_ds::test::linear_probe_fn_t_< Key, Allocator> lin_p_t;
114 typedef pb_ds::test::quadratic_probe_fn_t_< Key, Allocator> quad_p_t;
117 typename pb_ds::detail::typelist4<
118 pb_ds::detail::false_type,
119 pb_ds::test::direct_mask_range_hashing_t_<
121 no_access_half_load_check_resize_trigger_policy,
122 pb_ds::test::hash_exponential_size_policy_t_<
124 performance_cc_policy0;
127 typename pb_ds::detail::typelist4<
128 pb_ds::detail::false_type,
129 pb_ds::test::direct_mod_range_hashing_t_<
131 no_access_half_load_check_resize_trigger_policy,
132 pb_ds::test::hash_prime_size_policy_t_>::type
133 performance_cc_policy1;
136 typename pb_ds::detail::typelist4<
137 pb_ds::detail::false_type,
138 pb_ds::test::direct_mask_range_hashing_t_<
140 no_access_one_load_check_resize_trigger_policy,
141 pb_ds::test::hash_exponential_size_policy_t_<
143 performance_cc_policy2;
146 typename pb_ds::detail::typelist4<
147 pb_ds::detail::false_type,
148 pb_ds::test::direct_mod_range_hashing_t_<
150 no_access_one_load_check_resize_trigger_policy,
151 pb_ds::test::hash_prime_size_policy_t_ >::type
152 performance_cc_policy3;
155 typename pb_ds::detail::typelist4<
156 pb_ds::detail::true_type,
157 pb_ds::test::direct_mask_range_hashing_t_<
159 no_access_half_load_check_resize_trigger_policy,
160 pb_ds::test::hash_exponential_size_policy_t_<
162 performance_cc_policy4;
165 typename pb_ds::detail::typelist4<
166 pb_ds::detail::false_type,
167 pb_ds::test::direct_mask_range_hashing_t_<
169 no_access_half_max_col_check_check_resize_trigger_policy,
170 pb_ds::test::hash_exponential_size_policy_t_<
172 performance_cc_policy5;
175 typename pb_ds::detail::typelist4<
176 pb_ds::detail::false_type,
177 pb_ds::test::direct_mask_range_hashing_t_<
179 access_half_max_col_check_check_resize_trigger_policy,
180 pb_ds::test::hash_exponential_size_policy_t_<
182 regression_cc_policy0;
185 typename pb_ds::detail::typelist4<
186 pb_ds::detail::false_type,
187 pb_ds::test::direct_mask_range_hashing_t_<
189 access_half_load_check_resize_trigger_policy,
190 pb_ds::test::hash_exponential_size_policy_t_<
192 regression_cc_policy1;
195 typename pb_ds::detail::typelist4<
196 pb_ds::detail::true_type,
197 pb_ds::test::direct_mod_range_hashing_t_<
199 no_access_half_load_check_resize_trigger_policy,
200 pb_ds::test::hash_prime_size_policy_t_ >::type
201 regression_cc_policy2;
204 typename pb_ds::detail::typelist5<
205 pb_ds::detail::false_type,
207 pb_ds::test::direct_mask_range_hashing_t_<
209 no_access_half_load_check_resize_trigger_policy,
210 pb_ds::test::hash_exponential_size_policy_t_<
212 performance_gp_policy0;
215 typename pb_ds::detail::typelist5<
216 pb_ds::detail::false_type,
218 pb_ds::test::direct_mod_range_hashing_t_<
220 no_access_half_load_check_resize_trigger_policy,
221 pb_ds::test::hash_prime_size_policy_t_ >::type
222 performance_gp_policy1;
225 typename pb_ds::detail::typelist5<
226 pb_ds::detail::false_type,
228 pb_ds::test::direct_mod_range_hashing_t_<
230 access_half_load_check_resize_trigger_policy,
231 pb_ds::test::hash_prime_size_policy_t_>::type
232 regression_gp_policy0;
235 typename pb_ds::detail::typelist5<
236 pb_ds::detail::true_type,
238 pb_ds::test::direct_mask_range_hashing_t_<
240 access_half_load_check_resize_trigger_policy,
241 pb_ds::test::hash_exponential_size_policy_t_<
243 regression_gp_policy1;
246 typename pb_ds::detail::typelist6<
247 performance_cc_policy0,
248 performance_cc_policy1,
249 performance_cc_policy2,
250 performance_cc_policy3,
251 performance_cc_policy4,
252 performance_cc_policy5>::type
253 performance_cc_range_hashing_policies;
256 typename pb_ds::detail::typelist3<
257 regression_cc_policy0,
258 regression_cc_policy1,
259 regression_cc_policy2>::type
260 regression_cc_range_hashing_policies;
263 typename pb_ds::detail::typelist2<
264 performance_gp_policy0,
265 performance_gp_policy1>::type
266 performance_gp_range_hashing_policies;
269 typename pb_ds::detail::typelist2<
270 regression_gp_policy0,
271 regression_gp_policy1>::type
272 regression_gp_range_hashing_policies;
274 template<typename Policy_Tl>
275 struct no_access_generic_cc_hash_table_t
279 typename pb_ds::detail::typelist_at_index<
281 store_hash_indicator;
285 store_hash = store_hash_indicator::value
289 typename pb_ds::detail::typelist_at_index<
294 typename pb_ds::detail::typelist_at_index<
299 typename pb_ds::detail::typelist_at_index<
305 pb_ds::cc_hash_table<
311 pb_ds::hash_standard_resize_policy<
320 template<typename Policy_Tl>
321 struct access_generic_cc_hash_table_t
325 typename pb_ds::detail::typelist_at_index<
327 store_hash_indicator;
331 store_hash = store_hash_indicator::value
335 typename pb_ds::detail::typelist_at_index<
340 typename pb_ds::detail::typelist_at_index<
345 typename pb_ds::detail::typelist_at_index<
351 pb_ds::cc_hash_table<
357 pb_ds::hash_standard_resize_policy<
366 template<typename Policy_Tl>
367 struct no_access_generic_gp_hash_table_t
371 typename pb_ds::detail::typelist_at_index<
373 store_hash_indicator;
377 store_hash = store_hash_indicator::value
381 typename pb_ds::detail::typelist_at_index<
386 typename pb_ds::detail::typelist_at_index<
391 typename pb_ds::detail::typelist_at_index<
396 typename pb_ds::detail::typelist_at_index<
402 pb_ds::gp_hash_table<
409 pb_ds::hash_standard_resize_policy<
418 template<typename Policy_Tl>
419 struct access_generic_gp_hash_table_t
423 typename pb_ds::detail::typelist_at_index<
425 store_hash_indicator;
429 store_hash = store_hash_indicator::value
433 typename pb_ds::detail::typelist_at_index<
438 typename pb_ds::detail::typelist_at_index<
443 typename pb_ds::detail::typelist_at_index<
448 typename pb_ds::detail::typelist_at_index<
454 pb_ds::gp_hash_table<
461 pb_ds::hash_standard_resize_policy<
471 typename pb_ds::detail::typelist_transform<
472 performance_cc_range_hashing_policies,
473 no_access_generic_cc_hash_table_t>::type
474 performance_cc_types;
477 typename pb_ds::detail::typelist_transform<
478 regression_cc_range_hashing_policies,
479 access_generic_cc_hash_table_t>::type
483 typename pb_ds::detail::typelist_at_index<
484 performance_cc_types,
486 performance_min_cc_type;
489 typename pb_ds::detail::typelist_transform<
490 performance_gp_range_hashing_policies,
491 no_access_generic_gp_hash_table_t>::type
492 performance_gp_types;
495 typename pb_ds::detail::typelist_transform<
496 regression_gp_range_hashing_policies,
497 access_generic_gp_hash_table_t>::type
501 typename pb_ds::detail::typelist_at_index<
502 performance_gp_types,
504 performance_min_gp_type;
508 typename pb_ds::detail::typelist_append<
509 performance_cc_types,
510 performance_gp_types>::type
514 typename pb_ds::detail::typelist_append<
516 regression_cc_types>::type
520 typename pb_ds::detail::typelist1<
521 performance_min_cc_type>::type
525 template<typename Key,
527 class Comb_Hash_Fn_TL,
528 class Comb_Probe_Fn_TL,
536 struct ranged_hash_common_types
539 typedef typename Allocator::size_type size_type;
542 pb_ds::test::hash_load_check_resize_trigger_t_<
547 no_access_half_load_check_resize_trigger_policy;
550 pb_ds::test::hash_load_check_resize_trigger_t_<
555 no_access_one_load_check_resize_trigger_policy;
558 pb_ds::hash_standard_resize_policy<
559 pb_ds::test::hash_exponential_size_policy_t_<
561 no_access_half_load_check_resize_trigger_policy>
562 mask_half_resize_policy_t;
565 pb_ds::hash_standard_resize_policy<
566 pb_ds::test::hash_exponential_size_policy_t_<
568 no_access_one_load_check_resize_trigger_policy>
569 mask_one_resize_policy_t;
572 pb_ds::hash_standard_resize_policy<
573 pb_ds::test::hash_prime_size_policy_t_,
574 no_access_half_load_check_resize_trigger_policy>
575 mod_half_resize_policy_t;
578 pb_ds::hash_standard_resize_policy<
579 pb_ds::test::hash_prime_size_policy_t_,
580 no_access_one_load_check_resize_trigger_policy>
581 mod_one_resize_policy_t;
583 template<typename Comb_Hash_Fn_>
584 struct half_resize_policy_selector;
586 template<typename Allocator_>
587 struct half_resize_policy_selector<
588 pb_ds::test::direct_mask_range_hashing_t_<
591 typedef mask_half_resize_policy_t type;
594 template<typename Allocator_>
595 struct half_resize_policy_selector<
596 pb_ds::test::direct_mod_range_hashing_t_<
599 typedef mod_half_resize_policy_t type;
602 template<typename Comb_Hash_Fn_>
603 struct one_resize_policy_selector;
605 template<typename Allocator_>
606 struct one_resize_policy_selector<
607 pb_ds::test::direct_mask_range_hashing_t_<
610 typedef mask_one_resize_policy_t type;
613 template<typename Allocator_>
614 struct one_resize_policy_selector<
615 pb_ds::test::direct_mod_range_hashing_t_<
618 typedef mod_one_resize_policy_t type;
621 template<typename Comb_Hash_Fn>
622 struct generic_cc_hash_table_t
625 pb_ds::cc_hash_table<
631 typename one_resize_policy_selector<
632 typename Comb_Hash_Fn::comb_fn>::type,
639 typename pb_ds::detail::typelist_transform<
641 generic_cc_hash_table_t>::type
642 performance_cc_types;
644 template<typename Comb_Probe_Fn>
645 struct no_access_generic_gp_hash_table_t
648 pb_ds::gp_hash_table<
654 pb_ds::null_probe_fn,
655 typename half_resize_policy_selector<
656 typename Comb_Probe_Fn::comb_fn>::type,
663 typename pb_ds::detail::typelist_transform<
665 no_access_generic_gp_hash_table_t>::type
666 performance_gp_types;
670 typename pb_ds::detail::typelist_append<
671 performance_cc_types,
672 performance_gp_types>::type
676 template<typename Key, typename Data, class Eq_Fn = std::equal_to<Key>,
678 std::allocator<char> >
679 class lu_common_types
682 typedef typename Allocator::size_type size_type;
684 typedef pb_ds::test::move_to_front_lu_policy_t_ mtf_u;
686 typedef pb_ds::test::counter_lu_policy_t_< Allocator, 5> cnt_5_u;
688 typedef typename pb_ds::detail::typelist1< mtf_u>::type lu_policy0;
690 typedef typename pb_ds::detail::typelist1< cnt_5_u>::type lu_policy1;
693 typename pb_ds::detail::typelist2<
698 template<typename Policy_Tl>
699 struct generic_list_update_t
703 typename pb_ds::detail::typelist_at_index<
719 typename pb_ds::detail::typelist_transform<
721 generic_list_update_t>::type
725 typename pb_ds::detail::typelist_at_index<
731 typedef lu_types performance_tl;
733 typedef lu_types regression_tl;
736 typename pb_ds::detail::typelist1<
741 template<typename Key, typename Data, class Cmp_Fn = std::less<Key>,
742 template<typename Const_Node_Iterator,
747 pb_ds::null_tree_node_update,
749 std::allocator<std::pair<const Key, Data> > >
750 struct tree_common_types
761 ov_tree_assoc_container_t;
771 rb_tree_assoc_container_t;
778 pb_ds::splay_tree_tag,
781 splay_tree_assoc_container_t;
785 typename pb_ds::detail::typelist3<
786 splay_tree_assoc_container_t,
787 rb_tree_assoc_container_t,
788 ov_tree_assoc_container_t>::type
792 typename pb_ds::detail::typelist3<
793 ov_tree_assoc_container_t,
794 splay_tree_assoc_container_t,
795 rb_tree_assoc_container_t>::type
799 typename pb_ds::detail::typelist1<
800 rb_tree_assoc_container_t>::type
804 template<typename Key,
806 class E_Access_Traits =
807 typename pb_ds::detail::default_trie_e_access_traits<
811 template<typename Const_Node_Iterator,
812 typename Node_Iterator,
813 class E_Access_Traits_,
816 pb_ds::null_trie_node_update,
818 std::allocator<char> >
819 class trie_common_types
833 typedef typename pb_ds::detail::typelist1< type>::type performance_tl;
835 typedef typename pb_ds::detail::typelist1< type>::type regression_tl;
838 typename pb_ds::detail::typelist1<
847 #endif // #ifndef PB_DS_COMMON_TYPES_HPP