65 #ifdef PB_DS_DATA_TRUE_INDICATOR
66 #define PB_DS_PAT_TRIE_NAME pat_trie_map
69 #ifdef PB_DS_DATA_FALSE_INDICATOR
70 #define PB_DS_PAT_TRIE_NAME pat_trie_set
73 #define PB_DS_CLASS_T_DEC \
74 template<typename Key, typename Mapped, typename Node_And_It_Traits, \
77 #define PB_DS_CLASS_C_DEC \
78 PB_DS_PAT_TRIE_NAME<Key, Mapped, Node_And_It_Traits, _Alloc>
80 #define PB_DS_PAT_TRIE_TRAITS_BASE \
81 types_traits<Key, Mapped, _Alloc, false>
84 #define PB_DS_DEBUG_MAP_BASE_C_DEC \
85 debug_map_base<Key, eq_by_less<Key, std::less<Key> >, \
86 typename _Alloc::template rebind<Key>::other::const_reference>
99 template<
typename Key,
typename Mapped,
typename Node_And_It_Traits,
101 class PB_DS_PAT_TRIE_NAME :
102 #ifdef _GLIBCXX_DEBUG
103 public PB_DS_DEBUG_MAP_BASE_C_DEC,
105 public Node_And_It_Traits::synth_access_traits,
106 public Node_And_It_Traits::node_update,
107 public PB_DS_PAT_TRIE_TRAITS_BASE,
113 typedef Node_And_It_Traits traits_type;
115 typedef typename traits_type::synth_access_traits synth_access_traits;
116 typedef typename synth_access_traits::const_iterator a_const_iterator;
118 typedef typename traits_type::node node;
119 typedef typename _Alloc::template rebind<node> __rebind_n;
120 typedef typename __rebind_n::other::const_pointer node_const_pointer;
121 typedef typename __rebind_n::other::pointer node_pointer;
123 typedef typename traits_type::head head;
124 typedef typename _Alloc::template rebind<head> __rebind_h;
125 typedef typename __rebind_h::other head_allocator;
126 typedef typename head_allocator::pointer head_pointer;
128 typedef typename traits_type::leaf leaf;
129 typedef typename _Alloc::template rebind<leaf> __rebind_l;
130 typedef typename __rebind_l::other leaf_allocator;
131 typedef typename leaf_allocator::pointer leaf_pointer;
132 typedef typename leaf_allocator::const_pointer leaf_const_pointer;
134 typedef typename traits_type::inode inode;
135 typedef typename inode::iterator inode_iterator;
136 typedef typename _Alloc::template rebind<inode> __rebind_in;
137 typedef typename __rebind_in::other __rebind_ina;
138 typedef typename __rebind_in::other inode_allocator;
139 typedef typename __rebind_ina::pointer inode_pointer;
140 typedef typename __rebind_ina::const_pointer inode_const_pointer;
148 bool m_no_action_dtor;
149 bool m_call_destructor;
152 cond_dealtor(leaf_pointer p_nd)
153 : m_p_nd(p_nd), m_no_action_dtor(
false), m_call_destructor(
false)
158 { m_no_action_dtor =
true; }
161 set_call_destructor()
162 { m_call_destructor =
true; }
166 if (m_no_action_dtor)
169 if (m_call_destructor)
172 s_leaf_allocator.deallocate(m_p_nd, 1);
181 typedef inode_pointer __inp;
182 typedef typename _Alloc::template rebind<__inp>::other __rebind_inp;
184 #ifdef _GLIBCXX_DEBUG
185 typedef std::_GLIBCXX_STD_C::list<__inp, __rebind_inp> bag_type;
195 inode_pointer p_nd = s_inode_allocator.allocate(1);
198 m_bag.push_back(p_nd);
202 s_inode_allocator.deallocate(p_nd, 1);
203 __throw_exception_again;
210 _GLIBCXX_DEBUG_ASSERT(!m_bag.empty());
211 inode_pointer p_nd = *m_bag.begin();
218 while (!m_bag.empty())
220 inode_pointer p_nd = *m_bag.begin();
221 s_inode_allocator.deallocate(p_nd, 1);
228 {
return m_bag.empty(); }
231 #ifdef _GLIBCXX_DEBUG
232 typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
235 typedef typename traits_type::null_node_update_pointer null_node_update_pointer;
238 typedef pat_trie_tag container_category;
239 typedef _Alloc allocator_type;
240 typedef typename _Alloc::size_type size_type;
241 typedef typename _Alloc::difference_type difference_type;
243 typedef typename traits_base::key_type key_type;
244 typedef typename traits_base::key_pointer key_pointer;
245 typedef typename traits_base::key_const_pointer key_const_pointer;
246 typedef typename traits_base::key_reference key_reference;
247 typedef typename traits_base::key_const_reference key_const_reference;
248 typedef typename traits_base::mapped_type mapped_type;
249 typedef typename traits_base::mapped_pointer mapped_pointer;
250 typedef typename traits_base::mapped_const_pointer mapped_const_pointer;
251 typedef typename traits_base::mapped_reference mapped_reference;
252 typedef typename traits_base::mapped_const_reference mapped_const_reference;
253 typedef typename traits_base::value_type value_type;
254 typedef typename traits_base::pointer pointer;
255 typedef typename traits_base::const_pointer const_pointer;
256 typedef typename traits_base::reference reference;
257 typedef typename traits_base::const_reference const_reference;
259 typedef typename traits_type::access_traits access_traits;
260 typedef typename traits_type::const_iterator point_const_iterator;
261 typedef typename traits_type::iterator point_iterator;
262 typedef point_const_iterator const_iterator;
263 typedef point_iterator iterator;
265 typedef typename traits_type::reverse_iterator reverse_iterator;
266 typedef typename traits_type::const_reverse_iterator const_reverse_iterator;
267 typedef typename traits_type::node_const_iterator node_const_iterator;
268 typedef typename traits_type::node_iterator node_iterator;
269 typedef typename traits_type::node_update node_update;
271 PB_DS_PAT_TRIE_NAME();
273 PB_DS_PAT_TRIE_NAME(
const access_traits&);
275 PB_DS_PAT_TRIE_NAME(
const PB_DS_CLASS_C_DEC&);
278 swap(PB_DS_CLASS_C_DEC&);
280 ~PB_DS_PAT_TRIE_NAME();
295 get_access_traits()
const;
301 get_node_update()
const;
304 insert(const_reference);
306 inline mapped_reference
309 #ifdef PB_DS_DATA_TRUE_INDICATOR
310 return insert(
std::make_pair(r_key, mapped_type())).first->second;
313 return traits_base::s_null_type;
317 inline point_iterator
318 find(key_const_reference);
320 inline point_const_iterator
321 find(key_const_reference)
const;
323 inline point_iterator
324 lower_bound(key_const_reference);
326 inline point_const_iterator
327 lower_bound(key_const_reference)
const;
329 inline point_iterator
330 upper_bound(key_const_reference);
332 inline point_const_iterator
333 upper_bound(key_const_reference)
const;
339 erase(key_const_reference);
341 inline const_iterator
342 erase(const_iterator);
344 #ifdef PB_DS_DATA_TRUE_INDICATOR
349 inline const_reverse_iterator
350 erase(const_reverse_iterator);
352 #ifdef PB_DS_DATA_TRUE_INDICATOR
353 inline reverse_iterator
354 erase(reverse_iterator);
357 template<
typename Pred>
362 join(PB_DS_CLASS_C_DEC&);
365 split(key_const_reference, PB_DS_CLASS_C_DEC&);
370 inline const_iterator
376 inline const_iterator
379 inline reverse_iterator
382 inline const_reverse_iterator
385 inline reverse_iterator
388 inline const_reverse_iterator
393 inline node_const_iterator
403 inline node_const_iterator
411 #ifdef PB_DS_PAT_TRIE_TRACE_
417 template<
typename It>
419 copy_from_range(It, It);
422 value_swap(PB_DS_CLASS_C_DEC&);
425 recursive_copy_node(node_const_pointer);
432 apply_update(node_pointer, null_node_update_pointer);
434 template<
typename Node_Update_>
436 apply_update(node_pointer, Node_Update_*);
439 join_prep(PB_DS_CLASS_C_DEC&, branch_bag&);
442 rec_join_prep(node_const_pointer, node_const_pointer, branch_bag&);
445 rec_join_prep(leaf_const_pointer, leaf_const_pointer, branch_bag&);
448 rec_join_prep(leaf_const_pointer, inode_const_pointer, branch_bag&);
451 rec_join_prep(inode_const_pointer, leaf_const_pointer, branch_bag&);
454 rec_join_prep(inode_const_pointer, inode_const_pointer, branch_bag&);
457 rec_join(node_pointer, node_pointer, size_type, branch_bag&);
460 rec_join(leaf_pointer, leaf_pointer, branch_bag&);
463 rec_join(leaf_pointer, inode_pointer, size_type, branch_bag&);
466 rec_join(inode_pointer, leaf_pointer, size_type, branch_bag&);
469 rec_join(inode_pointer, inode_pointer, branch_bag&);
472 keys_diff_ind(
typename access_traits::const_iterator,
473 typename access_traits::const_iterator,
474 typename access_traits::const_iterator,
475 typename access_traits::const_iterator);
478 insert_branch(node_pointer, node_pointer, branch_bag&);
481 update_min_max_for_inserted_leaf(leaf_pointer);
484 erase_leaf(leaf_pointer);
487 actual_erase_leaf(leaf_pointer);
490 clear_imp(node_pointer);
493 erase_fixup(inode_pointer);
496 update_min_max_for_erased_leaf(leaf_pointer);
498 static inline a_const_iterator
499 pref_begin(node_const_pointer);
501 static inline a_const_iterator
502 pref_end(node_const_pointer);
505 find_imp(key_const_reference);
508 lower_bound_imp(key_const_reference);
511 upper_bound_imp(key_const_reference);
513 inline static leaf_const_pointer
514 leftmost_descendant(node_const_pointer);
516 inline static leaf_pointer
517 leftmost_descendant(node_pointer);
519 inline static leaf_const_pointer
520 rightmost_descendant(node_const_pointer);
522 inline static leaf_pointer
523 rightmost_descendant(node_pointer);
525 #ifdef _GLIBCXX_DEBUG
527 assert_valid(
const char*,
int)
const;
530 assert_iterators(
const char*,
int)
const;
533 assert_reverse_iterators(
const char*,
int)
const;
536 recursive_count_leafs(node_const_pointer,
const char*,
int);
539 #ifdef PB_DS_PAT_TRIE_TRACE_
541 trace_node(node_const_pointer, size_type);
543 template<
typename Metadata_>
545 trace_node_metadata(node_const_pointer, type_to_type<Metadata_>);
548 trace_node_metadata(node_const_pointer, type_to_type<null_type>);
552 split_prep(key_const_reference, PB_DS_CLASS_C_DEC&, branch_bag&);
555 rec_split(node_pointer, a_const_iterator, a_const_iterator,
556 PB_DS_CLASS_C_DEC&, branch_bag&);
559 split_insert_branch(size_type, a_const_iterator, inode_iterator,
560 size_type, branch_bag&);
562 static head_allocator s_head_allocator;
563 static inode_allocator s_inode_allocator;
564 static leaf_allocator s_leaf_allocator;
566 head_pointer m_p_head;
570 #define PB_DS_ASSERT_NODE_VALID(X) \
571 _GLIBCXX_DEBUG_ONLY(X->assert_valid(this, __FILE__, __LINE__);)
573 #define PB_DS_RECURSIVE_COUNT_LEAFS(X) \
574 recursive_count_leafs(X, __FILE__, __LINE__)
588 #undef PB_DS_RECURSIVE_COUNT_LEAFS
589 #undef PB_DS_ASSERT_NODE_VALID
590 #undef PB_DS_CLASS_C_DEC
591 #undef PB_DS_CLASS_T_DEC
592 #undef PB_DS_PAT_TRIE_NAME
593 #undef PB_DS_PAT_TRIE_TRAITS_BASE
594 #undef PB_DS_DEBUG_MAP_BASE_C_DEC
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
constexpr size_t size() const noexcept
Returns the total number of bits.
Struct holding two objects of arbitrary type.
Base type for PATRICIA trees.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
reference operator[](size_t __position)
Array-indexing support.