41 #ifndef PB_DS_ASSOC_CNTNR_HPP
42 #define PB_DS_ASSOC_CNTNR_HPP
49 #include <ext/pb_ds/detail/basic_tree_policy/traits.hpp>
68 #define PB_DS_BASE_C_DEC \
69 detail::container_base_dispatch<Key, Mapped, Tag, Policy_Tl, Allocator>::type
72 template<
typename Key,
80 typedef typename PB_DS_BASE_C_DEC base_type;
83 typedef Tag container_category;
84 typedef Allocator allocator_type;
85 typedef typename allocator_type::size_type size_type;
86 typedef typename allocator_type::difference_type difference_type;
89 typedef typename allocator_type::template rebind<Key>::other::value_type key_type;
90 typedef typename allocator_type::template rebind<key_type>::other key_rebind;
91 typedef typename key_rebind::reference key_reference;
92 typedef typename key_rebind::const_reference const_key_reference;
93 typedef typename key_rebind::pointer key_pointer;
94 typedef typename key_rebind::const_pointer const_key_pointer;
97 typedef Mapped mapped_type;
98 typedef typename allocator_type::template rebind<mapped_type>::other mapped_rebind;
99 typedef typename mapped_rebind::reference mapped_reference;
100 typedef typename mapped_rebind::const_reference const_mapped_reference;
101 typedef typename mapped_rebind::pointer mapped_pointer;
102 typedef typename mapped_rebind::const_pointer const_mapped_pointer;
105 typedef typename base_type::value_type value_type;
106 typedef typename allocator_type::template rebind<value_type>::other value_rebind;
107 typedef typename value_rebind::reference reference;
108 typedef typename value_rebind::const_reference const_reference;
109 typedef typename value_rebind::pointer pointer;
110 typedef typename value_rebind::const_pointer const_pointer;
113 typedef typename base_type::iterator iterator;
114 typedef typename base_type::const_iterator const_iterator;
115 typedef typename base_type::point_iterator point_iterator;
116 typedef typename base_type::const_point_iterator const_point_iterator;
122 #define PB_DS_CLASS_NAME container_base
124 #undef PB_DS_CLASS_NAME
127 #undef PB_DS_BASE_C_DEC
130 #define PB_DS_BASE_C_DEC \
131 container_base<Key, Mapped, Tag, typename __gnu_cxx::typelist::append< \
132 typename __gnu_cxx::typelist::create4<Hash_Fn, Eq_Fn, Resize_Policy, detail::integral_constant<int, Store_Hash> >::type, Policy_TL>::type, Allocator>
135 template<
typename Key,
139 typename Resize_Policy,
154 #define PB_DS_CLASS_NAME basic_hash_table
156 #undef PB_DS_CLASS_NAME
163 #undef PB_DS_BASE_C_DEC
166 #define PB_DS_BASE_C_DEC \
167 basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
169 typename __gnu_cxx::typelist::create1<Comb_Hash_Fn>::type, Allocator>
172 template<
typename Key,
174 typename Hash_Fn =
typename detail::default_hash_fn<Key>::type,
176 typename Comb_Hash_Fn = detail::default_comb_hash_fn::type,
177 typename Resize_Policy =
typename detail::default_resize_policy<Comb_Hash_Fn>::type,
178 bool Store_Hash = detail::default_store_hash,
186 typedef Hash_Fn hash_fn;
188 typedef Resize_Policy resize_policy;
189 typedef Comb_Hash_Fn comb_hash_fn;
211 cc_hash_table(
const hash_fn& h,
const eq_fn& e,
const comb_hash_fn& ch)
220 cc_hash_table(
const hash_fn& h,
const eq_fn& e,
const comb_hash_fn& ch,
221 const resize_policy& rp)
227 template<
typename It>
229 { base_type::copy_from_range(first, last); }
234 template<
typename It>
237 { copy_from_range(first, last); }
245 template<
typename It>
246 cc_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e)
248 { copy_from_range(first, last); }
257 template<
typename It>
258 cc_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e,
259 const comb_hash_fn& ch)
261 { copy_from_range(first, last); }
271 template<
typename It>
272 cc_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e,
273 const comb_hash_fn& ch,
const resize_policy& rp)
275 { copy_from_range(first, last); }
297 { base_type::swap(other); }
300 #undef PB_DS_BASE_C_DEC
303 #define PB_DS_BASE_C_DEC \
304 basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
306 typename __gnu_cxx::typelist::create2<Comb_Probe_Fn, Probe_Fn>::type, Allocator>
309 template<
typename Key,
311 typename Hash_Fn =
typename detail::default_hash_fn<Key>::type,
313 typename Comb_Probe_Fn = detail::default_comb_hash_fn::type,
314 typename Probe_Fn =
typename detail::default_probe_fn<Comb_Probe_Fn>::type,
315 typename Resize_Policy =
typename detail::default_resize_policy<Comb_Probe_Fn>::type,
316 bool Store_Hash = detail::default_store_hash,
324 typedef Hash_Fn hash_fn;
326 typedef Comb_Probe_Fn comb_probe_fn;
327 typedef Probe_Fn probe_fn;
328 typedef Resize_Policy resize_policy;
350 gp_hash_table(
const hash_fn& h,
const eq_fn& e,
const comb_probe_fn& cp)
359 gp_hash_table(
const hash_fn& h,
const eq_fn& e,
const comb_probe_fn& cp,
370 gp_hash_table(
const hash_fn& h,
const eq_fn& e,
const comb_probe_fn& cp,
371 const probe_fn& p,
const resize_policy& rp)
377 template<
typename It>
379 { base_type::copy_from_range(first, last); }
385 template<
typename It>
388 { base_type::copy_from_range(first, last); }
396 template<
typename It>
397 gp_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e)
399 { base_type::copy_from_range(first, last); }
408 template<
typename It>
409 gp_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e,
410 const comb_probe_fn& cp)
412 { base_type::copy_from_range(first, last); }
422 template<
typename It>
423 gp_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e,
424 const comb_probe_fn& cp,
const probe_fn& p)
426 { base_type::copy_from_range(first, last); }
438 template<
typename It>
439 gp_hash_table(It first, It last,
const hash_fn& h,
const eq_fn& e,
440 const comb_probe_fn& cp,
const probe_fn& p,
441 const resize_policy& rp)
443 { base_type::copy_from_range(first, last); }
465 { base_type::swap(other); }
468 #undef PB_DS_BASE_C_DEC
471 #define PB_DS_BASE_C_DEC \
472 container_base<Key, Mapped, Tag, Policy_Tl, Allocator>
475 template<
typename Key,
typename Mapped,
typename Tag,
476 typename Node_Update,
typename Policy_Tl,
typename Allocator>
480 typedef PB_DS_BASE_C_DEC base_type;
483 typedef Node_Update node_update;
489 #define PB_DS_CLASS_NAME basic_tree
491 #undef PB_DS_CLASS_NAME
494 #undef PB_DS_BASE_C_DEC
497 #define PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC \
498 detail::tree_traits<Key, Mapped,Cmp_Fn,Node_Update,Tag, Allocator>
500 #define PB_DS_BASE_C_DEC \
501 basic_tree<Key,Mapped,Tag,typename PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC::node_update, \
502 typename __gnu_cxx::typelist::create2<Cmp_Fn, PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC >::type, Allocator>
505 template<
typename Key,
typename Mapped,
typename Cmp_Fn = std::less<Key>,
506 typename Tag = rb_tree_tag,
507 template<
typename Const_Node_Iterator,
typename Node_Iterator,
typename Cmp_Fn_,
typename Allocator_>
508 class Node_Update = __gnu_pbds::null_tree_node_update,
510 class tree :
public PB_DS_BASE_C_DEC
517 typedef Cmp_Fn cmp_fn;
523 tree(
const cmp_fn& c)
529 template<
typename It>
530 tree(It first, It last)
531 { base_type::copy_from_range(first, last); }
537 template<
typename It>
538 tree(It first, It last,
const cmp_fn& c)
540 { base_type::copy_from_range(first, last); }
549 operator=(
const tree& other)
561 { base_type::swap(other); }
564 #undef PB_DS_BASE_C_DEC
565 #undef PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC
568 #define PB_DS_TRIE_NODE_AND_ITS_TRAITS \
569 detail::trie_traits<Key,Mapped,E_Access_Traits,Node_Update,Tag,Allocator>
571 #define PB_DS_BASE_C_DEC \
572 basic_tree<Key,Mapped,Tag, typename PB_DS_TRIE_NODE_AND_ITS_TRAITS::node_update, \
573 typename __gnu_cxx::typelist::create2<E_Access_Traits, PB_DS_TRIE_NODE_AND_ITS_TRAITS >::type, Allocator>
576 template<
typename Key,
578 typename E_Access_Traits =
typename detail::default_trie_e_access_traits<Key>::type,
580 template<
typename Const_Node_Iterator,
581 typename Node_Iterator,
582 typename E_Access_Traits_,
584 class Node_Update = null_trie_node_update,
586 class trie :
public PB_DS_BASE_C_DEC
593 typedef E_Access_Traits e_access_traits;
600 trie(
const e_access_traits& t)
606 template<
typename It>
607 trie(It first, It last)
608 { base_type::copy_from_range(first, last); }
613 template<
typename It>
614 trie(It first, It last,
const e_access_traits& t)
616 { base_type::copy_from_range(first, last); }
625 operator=(
const trie& other)
637 { base_type::swap(other); }
640 #undef PB_DS_BASE_C_DEC
641 #undef PB_DS_TRIE_NODE_AND_ITS_TRAITS
644 #define PB_DS_BASE_C_DEC \
645 container_base<Key, Mapped, list_update_tag, \
646 typename __gnu_cxx::typelist::create2<Eq_Fn, Update_Policy>::type, Allocator>
649 template<
typename Key,
652 class Update_Policy = detail::default_update_policy::type,
661 typedef Update_Policy update_policy;
662 typedef Allocator allocator;
669 template<
typename It>
671 { base_type::copy_from_range(first, last); }
692 { base_type::swap(other); }
695 #undef PB_DS_BASE_C_DEC