fix doc example typo
[boost.git] / boost / intrusive / treap_set.hpp
blob9322a6b9adde6c463feb60244d665bffc4b39dd8
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2007-2008
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 // (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/intrusive for documentation.
11 /////////////////////////////////////////////////////////////////////////////
12 #ifndef BOOST_INTRUSIVE_TRIE_SET_HPP
13 #define BOOST_INTRUSIVE_TRIE_SET_HPP
15 #include <boost/intrusive/detail/config_begin.hpp>
16 #include <boost/intrusive/intrusive_fwd.hpp>
17 #include <boost/intrusive/treap.hpp>
18 #include <boost/intrusive/detail/mpl.hpp>
19 #include <iterator>
21 namespace boost {
22 namespace intrusive {
24 //! The class template treap_set is an intrusive container, that mimics most of
25 //! the interface of std::set as described in the C++ standard.
26 //!
27 //! The template parameter \c T is the type to be managed by the container.
28 //! The user can specify additional options and if no options are provided
29 //! default options are used.
30 //!
31 //! The container supports the following options:
32 //! \c base_hook<>/member_hook<>/value_traits<>,
33 //! \c constant_time_size<>, \c size_type<>,
34 //! \c compare<> and \c priority_compare<>
35 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
36 template<class T, class ...Options>
37 #else
38 template<class Config>
39 #endif
40 class treap_set_impl
42 /// @cond
43 typedef treap_impl<Config> tree_type;
44 //! This class is
45 //! non-copyable
46 treap_set_impl (const treap_set_impl&);
48 //! This class is
49 //! non-assignable
50 treap_set_impl &operator =(const treap_set_impl&);
52 typedef tree_type implementation_defined;
53 /// @endcond
55 public:
56 typedef typename implementation_defined::value_type value_type;
57 typedef typename implementation_defined::value_traits value_traits;
58 typedef typename implementation_defined::pointer pointer;
59 typedef typename implementation_defined::const_pointer const_pointer;
60 typedef typename implementation_defined::reference reference;
61 typedef typename implementation_defined::const_reference const_reference;
62 typedef typename implementation_defined::difference_type difference_type;
63 typedef typename implementation_defined::size_type size_type;
64 typedef typename implementation_defined::value_compare value_compare;
65 typedef typename implementation_defined::priority_compare priority_compare;
66 typedef typename implementation_defined::key_compare key_compare;
67 typedef typename implementation_defined::iterator iterator;
68 typedef typename implementation_defined::const_iterator const_iterator;
69 typedef typename implementation_defined::reverse_iterator reverse_iterator;
70 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
71 typedef typename implementation_defined::insert_commit_data insert_commit_data;
72 typedef typename implementation_defined::node_traits node_traits;
73 typedef typename implementation_defined::node node;
74 typedef typename implementation_defined::node_ptr node_ptr;
75 typedef typename implementation_defined::const_node_ptr const_node_ptr;
76 typedef typename implementation_defined::node_algorithms node_algorithms;
78 /// @cond
79 private:
80 tree_type tree_;
81 /// @endcond
83 public:
84 //! <b>Effects</b>: Constructs an empty treap_set.
85 //!
86 //! <b>Complexity</b>: Constant.
87 //!
88 //! <b>Throws</b>: If value_traits::node_traits::node
89 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
90 //! or the copy constructor of the value_compare object throws.
91 treap_set_impl( const value_compare &cmp = value_compare()
92 , const priority_compare &pcmp = priority_compare()
93 , const value_traits &v_traits = value_traits())
94 : tree_(cmp, pcmp, v_traits)
97 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
98 //! cmp must be a comparison function that induces a strict weak ordering.
99 //!
100 //! <b>Effects</b>: Constructs an empty treap_set and inserts elements from
101 //! [b, e).
102 //!
103 //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using
104 //! comp and otherwise N * log N, where N is std::distance(last, first).
105 //!
106 //! <b>Throws</b>: If value_traits::node_traits::node
107 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
108 //! or the copy constructor/operator() of the value_compare object throws.
109 template<class Iterator>
110 treap_set_impl( Iterator b, Iterator e
111 , const value_compare &cmp = value_compare()
112 , const priority_compare &pcmp = priority_compare()
113 , const value_traits &v_traits = value_traits())
114 : tree_(true, b, e, cmp, pcmp, v_traits)
117 //! <b>Effects</b>: Detaches all elements from this. The objects in the treap_set
118 //! are not deleted (i.e. no destructors are called).
119 //!
120 //! <b>Complexity</b>: Linear to the number of elements on the container.
121 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
122 //!
123 //! <b>Throws</b>: Nothing.
124 ~treap_set_impl()
127 //! <b>Effects</b>: Returns an iterator pointing to the beginning of the treap_set.
128 //!
129 //! <b>Complexity</b>: Constant.
130 //!
131 //! <b>Throws</b>: Nothing.
132 iterator begin()
133 { return tree_.begin(); }
135 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_set.
136 //!
137 //! <b>Complexity</b>: Constant.
138 //!
139 //! <b>Throws</b>: Nothing.
140 const_iterator begin() const
141 { return tree_.begin(); }
143 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_set.
144 //!
145 //! <b>Complexity</b>: Constant.
146 //!
147 //! <b>Throws</b>: Nothing.
148 const_iterator cbegin() const
149 { return tree_.cbegin(); }
151 //! <b>Effects</b>: Returns an iterator pointing to the end of the treap_set.
152 //!
153 //! <b>Complexity</b>: Constant.
154 //!
155 //! <b>Throws</b>: Nothing.
156 iterator end()
157 { return tree_.end(); }
159 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_set.
160 //!
161 //! <b>Complexity</b>: Constant.
162 //!
163 //! <b>Throws</b>: Nothing.
164 const_iterator end() const
165 { return tree_.end(); }
167 //! <b>Effects</b>: Returns an iterator pointing to the highest priority object of the tree.
168 //!
169 //! <b>Complexity</b>: Constant.
170 //!
171 //! <b>Throws</b>: Nothing.
172 iterator top()
173 { return tree_.top(); }
175 //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree..
176 //!
177 //! <b>Complexity</b>: Constant.
178 //!
179 //! <b>Throws</b>: Nothing.
180 const_iterator top() const
181 { return this->ctop(); }
183 //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree..
184 //!
185 //! <b>Complexity</b>: Constant.
186 //!
187 //! <b>Throws</b>: Nothing.
188 const_iterator ctop() const
189 { return tree_.ctop(); }
191 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_set.
192 //!
193 //! <b>Complexity</b>: Constant.
194 //!
195 //! <b>Throws</b>: Nothing.
196 const_iterator cend() const
197 { return tree_.cend(); }
199 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the
200 //! reversed treap_set.
201 //!
202 //! <b>Complexity</b>: Constant.
203 //!
204 //! <b>Throws</b>: Nothing.
205 reverse_iterator rbegin()
206 { return tree_.rbegin(); }
208 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
209 //! of the reversed treap_set.
210 //!
211 //! <b>Complexity</b>: Constant.
212 //!
213 //! <b>Throws</b>: Nothing.
214 const_reverse_iterator rbegin() const
215 { return tree_.rbegin(); }
217 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
218 //! of the reversed treap_set.
219 //!
220 //! <b>Complexity</b>: Constant.
221 //!
222 //! <b>Throws</b>: Nothing.
223 const_reverse_iterator crbegin() const
224 { return tree_.crbegin(); }
226 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
227 //! of the reversed treap_set.
228 //!
229 //! <b>Complexity</b>: Constant.
230 //!
231 //! <b>Throws</b>: Nothing.
232 reverse_iterator rend()
233 { return tree_.rend(); }
235 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
236 //! of the reversed treap_set.
237 //!
238 //! <b>Complexity</b>: Constant.
239 //!
240 //! <b>Throws</b>: Nothing.
241 const_reverse_iterator rend() const
242 { return tree_.rend(); }
244 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
245 //! of the reversed treap_set.
246 //!
247 //! <b>Complexity</b>: Constant.
248 //!
249 //! <b>Throws</b>: Nothing.
250 const_reverse_iterator crend() const
251 { return tree_.crend(); }
253 //! <b>Effects</b>: Returns a reverse_iterator pointing to the highest priority object of the
254 //! reversed tree.
255 //!
256 //! <b>Complexity</b>: Constant.
257 //!
258 //! <b>Throws</b>: Nothing.
259 reverse_iterator rtop()
260 { return tree_.rtop(); }
262 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority objec
263 //! of the reversed tree.
264 //!
265 //! <b>Complexity</b>: Constant.
266 //!
267 //! <b>Throws</b>: Nothing.
268 const_reverse_iterator rtop() const
269 { return tree_.crtop(); }
271 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority object
272 //! of the reversed tree.
273 //!
274 //! <b>Complexity</b>: Constant.
275 //!
276 //! <b>Throws</b>: Nothing.
277 const_reverse_iterator crtop() const
278 { return tree_.crtop(); }
280 //! <b>Precondition</b>: end_iterator must be a valid end iterator
281 //! of treap_set.
282 //!
283 //! <b>Effects</b>: Returns a const reference to the treap_set associated to the end iterator
284 //!
285 //! <b>Throws</b>: Nothing.
286 //!
287 //! <b>Complexity</b>: Constant.
288 static treap_set_impl &container_from_end_iterator(iterator end_iterator)
290 return *detail::parent_from_member<treap_set_impl, tree_type>
291 ( &tree_type::container_from_end_iterator(end_iterator)
292 , &treap_set_impl::tree_);
295 //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
296 //! of treap_set.
297 //!
298 //! <b>Effects</b>: Returns a const reference to the treap_set associated to the end iterator
299 //!
300 //! <b>Throws</b>: Nothing.
301 //!
302 //! <b>Complexity</b>: Constant.
303 static const treap_set_impl &container_from_end_iterator(const_iterator end_iterator)
305 return *detail::parent_from_member<treap_set_impl, tree_type>
306 ( &tree_type::container_from_end_iterator(end_iterator)
307 , &treap_set_impl::tree_);
310 //! <b>Precondition</b>: it must be a valid iterator of set.
311 //!
312 //! <b>Effects</b>: Returns a reference to the set associated to the iterator
313 //!
314 //! <b>Throws</b>: Nothing.
315 //!
316 //! <b>Complexity</b>: Logarithmic.
317 static treap_set_impl &container_from_iterator(iterator it)
319 return *detail::parent_from_member<treap_set_impl, tree_type>
320 ( &tree_type::container_from_iterator(it)
321 , &treap_set_impl::tree_);
324 //! <b>Precondition</b>: it must be a valid const_iterator of set.
325 //!
326 //! <b>Effects</b>: Returns a const reference to the set associated to the iterator
327 //!
328 //! <b>Throws</b>: Nothing.
329 //!
330 //! <b>Complexity</b>: Logarithmic.
331 static const treap_set_impl &container_from_iterator(const_iterator it)
333 return *detail::parent_from_member<treap_set_impl, tree_type>
334 ( &tree_type::container_from_iterator(it)
335 , &treap_set_impl::tree_);
338 //! <b>Effects</b>: Returns the key_compare object used by the treap_set.
339 //!
340 //! <b>Complexity</b>: Constant.
341 //!
342 //! <b>Throws</b>: If key_compare copy-constructor throws.
343 key_compare key_comp() const
344 { return tree_.value_comp(); }
346 //! <b>Effects</b>: Returns the value_compare object used by the treap_set.
347 //!
348 //! <b>Complexity</b>: Constant.
349 //!
350 //! <b>Throws</b>: If value_compare copy-constructor throws.
351 value_compare value_comp() const
352 { return tree_.value_comp(); }
354 //! <b>Effects</b>: Returns true if the container is empty.
355 //!
356 //! <b>Complexity</b>: Constant.
357 //!
358 //! <b>Throws</b>: Nothing.
359 bool empty() const
360 { return tree_.empty(); }
362 //! <b>Effects</b>: Returns the number of elements stored in the treap_set.
363 //!
364 //! <b>Complexity</b>: Linear to elements contained in *this if,
365 //! constant-time size option is enabled. Constant-time otherwise.
366 //!
367 //! <b>Throws</b>: Nothing.
368 size_type size() const
369 { return tree_.size(); }
371 //! <b>Effects</b>: Swaps the contents of two sets.
372 //!
373 //! <b>Complexity</b>: Constant.
374 //!
375 //! <b>Throws</b>: If the swap() call for the comparison functor
376 //! found using ADL throws. Strong guarantee.
377 void swap(treap_set_impl& other)
378 { tree_.swap(other.tree_); }
380 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
381 //! Cloner should yield to nodes equivalent to the original nodes.
383 //! <b>Effects</b>: Erases all the elements from *this
384 //! calling Disposer::operator()(pointer), clones all the
385 //! elements from src calling Cloner::operator()(const_reference )
386 //! and inserts them on *this. Copies the predicate from the source container.
388 //! If cloner throws, all cloned elements are unlinked and disposed
389 //! calling Disposer::operator()(pointer).
390 //!
391 //! <b>Complexity</b>: Linear to erased plus inserted elements.
392 //!
393 //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee.
394 template <class Cloner, class Disposer>
395 void clone_from(const treap_set_impl &src, Cloner cloner, Disposer disposer)
396 { tree_.clone_from(src.tree_, cloner, disposer); }
398 //! <b>Requires</b>: value must be an lvalue
399 //!
400 //! <b>Effects</b>: Tries to inserts value into the treap_set.
402 //! <b>Returns</b>: If the value
403 //! is not already present inserts it and returns a pair containing the
404 //! iterator to the new value and true. If there is an equivalent value
405 //! returns a pair containing an iterator to the already present value
406 //! and false.
407 //!
408 //! <b>Complexity</b>: Average complexity for insert element is at
409 //! most logarithmic.
410 //!
411 //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
412 //!
413 //! <b>Note</b>: Does not affect the validity of iterators and references.
414 //! No copy-constructors are called.
415 std::pair<iterator, bool> insert(reference value)
416 { return tree_.insert_unique(value); }
418 //! <b>Requires</b>: value must be an lvalue
419 //!
420 //! <b>Effects</b>: Tries to to insert x into the treap_set, using "hint"
421 //! as a hint to where it will be inserted.
423 //! <b>Returns</b>: An iterator that points to the position where the
424 //! new element was inserted into the treap_set.
425 //!
426 //! <b>Complexity</b>: Logarithmic in general, but it's amortized
427 //! constant time if t is inserted immediately before hint.
428 //!
429 //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
430 //!
431 //! <b>Note</b>: Does not affect the validity of iterators and references.
432 //! No copy-constructors are called.
433 iterator insert(const_iterator hint, reference value)
434 { return tree_.insert_unique(hint, value); }
436 //! <b>Requires</b>: key_value_comp must be a comparison function that induces
437 //! the same strict weak ordering as value_compare. The difference is that
438 //! key_value_comp compares an ascapegoatitrary key with the contained values.
439 //!
440 //! <b>Effects</b>: Checks if a value can be inserted in the treap_set, using
441 //! a user provided key instead of the value itself.
443 //! <b>Returns</b>: If there is an equivalent value
444 //! returns a pair containing an iterator to the already present value
445 //! and false. If the value can be inserted returns true in the returned
446 //! pair boolean and fills "commit_data" that is meant to be used with
447 //! the "insert_commit" function.
448 //!
449 //! <b>Complexity</b>: Average complexity is at most logarithmic.
451 //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee.
452 //!
453 //! <b>Notes</b>: This function is used to improve performance when constructing
454 //! a value_type is expensive: if there is an equivalent value
455 //! the constructed object must be discarded. Many times, the part of the
456 //! node that is used to impose the order is much cheaper to construct
457 //! than the value_type and this function offers the possibility to use that
458 //! part to check if the insertion will be successful.
460 //! If the check is successful, the user can construct the value_type and use
461 //! "insert_commit" to insert the object in constant-time. This gives a total
462 //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)).
464 //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
465 //! objects are inserted or erased from the treap_set.
466 template<class KeyType, class KeyValueCompare>
467 std::pair<iterator, bool> insert_check
468 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data)
469 { return tree_.insert_unique_check(key, key_value_comp, commit_data); }
471 //! <b>Requires</b>: key_value_comp must be a comparison function that induces
472 //! the same strict weak ordering as value_compare. The difference is that
473 //! key_value_comp compares an ascapegoatitrary key with the contained values.
474 //!
475 //! <b>Effects</b>: Checks if a value can be inserted in the treap_set, using
476 //! a user provided key instead of the value itself, using "hint"
477 //! as a hint to where it will be inserted.
479 //! <b>Returns</b>: If there is an equivalent value
480 //! returns a pair containing an iterator to the already present value
481 //! and false. If the value can be inserted returns true in the returned
482 //! pair boolean and fills "commit_data" that is meant to be used with
483 //! the "insert_commit" function.
484 //!
485 //! <b>Complexity</b>: Logarithmic in general, but it's amortized
486 //! constant time if t is inserted immediately before hint.
488 //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee.
489 //!
490 //! <b>Notes</b>: This function is used to improve performance when constructing
491 //! a value_type is expensive: if there is an equivalent value
492 //! the constructed object must be discarded. Many times, the part of the
493 //! constructing that is used to impose the order is much cheaper to construct
494 //! than the value_type and this function offers the possibility to use that key
495 //! to check if the insertion will be successful.
497 //! If the check is successful, the user can construct the value_type and use
498 //! "insert_commit" to insert the object in constant-time. This can give a total
499 //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)).
500 //!
501 //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
502 //! objects are inserted or erased from the treap_set.
503 template<class KeyType, class KeyValueCompare>
504 std::pair<iterator, bool> insert_check
505 (const_iterator hint, const KeyType &key
506 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data)
507 { return tree_.insert_unique_check(hint, key, key_value_comp, commit_data); }
509 //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
510 //! must have been obtained from a previous call to "insert_check".
511 //! No objects should have been inserted or erased from the treap_set between
512 //! the "insert_check" that filled "commit_data" and the call to "insert_commit".
513 //!
514 //! <b>Effects</b>: Inserts the value in the treap_set using the information obtained
515 //! from the "commit_data" that a previous "insert_check" filled.
517 //! <b>Returns</b>: An iterator to the newly inserted object.
518 //!
519 //! <b>Complexity</b>: Constant time.
521 //! <b>Throws</b>: Nothing.
522 //!
523 //! <b>Notes</b>: This function has only sense if a "insert_check" has been
524 //! previously executed to fill "commit_data". No value should be inserted or
525 //! erased between the "insert_check" and "insert_commit" calls.
526 iterator insert_commit(reference value, const insert_commit_data &commit_data)
527 { return tree_.insert_unique_commit(value, commit_data); }
529 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
530 //! of type value_type.
531 //!
532 //! <b>Effects</b>: Inserts a range into the treap_set.
533 //!
534 //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the
535 //! size of the range. However, it is linear in N if the range is already sorted
536 //! by value_comp().
537 //!
538 //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
539 //!
540 //! <b>Note</b>: Does not affect the validity of iterators and references.
541 //! No copy-constructors are called.
542 template<class Iterator>
543 void insert(Iterator b, Iterator e)
544 { tree_.insert_unique(b, e); }
546 //! <b>Effects</b>: Erases the element pointed to by pos.
547 //!
548 //! <b>Complexity</b>: Average complexity is constant time.
549 //!
550 //! <b>Returns</b>: An iterator to the element after the erased element.
552 //! <b>Throws</b>: Nothing.
553 //!
554 //! <b>Note</b>: Invalidates the iterators (but not the references)
555 //! to the erased elements. No destructors are called.
556 iterator erase(const_iterator i)
557 { return tree_.erase(i); }
559 //! <b>Effects</b>: Erases the range pointed to by b end e.
560 //!
561 //! <b>Complexity</b>: Average complexity for erase range is at most
562 //! O(log(size() + N)), where N is the number of elements in the range.
563 //!
564 //! <b>Returns</b>: An iterator to the element after the erased elements.
565 //!
566 //! <b>Throws</b>: Nothing.
567 //!
568 //! <b>Note</b>: Invalidates the iterators (but not the references)
569 //! to the erased elements. No destructors are called.
570 iterator erase(const_iterator b, const_iterator e)
571 { return tree_.erase(b, e); }
573 //! <b>Effects</b>: Erases all the elements with the given value.
574 //!
575 //! <b>Returns</b>: The number of erased elements.
576 //!
577 //! <b>Complexity</b>: O(log(size()) + this->count(value)).
578 //!
579 //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
580 //!
581 //! <b>Note</b>: Invalidates the iterators (but not the references)
582 //! to the erased elements. No destructors are called.
583 size_type erase(const_reference value)
584 { return tree_.erase(value); }
586 //! <b>Effects</b>: Erases all the elements that compare equal with
587 //! the given key and the given comparison functor.
588 //!
589 //! <b>Returns</b>: The number of erased elements.
590 //!
591 //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
592 //!
593 //! <b>Throws</b>: If the comp ordering function throws. Basic guarantee.
594 //!
595 //! <b>Note</b>: Invalidates the iterators (but not the references)
596 //! to the erased elements. No destructors are called.
597 template<class KeyType, class KeyValueCompare>
598 size_type erase(const KeyType& key, KeyValueCompare comp
599 /// @cond
600 , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
601 /// @endcond
603 { return tree_.erase(key, comp); }
605 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
607 //! <b>Effects</b>: Erases the element pointed to by pos.
608 //! Disposer::operator()(pointer) is called for the removed element.
609 //!
610 //! <b>Complexity</b>: Average complexity for erase element is constant time.
611 //!
612 //! <b>Returns</b>: An iterator to the element after the erased element.
613 //!
614 //! <b>Throws</b>: Nothing.
615 //!
616 //! <b>Note</b>: Invalidates the iterators
617 //! to the erased elements.
618 template<class Disposer>
619 iterator erase_and_dispose(const_iterator i, Disposer disposer)
620 { return tree_.erase_and_dispose(i, disposer); }
622 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
623 template<class Disposer>
624 iterator erase_and_dispose(iterator i, Disposer disposer)
625 { return this->erase_and_dispose(const_iterator(i), disposer); }
626 #endif
628 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
630 //! <b>Effects</b>: Erases the range pointed to by b end e.
631 //! Disposer::operator()(pointer) is called for the removed elements.
632 //!
633 //! <b>Complexity</b>: Average complexity for erase range is at most
634 //! O(log(size() + N)), where N is the number of elements in the range.
635 //!
636 //! <b>Returns</b>: An iterator to the element after the erased elements.
637 //!
638 //! <b>Throws</b>: Nothing.
639 //!
640 //! <b>Note</b>: Invalidates the iterators
641 //! to the erased elements.
642 template<class Disposer>
643 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
644 { return tree_.erase_and_dispose(b, e, disposer); }
646 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
648 //! <b>Effects</b>: Erases all the elements with the given value.
649 //! Disposer::operator()(pointer) is called for the removed elements.
650 //!
651 //! <b>Throws</b>: If the internal value_compare ordering function throws.
652 //!
653 //! <b>Complexity</b>: O(log(size() + this->count(value)). Basic guarantee.
654 //!
655 //! <b>Throws</b>: Nothing.
656 //!
657 //! <b>Note</b>: Invalidates the iterators (but not the references)
658 //! to the erased elements. No destructors are called.
659 template<class Disposer>
660 size_type erase_and_dispose(const_reference value, Disposer disposer)
661 { return tree_.erase_and_dispose(value, disposer); }
663 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
665 //! <b>Effects</b>: Erases all the elements with the given key.
666 //! according to the comparison functor "comp".
667 //! Disposer::operator()(pointer) is called for the removed elements.
669 //! <b>Returns</b>: The number of erased elements.
670 //!
671 //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
672 //!
673 //! <b>Throws</b>: If comp ordering function throws. Basic guarantee.
674 //!
675 //! <b>Note</b>: Invalidates the iterators
676 //! to the erased elements.
677 template<class KeyType, class KeyValueCompare, class Disposer>
678 size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer
679 /// @cond
680 , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
681 /// @endcond
683 { return tree_.erase_and_dispose(key, comp, disposer); }
685 //! <b>Effects</b>: Erases all the elements of the container.
686 //!
687 //! <b>Complexity</b>: Linear to the number of elements on the container.
688 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
689 //!
690 //! <b>Throws</b>: Nothing.
691 //!
692 //! <b>Note</b>: Invalidates the iterators (but not the references)
693 //! to the erased elements. No destructors are called.
694 void clear()
695 { return tree_.clear(); }
697 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
698 //!
699 //! <b>Effects</b>: Erases all the elements of the container.
700 //!
701 //! <b>Complexity</b>: Linear to the number of elements on the container.
702 //! Disposer::operator()(pointer) is called for the removed elements.
703 //!
704 //! <b>Throws</b>: Nothing.
705 //!
706 //! <b>Note</b>: Invalidates the iterators (but not the references)
707 //! to the erased elements. No destructors are called.
708 template<class Disposer>
709 void clear_and_dispose(Disposer disposer)
710 { return tree_.clear_and_dispose(disposer); }
712 //! <b>Effects</b>: Returns the number of contained elements with the given key
713 //!
714 //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
715 //! to number of objects with the given key.
716 //!
717 //! <b>Throws</b>: If the internal value_compare ordering function throws.
718 size_type count(const_reference value) const
719 { return tree_.find(value) != end(); }
721 //! <b>Effects</b>: Returns the number of contained elements with the same key
722 //! compared with the given comparison functor.
723 //!
724 //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
725 //! to number of objects with the given key.
726 //!
727 //! <b>Throws</b>: If comp ordering function throws.
728 template<class KeyType, class KeyValueCompare>
729 size_type count(const KeyType& key, KeyValueCompare comp) const
730 { return tree_.find(key, comp) != end(); }
732 //! <b>Effects</b>: Returns an iterator to the first element whose
733 //! key is not less than k or end() if that element does not exist.
734 //!
735 //! <b>Complexity</b>: Logarithmic.
736 //!
737 //! <b>Throws</b>: If the internal value_compare ordering function throws.
738 iterator lower_bound(const_reference value)
739 { return tree_.lower_bound(value); }
741 //! <b>Requires</b>: comp must imply the same element order as
742 //! value_compare. Usually key is the part of the value_type
743 //! that is used in the ordering functor.
745 //! <b>Effects</b>: Returns an iterator to the first element whose
746 //! key according to the comparison functor is not less than k or
747 //! end() if that element does not exist.
748 //!
749 //! <b>Complexity</b>: Logarithmic.
750 //!
751 //! <b>Throws</b>: If comp ordering function throws.
752 //!
753 //! <b>Note</b>: This function is used when constructing a value_type
754 //! is expensive and the value_type can be compared with a cheaper
755 //! key type. Usually this key is part of the value_type.
756 template<class KeyType, class KeyValueCompare>
757 iterator lower_bound(const KeyType& key, KeyValueCompare comp)
758 { return tree_.lower_bound(key, comp); }
760 //! <b>Effects</b>: Returns a const iterator to the first element whose
761 //! key is not less than k or end() if that element does not exist.
762 //!
763 //! <b>Complexity</b>: Logarithmic.
764 //!
765 //! <b>Throws</b>: If the internal value_compare ordering function throws.
766 const_iterator lower_bound(const_reference value) const
767 { return tree_.lower_bound(value); }
769 //! <b>Requires</b>: comp must imply the same element order as
770 //! value_compare. Usually key is the part of the value_type
771 //! that is used in the ordering functor.
773 //! <b>Effects</b>: Returns a const_iterator to the first element whose
774 //! key according to the comparison functor is not less than k or
775 //! end() if that element does not exist.
776 //!
777 //! <b>Complexity</b>: Logarithmic.
778 //!
779 //! <b>Throws</b>: If comp ordering function throws.
780 //!
781 //! <b>Note</b>: This function is used when constructing a value_type
782 //! is expensive and the value_type can be compared with a cheaper
783 //! key type. Usually this key is part of the value_type.
784 template<class KeyType, class KeyValueCompare>
785 const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const
786 { return tree_.lower_bound(key, comp); }
788 //! <b>Effects</b>: Returns an iterator to the first element whose
789 //! key is greater than k or end() if that element does not exist.
790 //!
791 //! <b>Complexity</b>: Logarithmic.
792 //!
793 //! <b>Throws</b>: If the internal value_compare ordering function throws.
794 iterator upper_bound(const_reference value)
795 { return tree_.upper_bound(value); }
797 //! <b>Requires</b>: comp must imply the same element order as
798 //! value_compare. Usually key is the part of the value_type
799 //! that is used in the ordering functor.
801 //! <b>Effects</b>: Returns an iterator to the first element whose
802 //! key according to the comparison functor is greater than key or
803 //! end() if that element does not exist.
804 //!
805 //! <b>Complexity</b>: Logarithmic.
806 //!
807 //! <b>Throws</b>: If comp ordering function throws.
809 //! <b>Note</b>: This function is used when constructing a value_type
810 //! is expensive and the value_type can be compared with a cheaper
811 //! key type. Usually this key is part of the value_type.
812 template<class KeyType, class KeyValueCompare>
813 iterator upper_bound(const KeyType& key, KeyValueCompare comp)
814 { return tree_.upper_bound(key, comp); }
816 //! <b>Effects</b>: Returns an iterator to the first element whose
817 //! key is greater than k or end() if that element does not exist.
818 //!
819 //! <b>Complexity</b>: Logarithmic.
820 //!
821 //! <b>Throws</b>: If the internal value_compare ordering function throws.
822 const_iterator upper_bound(const_reference value) const
823 { return tree_.upper_bound(value); }
825 //! <b>Requires</b>: comp must imply the same element order as
826 //! value_compare. Usually key is the part of the value_type
827 //! that is used in the ordering functor.
829 //! <b>Effects</b>: Returns a const_iterator to the first element whose
830 //! key according to the comparison functor is greater than key or
831 //! end() if that element does not exist.
832 //!
833 //! <b>Complexity</b>: Logarithmic.
834 //!
835 //! <b>Throws</b>: If comp ordering function throws.
837 //! <b>Note</b>: This function is used when constructing a value_type
838 //! is expensive and the value_type can be compared with a cheaper
839 //! key type. Usually this key is part of the value_type.
840 template<class KeyType, class KeyValueCompare>
841 const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const
842 { return tree_.upper_bound(key, comp); }
844 //! <b>Effects</b>: Finds an iterator to the first element whose value is
845 //! "value" or end() if that element does not exist.
847 //! <b>Complexity</b>: Logarithmic.
848 //!
849 //! <b>Throws</b>: If the internal value_compare ordering function throws.
850 iterator find(const_reference value)
851 { return tree_.find(value); }
853 //! <b>Requires</b>: comp must imply the same element order as
854 //! value_compare. Usually key is the part of the value_type
855 //! that is used in the ordering functor.
857 //! <b>Effects</b>: Finds an iterator to the first element whose key is
858 //! "key" according to the comparison functor or end() if that element
859 //! does not exist.
861 //! <b>Complexity</b>: Logarithmic.
862 //!
863 //! <b>Throws</b>: If comp ordering function throws.
865 //! <b>Note</b>: This function is used when constructing a value_type
866 //! is expensive and the value_type can be compared with a cheaper
867 //! key type. Usually this key is part of the value_type.
868 template<class KeyType, class KeyValueCompare>
869 iterator find(const KeyType& key, KeyValueCompare comp)
870 { return tree_.find(key, comp); }
872 //! <b>Effects</b>: Finds a const_iterator to the first element whose value is
873 //! "value" or end() if that element does not exist.
874 //!
875 //! <b>Complexity</b>: Logarithmic.
876 //!
877 //! <b>Throws</b>: If the internal value_compare ordering function throws.
878 const_iterator find(const_reference value) const
879 { return tree_.find(value); }
881 //! <b>Requires</b>: comp must imply the same element order as
882 //! value_compare. Usually key is the part of the value_type
883 //! that is used in the ordering functor.
885 //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
886 //! "key" according to the comparison functor or end() if that element
887 //! does not exist.
888 //!
889 //! <b>Complexity</b>: Logarithmic.
890 //!
891 //! <b>Throws</b>: If comp ordering function throws.
893 //! <b>Note</b>: This function is used when constructing a value_type
894 //! is expensive and the value_type can be compared with a cheaper
895 //! key type. Usually this key is part of the value_type.
896 template<class KeyType, class KeyValueCompare>
897 const_iterator find(const KeyType& key, KeyValueCompare comp) const
898 { return tree_.find(key, comp); }
900 //! <b>Effects</b>: Finds a range containing all elements whose key is k or
901 //! an empty range that indicates the position where those elements would be
902 //! if they there is no elements with key k.
903 //!
904 //! <b>Complexity</b>: Logarithmic.
905 //!
906 //! <b>Throws</b>: If the internal value_compare ordering function throws.
907 std::pair<iterator,iterator> equal_range(const_reference value)
908 { return tree_.equal_range(value); }
910 //! <b>Requires</b>: comp must imply the same element order as
911 //! value_compare. Usually key is the part of the value_type
912 //! that is used in the ordering functor.
914 //! <b>Effects</b>: Finds a range containing all elements whose key is k
915 //! according to the comparison functor or an empty range
916 //! that indicates the position where those elements would be
917 //! if they there is no elements with key k.
918 //!
919 //! <b>Complexity</b>: Logarithmic.
920 //!
921 //! <b>Throws</b>: If comp ordering function throws.
923 //! <b>Note</b>: This function is used when constructing a value_type
924 //! is expensive and the value_type can be compared with a cheaper
925 //! key type. Usually this key is part of the value_type.
926 template<class KeyType, class KeyValueCompare>
927 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp)
928 { return tree_.equal_range(key, comp); }
930 //! <b>Effects</b>: Finds a range containing all elements whose key is k or
931 //! an empty range that indicates the position where those elements would be
932 //! if they there is no elements with key k.
933 //!
934 //! <b>Complexity</b>: Logarithmic.
935 //!
936 //! <b>Throws</b>: If the internal value_compare ordering function throws.
937 std::pair<const_iterator, const_iterator>
938 equal_range(const_reference value) const
939 { return tree_.equal_range(value); }
941 //! <b>Requires</b>: comp must imply the same element order as
942 //! value_compare. Usually key is the part of the value_type
943 //! that is used in the ordering functor.
945 //! <b>Effects</b>: Finds a range containing all elements whose key is k
946 //! according to the comparison functor or an empty range
947 //! that indicates the position where those elements would be
948 //! if they there is no elements with key k.
949 //!
950 //! <b>Complexity</b>: Logarithmic.
951 //!
952 //! <b>Throws</b>: If comp ordering function throws.
954 //! <b>Note</b>: This function is used when constructing a value_type
955 //! is expensive and the value_type can be compared with a cheaper
956 //! key type. Usually this key is part of the value_type.
957 template<class KeyType, class KeyValueCompare>
958 std::pair<const_iterator, const_iterator>
959 equal_range(const KeyType& key, KeyValueCompare comp) const
960 { return tree_.equal_range(key, comp); }
962 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of
963 //! appropriate type. Otherwise the behavior is undefined.
964 //!
965 //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_set
966 //! that points to the value
967 //!
968 //! <b>Complexity</b>: Constant.
969 //!
970 //! <b>Throws</b>: Nothing.
971 //!
972 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
973 //! is stateless.
974 static iterator s_iterator_to(reference value)
975 { return tree_type::s_iterator_to(value); }
977 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of
978 //! appropriate type. Otherwise the behavior is undefined.
979 //!
980 //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
981 //! treap_set that points to the value
982 //!
983 //! <b>Complexity</b>: Constant.
984 //!
985 //! <b>Throws</b>: Nothing.
986 //!
987 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
988 //! is stateless.
989 static const_iterator s_iterator_to(const_reference value)
990 { return tree_type::s_iterator_to(value); }
992 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of
993 //! appropriate type. Otherwise the behavior is undefined.
994 //!
995 //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_set
996 //! that points to the value
997 //!
998 //! <b>Complexity</b>: Constant.
999 //!
1000 //! <b>Throws</b>: Nothing.
1001 iterator iterator_to(reference value)
1002 { return tree_.iterator_to(value); }
1004 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_set of
1005 //! appropriate type. Otherwise the behavior is undefined.
1006 //!
1007 //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
1008 //! treap_set that points to the value
1009 //!
1010 //! <b>Complexity</b>: Constant.
1011 //!
1012 //! <b>Throws</b>: Nothing.
1013 const_iterator iterator_to(const_reference value) const
1014 { return tree_.iterator_to(value); }
1016 //! <b>Requires</b>: value shall not be in a treap_set/treap_multiset.
1017 //!
1018 //! <b>Effects</b>: init_node puts the hook of a value in a well-known default
1019 //! state.
1020 //!
1021 //! <b>Throws</b>: Nothing.
1022 //!
1023 //! <b>Complexity</b>: Constant time.
1024 //!
1025 //! <b>Note</b>: This function puts the hook in the well-known default state
1026 //! used by auto_unlink and safe hooks.
1027 static void init_node(reference value)
1028 { tree_type::init_node(value); }
1030 //! <b>Effects</b>: Unlinks the leftmost node from the tree.
1031 //!
1032 //! <b>Complexity</b>: Average complexity is constant time.
1033 //!
1034 //! <b>Throws</b>: Nothing.
1035 //!
1036 //! <b>Notes</b>: This function breaks the tree and the tree can
1037 //! only be used for more unlink_leftmost_without_rebalance calls.
1038 //! This function is normally used to achieve a step by step
1039 //! controlled destruction of the tree.
1040 pointer unlink_leftmost_without_rebalance()
1041 { return tree_.unlink_leftmost_without_rebalance(); }
1043 //! <b>Requires</b>: replace_this must be a valid iterator of *this
1044 //! and with_this must not be inserted in any tree.
1045 //!
1046 //! <b>Effects</b>: Replaces replace_this in its position in the
1047 //! tree with with_this. The tree does not need to be rebalanced.
1048 //!
1049 //! <b>Complexity</b>: Constant.
1050 //!
1051 //! <b>Throws</b>: Nothing.
1052 //!
1053 //! <b>Note</b>: This function will break container ordering invariants if
1054 //! with_this is not equivalent to *replace_this according to the
1055 //! ordering rules. This function is faster than erasing and inserting
1056 //! the node, since no rebalancing or comparison is needed.
1057 void replace_node(iterator replace_this, reference with_this)
1058 { tree_.replace_node(replace_this, with_this); }
1060 //! <b>Effects</b>: Rebalances the tree.
1061 //!
1062 //! <b>Throws</b>: Nothing.
1063 //!
1064 //! <b>Complexity</b>: Linear.
1065 void rebalance()
1066 { tree_.rebalance(); }
1068 //! <b>Requires</b>: old_root is a node of a tree.
1069 //!
1070 //! <b>Effects</b>: Rebalances the subtree rooted at old_root.
1072 //! <b>Returns</b>: The new root of the subtree.
1074 //! <b>Throws</b>: Nothing.
1075 //!
1076 //! <b>Complexity</b>: Linear to the elements in the subtree.
1077 iterator rebalance_subtree(iterator root)
1078 { return tree_.rebalance_subtree(root); }
1080 //! <b>Returns</b>: The balance factor (alpha) used in this tree
1082 //! <b>Throws</b>: Nothing.
1083 //!
1084 //! <b>Complexity</b>: Constant.
1085 float balance_factor() const
1086 { return tree_.balance_factor(); }
1088 //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0
1089 //!
1090 //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances
1091 //! the tree if the new balance factor is stricter (less) than the old factor.
1093 //! <b>Throws</b>: Nothing.
1094 //!
1095 //! <b>Complexity</b>: Linear to the elements in the subtree.
1096 void balance_factor(float new_alpha)
1097 { tree_.balance_factor(new_alpha); }
1099 /// @cond
1100 friend bool operator==(const treap_set_impl &x, const treap_set_impl &y)
1101 { return x.tree_ == y.tree_; }
1103 friend bool operator<(const treap_set_impl &x, const treap_set_impl &y)
1104 { return x.tree_ < y.tree_; }
1105 /// @endcond
1108 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1109 template<class T, class ...Options>
1110 #else
1111 template<class Config>
1112 #endif
1113 inline bool operator!=
1114 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1115 (const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y)
1116 #else
1117 (const treap_set_impl<Config> &x, const treap_set_impl<Config> &y)
1118 #endif
1119 { return !(x == y); }
1121 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1122 template<class T, class ...Options>
1123 #else
1124 template<class Config>
1125 #endif
1126 inline bool operator>
1127 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1128 (const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y)
1129 #else
1130 (const treap_set_impl<Config> &x, const treap_set_impl<Config> &y)
1131 #endif
1132 { return y < x; }
1134 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1135 template<class T, class ...Options>
1136 #else
1137 template<class Config>
1138 #endif
1139 inline bool operator<=
1140 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1141 (const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y)
1142 #else
1143 (const treap_set_impl<Config> &x, const treap_set_impl<Config> &y)
1144 #endif
1145 { return !(y < x); }
1147 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1148 template<class T, class ...Options>
1149 #else
1150 template<class Config>
1151 #endif
1152 inline bool operator>=
1153 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1154 (const treap_set_impl<T, Options...> &x, const treap_set_impl<T, Options...> &y)
1155 #else
1156 (const treap_set_impl<Config> &x, const treap_set_impl<Config> &y)
1157 #endif
1158 { return !(x < y); }
1160 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1161 template<class T, class ...Options>
1162 #else
1163 template<class Config>
1164 #endif
1165 inline void swap
1166 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1167 (treap_set_impl<T, Options...> &x, treap_set_impl<T, Options...> &y)
1168 #else
1169 (treap_set_impl<Config> &x, treap_set_impl<Config> &y)
1170 #endif
1171 { x.swap(y); }
1173 //! Helper metafunction to define a \c treap_set that yields to the same type when the
1174 //! same options (either explicitly or implicitly) are used.
1175 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1176 template<class T, class ...Options>
1177 #else
1178 template<class T, class O1 = none, class O2 = none
1179 , class O3 = none, class O4 = none>
1180 #endif
1181 struct make_treap_set
1183 /// @cond
1184 typedef treap_set_impl
1185 < typename make_treap_opt<T,
1186 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1187 O1, O2, O3, O4
1188 #else
1189 Options...
1190 #endif
1191 >::type
1192 > implementation_defined;
1193 /// @endcond
1194 typedef implementation_defined type;
1197 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
1199 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1200 template<class T, class O1, class O2, class O3, class O4>
1201 #else
1202 template<class T, class ...Options>
1203 #endif
1204 class treap_set
1205 : public make_treap_set<T,
1206 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1207 O1, O2, O3, O4
1208 #else
1209 Options...
1210 #endif
1211 >::type
1213 typedef typename make_treap_set
1214 <T,
1215 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
1216 O1, O2, O3, O4
1217 #else
1218 Options...
1219 #endif
1220 >::type Base;
1222 public:
1223 typedef typename Base::value_compare value_compare;
1224 typedef typename Base::priority_compare priority_compare;
1225 typedef typename Base::value_traits value_traits;
1226 typedef typename Base::iterator iterator;
1227 typedef typename Base::const_iterator const_iterator;
1229 //Assert if passed value traits are compatible with the type
1230 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
1232 treap_set( const value_compare &cmp = value_compare()
1233 , const priority_compare &pcmp = priority_compare()
1234 , const value_traits &v_traits = value_traits())
1235 : Base(cmp, pcmp, v_traits)
1238 template<class Iterator>
1239 treap_set( Iterator b, Iterator e
1240 , const value_compare &cmp = value_compare()
1241 , const priority_compare &pcmp = priority_compare()
1242 , const value_traits &v_traits = value_traits())
1243 : Base(b, e, cmp, pcmp, v_traits)
1246 static treap_set &container_from_end_iterator(iterator end_iterator)
1247 { return static_cast<treap_set &>(Base::container_from_end_iterator(end_iterator)); }
1249 static const treap_set &container_from_end_iterator(const_iterator end_iterator)
1250 { return static_cast<const treap_set &>(Base::container_from_end_iterator(end_iterator)); }
1252 static treap_set &container_from_iterator(iterator it)
1253 { return static_cast<treap_set &>(Base::container_from_iterator(it)); }
1255 static const treap_set &container_from_iterator(const_iterator it)
1256 { return static_cast<const treap_set &>(Base::container_from_iterator(it)); }
1259 #endif
1261 //! The class template treap_multiset is an intrusive container, that mimics most of
1262 //! the interface of std::treap_multiset as described in the C++ standard.
1263 //!
1264 //! The template parameter \c T is the type to be managed by the container.
1265 //! The user can specify additional options and if no options are provided
1266 //! default options are used.
1268 //! The container supports the following options:
1269 //! \c base_hook<>/member_hook<>/value_traits<>,
1270 //! \c constant_time_size<>, \c size_type<>,
1271 //! \c compare<> and \c priority_compare<>
1272 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1273 template<class T, class ...Options>
1274 #else
1275 template<class Config>
1276 #endif
1277 class treap_multiset_impl
1279 /// @cond
1280 typedef treap_impl<Config> tree_type;
1282 //Non-copyable and non-assignable
1283 treap_multiset_impl (const treap_multiset_impl&);
1284 treap_multiset_impl &operator =(const treap_multiset_impl&);
1285 typedef tree_type implementation_defined;
1286 /// @endcond
1288 public:
1289 typedef typename implementation_defined::value_type value_type;
1290 typedef typename implementation_defined::value_traits value_traits;
1291 typedef typename implementation_defined::pointer pointer;
1292 typedef typename implementation_defined::const_pointer const_pointer;
1293 typedef typename implementation_defined::reference reference;
1294 typedef typename implementation_defined::const_reference const_reference;
1295 typedef typename implementation_defined::difference_type difference_type;
1296 typedef typename implementation_defined::size_type size_type;
1297 typedef typename implementation_defined::value_compare value_compare;
1298 typedef typename implementation_defined::priority_compare priority_compare;
1299 typedef typename implementation_defined::key_compare key_compare;
1300 typedef typename implementation_defined::iterator iterator;
1301 typedef typename implementation_defined::const_iterator const_iterator;
1302 typedef typename implementation_defined::reverse_iterator reverse_iterator;
1303 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
1304 typedef typename implementation_defined::insert_commit_data insert_commit_data;
1305 typedef typename implementation_defined::node_traits node_traits;
1306 typedef typename implementation_defined::node node;
1307 typedef typename implementation_defined::node_ptr node_ptr;
1308 typedef typename implementation_defined::const_node_ptr const_node_ptr;
1309 typedef typename implementation_defined::node_algorithms node_algorithms;
1311 /// @cond
1312 private:
1313 tree_type tree_;
1314 /// @endcond
1316 public:
1317 //! <b>Effects</b>: Constructs an empty treap_multiset.
1318 //!
1319 //! <b>Complexity</b>: Constant.
1320 //!
1321 //! <b>Throws</b>: If value_traits::node_traits::node
1322 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
1323 //! or the copy constructor of the value_compare/priority_compare objects throw.
1324 treap_multiset_impl( const value_compare &cmp = value_compare()
1325 , const priority_compare &pcmp = priority_compare()
1326 , const value_traits &v_traits = value_traits())
1327 : tree_(cmp, pcmp, v_traits)
1330 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
1331 //! cmp must be a comparison function that induces a strict weak ordering.
1332 //!
1333 //! <b>Effects</b>: Constructs an empty treap_multiset and inserts elements from
1334 //! [b, e).
1335 //!
1336 //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using
1337 //! comp and otherwise N * log N, where N is the distance between first and last
1338 //!
1339 //! <b>Throws</b>: If value_traits::node_traits::node
1340 //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
1341 //! or the copy constructor/operator() of the value_compare/priority_compare objects throw.
1342 template<class Iterator>
1343 treap_multiset_impl( Iterator b, Iterator e
1344 , const value_compare &cmp = value_compare()
1345 , const priority_compare &pcmp = priority_compare()
1346 , const value_traits &v_traits = value_traits())
1347 : tree_(false, b, e, cmp, pcmp, v_traits)
1350 //! <b>Effects</b>: Detaches all elements from this. The objects in the treap_multiset
1351 //! are not deleted (i.e. no destructors are called).
1352 //!
1353 //! <b>Complexity</b>: Linear to the number of elements on the container.
1354 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
1355 //!
1356 //! <b>Throws</b>: Nothing.
1357 ~treap_multiset_impl()
1360 //! <b>Effects</b>: Returns an iterator pointing to the beginning of the treap_multiset.
1361 //!
1362 //! <b>Complexity</b>: Constant.
1363 //!
1364 //! <b>Throws</b>: Nothing.
1365 iterator begin()
1366 { return tree_.begin(); }
1368 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_multiset.
1369 //!
1370 //! <b>Complexity</b>: Constant.
1371 //!
1372 //! <b>Throws</b>: Nothing.
1373 const_iterator begin() const
1374 { return tree_.begin(); }
1376 //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the treap_multiset.
1377 //!
1378 //! <b>Complexity</b>: Constant.
1379 //!
1380 //! <b>Throws</b>: Nothing.
1381 const_iterator cbegin() const
1382 { return tree_.cbegin(); }
1384 //! <b>Effects</b>: Returns an iterator pointing to the end of the treap_multiset.
1385 //!
1386 //! <b>Complexity</b>: Constant.
1387 //!
1388 //! <b>Throws</b>: Nothing.
1389 iterator end()
1390 { return tree_.end(); }
1392 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_multiset.
1393 //!
1394 //! <b>Complexity</b>: Constant.
1395 //!
1396 //! <b>Throws</b>: Nothing.
1397 const_iterator end() const
1398 { return tree_.end(); }
1400 //! <b>Effects</b>: Returns a const_iterator pointing to the end of the treap_multiset.
1401 //!
1402 //! <b>Complexity</b>: Constant.
1403 //!
1404 //! <b>Throws</b>: Nothing.
1405 const_iterator cend() const
1406 { return tree_.cend(); }
1408 //! <b>Effects</b>: Returns an iterator pointing to the highest priority object of the tree.
1409 //!
1410 //! <b>Complexity</b>: Constant.
1411 //!
1412 //! <b>Throws</b>: Nothing.
1413 iterator top()
1414 { return tree_.top(); }
1416 //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree..
1417 //!
1418 //! <b>Complexity</b>: Constant.
1419 //!
1420 //! <b>Throws</b>: Nothing.
1421 const_iterator top() const
1422 { return this->ctop(); }
1424 //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the tree..
1425 //!
1426 //! <b>Complexity</b>: Constant.
1427 //!
1428 //! <b>Throws</b>: Nothing.
1429 const_iterator ctop() const
1430 { return tree_.ctop(); }
1432 //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the
1433 //! reversed treap_multiset.
1434 //!
1435 //! <b>Complexity</b>: Constant.
1436 //!
1437 //! <b>Throws</b>: Nothing.
1438 reverse_iterator rbegin()
1439 { return tree_.rbegin(); }
1441 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
1442 //! of the reversed treap_multiset.
1443 //!
1444 //! <b>Complexity</b>: Constant.
1445 //!
1446 //! <b>Throws</b>: Nothing.
1447 const_reverse_iterator rbegin() const
1448 { return tree_.rbegin(); }
1450 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
1451 //! of the reversed treap_multiset.
1452 //!
1453 //! <b>Complexity</b>: Constant.
1454 //!
1455 //! <b>Throws</b>: Nothing.
1456 const_reverse_iterator crbegin() const
1457 { return tree_.crbegin(); }
1459 //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
1460 //! of the reversed treap_multiset.
1461 //!
1462 //! <b>Complexity</b>: Constant.
1463 //!
1464 //! <b>Throws</b>: Nothing.
1465 reverse_iterator rend()
1466 { return tree_.rend(); }
1468 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
1469 //! of the reversed treap_multiset.
1470 //!
1471 //! <b>Complexity</b>: Constant.
1472 //!
1473 //! <b>Throws</b>: Nothing.
1474 const_reverse_iterator rend() const
1475 { return tree_.rend(); }
1477 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
1478 //! of the reversed treap_multiset.
1479 //!
1480 //! <b>Complexity</b>: Constant.
1481 //!
1482 //! <b>Throws</b>: Nothing.
1483 const_reverse_iterator crend() const
1484 { return tree_.crend(); }
1486 //! <b>Effects</b>: Returns a reverse_iterator pointing to the highest priority object of the
1487 //! reversed tree.
1488 //!
1489 //! <b>Complexity</b>: Constant.
1490 //!
1491 //! <b>Throws</b>: Nothing.
1492 reverse_iterator rtop()
1493 { return tree_.rtop(); }
1495 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority objec
1496 //! of the reversed tree.
1497 //!
1498 //! <b>Complexity</b>: Constant.
1499 //!
1500 //! <b>Throws</b>: Nothing.
1501 const_reverse_iterator rtop() const
1502 { return tree_.crtop(); }
1504 //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the highest priority object
1505 //! of the reversed tree.
1506 //!
1507 //! <b>Complexity</b>: Constant.
1508 //!
1509 //! <b>Throws</b>: Nothing.
1510 const_reverse_iterator crtop() const
1511 { return tree_.crtop(); }
1513 //! <b>Precondition</b>: end_iterator must be a valid end iterator
1514 //! of treap_multiset.
1515 //!
1516 //! <b>Effects</b>: Returns a const reference to the treap_multiset associated to the end iterator
1517 //!
1518 //! <b>Throws</b>: Nothing.
1519 //!
1520 //! <b>Complexity</b>: Constant.
1521 static treap_multiset_impl &container_from_end_iterator(iterator end_iterator)
1523 return *detail::parent_from_member<treap_multiset_impl, tree_type>
1524 ( &tree_type::container_from_end_iterator(end_iterator)
1525 , &treap_multiset_impl::tree_);
1528 //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
1529 //! of treap_multiset.
1530 //!
1531 //! <b>Effects</b>: Returns a const reference to the treap_multiset associated to the end iterator
1532 //!
1533 //! <b>Throws</b>: Nothing.
1534 //!
1535 //! <b>Complexity</b>: Constant.
1536 static const treap_multiset_impl &container_from_end_iterator(const_iterator end_iterator)
1538 return *detail::parent_from_member<treap_multiset_impl, tree_type>
1539 ( &tree_type::container_from_end_iterator(end_iterator)
1540 , &treap_multiset_impl::tree_);
1543 //! <b>Precondition</b>: it must be a valid iterator of multiset.
1544 //!
1545 //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator
1546 //!
1547 //! <b>Throws</b>: Nothing.
1548 //!
1549 //! <b>Complexity</b>: Constant.
1550 static treap_multiset_impl &container_from_iterator(iterator it)
1552 return *detail::parent_from_member<treap_multiset_impl, tree_type>
1553 ( &tree_type::container_from_iterator(it)
1554 , &treap_multiset_impl::tree_);
1557 //! <b>Precondition</b>: it must be a valid const_iterator of multiset.
1558 //!
1559 //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator
1560 //!
1561 //! <b>Throws</b>: Nothing.
1562 //!
1563 //! <b>Complexity</b>: Constant.
1564 static const treap_multiset_impl &container_from_iterator(const_iterator it)
1566 return *detail::parent_from_member<treap_multiset_impl, tree_type>
1567 ( &tree_type::container_from_iterator(it)
1568 , &treap_multiset_impl::tree_);
1571 //! <b>Effects</b>: Returns the key_compare object used by the treap_multiset.
1572 //!
1573 //! <b>Complexity</b>: Constant.
1574 //!
1575 //! <b>Throws</b>: If key_compare copy-constructor throws.
1576 key_compare key_comp() const
1577 { return tree_.value_comp(); }
1579 //! <b>Effects</b>: Returns the value_compare object used by the treap_multiset.
1580 //!
1581 //! <b>Complexity</b>: Constant.
1582 //!
1583 //! <b>Throws</b>: If value_compare copy-constructor throws.
1584 value_compare value_comp() const
1585 { return tree_.value_comp(); }
1587 //! <b>Effects</b>: Returns true if the container is empty.
1588 //!
1589 //! <b>Complexity</b>: Constant.
1590 //!
1591 //! <b>Throws</b>: Nothing.
1592 bool empty() const
1593 { return tree_.empty(); }
1595 //! <b>Effects</b>: Returns the number of elements stored in the treap_multiset.
1596 //!
1597 //! <b>Complexity</b>: Linear to elements contained in *this if,
1598 //! constant-time size option is enabled. Constant-time otherwise.
1599 //!
1600 //! <b>Throws</b>: Nothing.
1601 size_type size() const
1602 { return tree_.size(); }
1604 //! <b>Effects</b>: Swaps the contents of two treap_multisets.
1605 //!
1606 //! <b>Complexity</b>: Constant.
1607 //!
1608 //! <b>Throws</b>: If the swap() call for the comparison functor
1609 //! found using ADL throws. Strong guarantee.
1610 void swap(treap_multiset_impl& other)
1611 { tree_.swap(other.tree_); }
1613 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1614 //! Cloner should yield to nodes equivalent to the original nodes.
1616 //! <b>Effects</b>: Erases all the elements from *this
1617 //! calling Disposer::operator()(pointer), clones all the
1618 //! elements from src calling Cloner::operator()(const_reference )
1619 //! and inserts them on *this. Copies the predicate from the source container.
1621 //! If cloner throws, all cloned elements are unlinked and disposed
1622 //! calling Disposer::operator()(pointer).
1623 //!
1624 //! <b>Complexity</b>: Linear to erased plus inserted elements.
1625 //!
1626 //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee.
1627 template <class Cloner, class Disposer>
1628 void clone_from(const treap_multiset_impl &src, Cloner cloner, Disposer disposer)
1629 { tree_.clone_from(src.tree_, cloner, disposer); }
1631 //! <b>Requires</b>: value must be an lvalue
1632 //!
1633 //! <b>Effects</b>: Inserts value into the treap_multiset.
1634 //!
1635 //! <b>Returns</b>: An iterator that points to the position where the new
1636 //! element was inserted.
1637 //!
1638 //! <b>Complexity</b>: Average complexity for insert element is at
1639 //! most logarithmic.
1640 //!
1641 //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
1642 //!
1643 //! <b>Note</b>: Does not affect the validity of iterators and references.
1644 //! No copy-constructors are called.
1645 iterator insert(reference value)
1646 { return tree_.insert_equal(value); }
1648 //! <b>Requires</b>: value must be an lvalue
1649 //!
1650 //! <b>Effects</b>: Inserts x into the treap_multiset, using pos as a hint to
1651 //! where it will be inserted.
1652 //!
1653 //! <b>Returns</b>: An iterator that points to the position where the new
1654 //! element was inserted.
1655 //!
1656 //! <b>Complexity</b>: Logarithmic in general, but it is amortized
1657 //! constant time if t is inserted immediately before hint.
1658 //!
1659 //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
1660 //!
1661 //! <b>Note</b>: Does not affect the validity of iterators and references.
1662 //! No copy-constructors are called.
1663 iterator insert(const_iterator hint, reference value)
1664 { return tree_.insert_equal(hint, value); }
1666 //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
1667 //! of type value_type.
1668 //!
1669 //! <b>Effects</b>: Inserts a range into the treap_multiset.
1670 //!
1671 //! <b>Returns</b>: An iterator that points to the position where the new
1672 //! element was inserted.
1673 //!
1674 //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the
1675 //! size of the range. However, it is linear in N if the range is already sorted
1676 //! by value_comp().
1677 //!
1678 //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
1679 //!
1680 //! <b>Note</b>: Does not affect the validity of iterators and references.
1681 //! No copy-constructors are called.
1682 template<class Iterator>
1683 void insert(Iterator b, Iterator e)
1684 { tree_.insert_equal(b, e); }
1686 //! <b>Effects</b>: Erases the element pointed to by pos.
1687 //!
1688 //! <b>Complexity</b>: Average complexity is constant time.
1689 //!
1690 //! <b>Returns</b>: An iterator to the element after the erased element.
1692 //! <b>Throws</b>: Nothing.
1693 //!
1694 //! <b>Note</b>: Invalidates the iterators (but not the references)
1695 //! to the erased elements. No destructors are called.
1696 iterator erase(const_iterator i)
1697 { return tree_.erase(i); }
1699 //! <b>Effects</b>: Erases the range pointed to by b end e.
1701 //! <b>Returns</b>: An iterator to the element after the erased elements.
1702 //!
1703 //! <b>Complexity</b>: Average complexity for erase range is at most
1704 //! O(log(size() + N)), where N is the number of elements in the range.
1705 //!
1706 //! <b>Throws</b>: Nothing.
1707 //!
1708 //! <b>Note</b>: Invalidates the iterators (but not the references)
1709 //! to the erased elements. No destructors are called.
1710 iterator erase(const_iterator b, const_iterator e)
1711 { return tree_.erase(b, e); }
1713 //! <b>Effects</b>: Erases all the elements with the given value.
1714 //!
1715 //! <b>Returns</b>: The number of erased elements.
1716 //!
1717 //! <b>Complexity</b>: O(log(size() + this->count(value)).
1718 //!
1719 //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
1720 //!
1721 //! <b>Note</b>: Invalidates the iterators (but not the references)
1722 //! to the erased elements. No destructors are called.
1723 size_type erase(const_reference value)
1724 { return tree_.erase(value); }
1726 //! <b>Effects</b>: Erases all the elements that compare equal with
1727 //! the given key and the given comparison functor.
1728 //!
1729 //! <b>Returns</b>: The number of erased elements.
1730 //!
1731 //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
1732 //!
1733 //! <b>Throws</b>: If comp ordering function throws. Basic guarantee.
1734 //!
1735 //! <b>Note</b>: Invalidates the iterators (but not the references)
1736 //! to the erased elements. No destructors are called.
1737 template<class KeyType, class KeyValueCompare>
1738 size_type erase(const KeyType& key, KeyValueCompare comp
1739 /// @cond
1740 , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
1741 /// @endcond
1743 { return tree_.erase(key, comp); }
1745 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1747 //! <b>Returns</b>: An iterator to the element after the erased element.
1749 //! <b>Effects</b>: Erases the element pointed to by pos.
1750 //! Disposer::operator()(pointer) is called for the removed element.
1751 //!
1752 //! <b>Complexity</b>: Average complexity for erase element is constant time.
1753 //!
1754 //! <b>Throws</b>: Nothing.
1755 //!
1756 //! <b>Note</b>: Invalidates the iterators
1757 //! to the erased elements.
1758 template<class Disposer>
1759 iterator erase_and_dispose(const_iterator i, Disposer disposer)
1760 { return tree_.erase_and_dispose(i, disposer); }
1762 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
1763 template<class Disposer>
1764 iterator erase_and_dispose(iterator i, Disposer disposer)
1765 { return this->erase_and_dispose(const_iterator(i), disposer); }
1766 #endif
1768 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1770 //! <b>Returns</b>: An iterator to the element after the erased elements.
1772 //! <b>Effects</b>: Erases the range pointed to by b end e.
1773 //! Disposer::operator()(pointer) is called for the removed elements.
1774 //!
1775 //! <b>Complexity</b>: Average complexity for erase range is at most
1776 //! O(log(size() + N)), where N is the number of elements in the range.
1777 //!
1778 //! <b>Throws</b>: Nothing.
1779 //!
1780 //! <b>Note</b>: Invalidates the iterators
1781 //! to the erased elements.
1782 template<class Disposer>
1783 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
1784 { return tree_.erase_and_dispose(b, e, disposer); }
1786 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1788 //! <b>Effects</b>: Erases all the elements with the given value.
1789 //! Disposer::operator()(pointer) is called for the removed elements.
1790 //!
1791 //! <b>Returns</b>: The number of erased elements.
1792 //!
1793 //! <b>Complexity</b>: O(log(size() + this->count(value)).
1794 //!
1795 //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
1796 //!
1797 //! <b>Note</b>: Invalidates the iterators (but not the references)
1798 //! to the erased elements. No destructors are called.
1799 template<class Disposer>
1800 size_type erase_and_dispose(const_reference value, Disposer disposer)
1801 { return tree_.erase_and_dispose(value, disposer); }
1803 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1805 //! <b>Effects</b>: Erases all the elements with the given key.
1806 //! according to the comparison functor "comp".
1807 //! Disposer::operator()(pointer) is called for the removed elements.
1809 //! <b>Returns</b>: The number of erased elements.
1810 //!
1811 //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
1812 //!
1813 //! <b>Throws</b>: If comp ordering function throws. Basic guarantee.
1814 //!
1815 //! <b>Note</b>: Invalidates the iterators
1816 //! to the erased elements.
1817 template<class KeyType, class KeyValueCompare, class Disposer>
1818 size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer
1819 /// @cond
1820 , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
1821 /// @endcond
1823 { return tree_.erase_and_dispose(key, comp, disposer); }
1825 //! <b>Effects</b>: Erases all the elements of the container.
1826 //!
1827 //! <b>Complexity</b>: Linear to the number of elements on the container.
1828 //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
1829 //!
1830 //! <b>Throws</b>: Nothing.
1831 //!
1832 //! <b>Note</b>: Invalidates the iterators (but not the references)
1833 //! to the erased elements. No destructors are called.
1834 void clear()
1835 { return tree_.clear(); }
1837 //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
1838 //!
1839 //! <b>Effects</b>: Erases all the elements of the container.
1840 //!
1841 //! <b>Complexity</b>: Linear to the number of elements on the container.
1842 //! Disposer::operator()(pointer) is called for the removed elements.
1843 //!
1844 //! <b>Throws</b>: Nothing.
1845 //!
1846 //! <b>Note</b>: Invalidates the iterators (but not the references)
1847 //! to the erased elements. No destructors are called.
1848 template<class Disposer>
1849 void clear_and_dispose(Disposer disposer)
1850 { return tree_.clear_and_dispose(disposer); }
1852 //! <b>Effects</b>: Returns the number of contained elements with the given key
1853 //!
1854 //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
1855 //! to number of objects with the given key.
1856 //!
1857 //! <b>Throws</b>: If the internal value_compare ordering function throws.
1858 size_type count(const_reference value) const
1859 { return tree_.count(value); }
1861 //! <b>Effects</b>: Returns the number of contained elements with the same key
1862 //! compared with the given comparison functor.
1863 //!
1864 //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
1865 //! to number of objects with the given key.
1866 //!
1867 //! <b>Throws</b>: If comp ordering function throws.
1868 template<class KeyType, class KeyValueCompare>
1869 size_type count(const KeyType& key, KeyValueCompare comp) const
1870 { return tree_.count(key, comp); }
1872 //! <b>Effects</b>: Returns an iterator to the first element whose
1873 //! key is not less than k or end() if that element does not exist.
1874 //!
1875 //! <b>Complexity</b>: Logarithmic.
1876 //!
1877 //! <b>Throws</b>: If the internal value_compare ordering function throws.
1878 iterator lower_bound(const_reference value)
1879 { return tree_.lower_bound(value); }
1881 //! <b>Requires</b>: comp must imply the same element order as
1882 //! value_compare. Usually key is the part of the value_type
1883 //! that is used in the ordering functor.
1885 //! <b>Effects</b>: Returns an iterator to the first element whose
1886 //! key according to the comparison functor is not less than k or
1887 //! end() if that element does not exist.
1888 //!
1889 //! <b>Complexity</b>: Logarithmic.
1890 //!
1891 //! <b>Throws</b>: If comp ordering function throws.
1892 //!
1893 //! <b>Note</b>: This function is used when constructing a value_type
1894 //! is expensive and the value_type can be compared with a cheaper
1895 //! key type. Usually this key is part of the value_type.
1896 template<class KeyType, class KeyValueCompare>
1897 iterator lower_bound(const KeyType& key, KeyValueCompare comp)
1898 { return tree_.lower_bound(key, comp); }
1900 //! <b>Effects</b>: Returns a const iterator to the first element whose
1901 //! key is not less than k or end() if that element does not exist.
1902 //!
1903 //! <b>Complexity</b>: Logarithmic.
1904 //!
1905 //! <b>Throws</b>: If the internal value_compare ordering function throws.
1906 const_iterator lower_bound(const_reference value) const
1907 { return tree_.lower_bound(value); }
1909 //! <b>Requires</b>: comp must imply the same element order as
1910 //! value_compare. Usually key is the part of the value_type
1911 //! that is used in the ordering functor.
1913 //! <b>Effects</b>: Returns a const_iterator to the first element whose
1914 //! key according to the comparison functor is not less than k or
1915 //! end() if that element does not exist.
1916 //!
1917 //! <b>Complexity</b>: Logarithmic.
1918 //!
1919 //! <b>Throws</b>: If comp ordering function throws.
1920 //!
1921 //! <b>Note</b>: This function is used when constructing a value_type
1922 //! is expensive and the value_type can be compared with a cheaper
1923 //! key type. Usually this key is part of the value_type.
1924 template<class KeyType, class KeyValueCompare>
1925 const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const
1926 { return tree_.lower_bound(key, comp); }
1928 //! <b>Effects</b>: Returns an iterator to the first element whose
1929 //! key is greater than k or end() if that element does not exist.
1930 //!
1931 //! <b>Complexity</b>: Logarithmic.
1932 //!
1933 //! <b>Throws</b>: If the internal value_compare ordering function throws.
1934 iterator upper_bound(const_reference value)
1935 { return tree_.upper_bound(value); }
1937 //! <b>Requires</b>: comp must imply the same element order as
1938 //! value_compare. Usually key is the part of the value_type
1939 //! that is used in the ordering functor.
1941 //! <b>Effects</b>: Returns an iterator to the first element whose
1942 //! key according to the comparison functor is greater than key or
1943 //! end() if that element does not exist.
1944 //!
1945 //! <b>Complexity</b>: Logarithmic.
1946 //!
1947 //! <b>Throws</b>: If comp ordering function throws.
1949 //! <b>Note</b>: This function is used when constructing a value_type
1950 //! is expensive and the value_type can be compared with a cheaper
1951 //! key type. Usually this key is part of the value_type.
1952 template<class KeyType, class KeyValueCompare>
1953 iterator upper_bound(const KeyType& key, KeyValueCompare comp)
1954 { return tree_.upper_bound(key, comp); }
1956 //! <b>Effects</b>: Returns an iterator to the first element whose
1957 //! key is greater than k or end() if that element does not exist.
1958 //!
1959 //! <b>Complexity</b>: Logarithmic.
1960 //!
1961 //! <b>Throws</b>: If the internal value_compare ordering function throws.
1962 const_iterator upper_bound(const_reference value) const
1963 { return tree_.upper_bound(value); }
1965 //! <b>Requires</b>: comp must imply the same element order as
1966 //! value_compare. Usually key is the part of the value_type
1967 //! that is used in the ordering functor.
1969 //! <b>Effects</b>: Returns a const_iterator to the first element whose
1970 //! key according to the comparison functor is greater than key or
1971 //! end() if that element does not exist.
1972 //!
1973 //! <b>Complexity</b>: Logarithmic.
1974 //!
1975 //! <b>Throws</b>: If comp ordering function throws.
1977 //! <b>Note</b>: This function is used when constructing a value_type
1978 //! is expensive and the value_type can be compared with a cheaper
1979 //! key type. Usually this key is part of the value_type.
1980 template<class KeyType, class KeyValueCompare>
1981 const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const
1982 { return tree_.upper_bound(key, comp); }
1984 //! <b>Effects</b>: Finds an iterator to the first element whose value is
1985 //! "value" or end() if that element does not exist.
1987 //! <b>Complexity</b>: Logarithmic.
1988 //!
1989 //! <b>Throws</b>: If the internal value_compare ordering function throws.
1990 iterator find(const_reference value)
1991 { return tree_.find(value); }
1993 //! <b>Requires</b>: comp must imply the same element order as
1994 //! value_compare. Usually key is the part of the value_type
1995 //! that is used in the ordering functor.
1997 //! <b>Effects</b>: Finds an iterator to the first element whose key is
1998 //! "key" according to the comparison functor or end() if that element
1999 //! does not exist.
2001 //! <b>Complexity</b>: Logarithmic.
2002 //!
2003 //! <b>Throws</b>: If comp ordering function throws.
2005 //! <b>Note</b>: This function is used when constructing a value_type
2006 //! is expensive and the value_type can be compared with a cheaper
2007 //! key type. Usually this key is part of the value_type.
2008 template<class KeyType, class KeyValueCompare>
2009 iterator find(const KeyType& key, KeyValueCompare comp)
2010 { return tree_.find(key, comp); }
2012 //! <b>Effects</b>: Finds a const_iterator to the first element whose value is
2013 //! "value" or end() if that element does not exist.
2014 //!
2015 //! <b>Complexity</b>: Logarithmic.
2016 //!
2017 //! <b>Throws</b>: If the internal value_compare ordering function throws.
2018 const_iterator find(const_reference value) const
2019 { return tree_.find(value); }
2021 //! <b>Requires</b>: comp must imply the same element order as
2022 //! value_compare. Usually key is the part of the value_type
2023 //! that is used in the ordering functor.
2025 //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
2026 //! "key" according to the comparison functor or end() if that element
2027 //! does not exist.
2028 //!
2029 //! <b>Complexity</b>: Logarithmic.
2030 //!
2031 //! <b>Throws</b>: If comp ordering function throws.
2033 //! <b>Note</b>: This function is used when constructing a value_type
2034 //! is expensive and the value_type can be compared with a cheaper
2035 //! key type. Usually this key is part of the value_type.
2036 template<class KeyType, class KeyValueCompare>
2037 const_iterator find(const KeyType& key, KeyValueCompare comp) const
2038 { return tree_.find(key, comp); }
2040 //! <b>Effects</b>: Finds a range containing all elements whose key is k or
2041 //! an empty range that indicates the position where those elements would be
2042 //! if they there is no elements with key k.
2043 //!
2044 //! <b>Complexity</b>: Logarithmic.
2045 //!
2046 //! <b>Throws</b>: If the internal value_compare ordering function throws.
2047 std::pair<iterator,iterator> equal_range(const_reference value)
2048 { return tree_.equal_range(value); }
2050 //! <b>Requires</b>: comp must imply the same element order as
2051 //! value_compare. Usually key is the part of the value_type
2052 //! that is used in the ordering functor.
2054 //! <b>Effects</b>: Finds a range containing all elements whose key is k
2055 //! according to the comparison functor or an empty range
2056 //! that indicates the position where those elements would be
2057 //! if they there is no elements with key k.
2058 //!
2059 //! <b>Complexity</b>: Logarithmic.
2060 //!
2061 //! <b>Throws</b>: If comp ordering function throws.
2063 //! <b>Note</b>: This function is used when constructing a value_type
2064 //! is expensive and the value_type can be compared with a cheaper
2065 //! key type. Usually this key is part of the value_type.
2066 template<class KeyType, class KeyValueCompare>
2067 std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp)
2068 { return tree_.equal_range(key, comp); }
2070 //! <b>Effects</b>: Finds a range containing all elements whose key is k or
2071 //! an empty range that indicates the position where those elements would be
2072 //! if they there is no elements with key k.
2073 //!
2074 //! <b>Complexity</b>: Logarithmic.
2075 //!
2076 //! <b>Throws</b>: If the internal value_compare ordering function throws.
2077 std::pair<const_iterator, const_iterator>
2078 equal_range(const_reference value) const
2079 { return tree_.equal_range(value); }
2081 //! <b>Requires</b>: comp must imply the same element order as
2082 //! value_compare. Usually key is the part of the value_type
2083 //! that is used in the ordering functor.
2085 //! <b>Effects</b>: Finds a range containing all elements whose key is k
2086 //! according to the comparison functor or an empty range
2087 //! that indicates the position where those elements would be
2088 //! if they there is no elements with key k.
2089 //!
2090 //! <b>Complexity</b>: Logarithmic.
2091 //!
2092 //! <b>Throws</b>: If comp ordering function throws.
2094 //! <b>Note</b>: This function is used when constructing a value_type
2095 //! is expensive and the value_type can be compared with a cheaper
2096 //! key type. Usually this key is part of the value_type.
2097 template<class KeyType, class KeyValueCompare>
2098 std::pair<const_iterator, const_iterator>
2099 equal_range(const KeyType& key, KeyValueCompare comp) const
2100 { return tree_.equal_range(key, comp); }
2102 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of
2103 //! appropriate type. Otherwise the behavior is undefined.
2104 //!
2105 //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_multiset
2106 //! that points to the value
2107 //!
2108 //! <b>Complexity</b>: Constant.
2109 //!
2110 //! <b>Throws</b>: Nothing.
2111 //!
2112 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
2113 //! is stateless.
2114 static iterator s_iterator_to(reference value)
2115 { return tree_type::s_iterator_to(value); }
2117 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of
2118 //! appropriate type. Otherwise the behavior is undefined.
2119 //!
2120 //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
2121 //! treap_multiset that points to the value
2122 //!
2123 //! <b>Complexity</b>: Constant.
2124 //!
2125 //! <b>Throws</b>: Nothing.
2126 //!
2127 //! <b>Note</b>: This static function is available only if the <i>value traits</i>
2128 //! is stateless.
2129 static const_iterator s_iterator_to(const_reference value)
2130 { return tree_type::s_iterator_to(value); }
2132 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of
2133 //! appropriate type. Otherwise the behavior is undefined.
2134 //!
2135 //! <b>Effects</b>: Returns: a valid iterator i belonging to the treap_multiset
2136 //! that points to the value
2137 //!
2138 //! <b>Complexity</b>: Constant.
2139 //!
2140 //! <b>Throws</b>: Nothing.
2141 iterator iterator_to(reference value)
2142 { return tree_.iterator_to(value); }
2144 //! <b>Requires</b>: value must be an lvalue and shall be in a treap_multiset of
2145 //! appropriate type. Otherwise the behavior is undefined.
2146 //!
2147 //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
2148 //! treap_multiset that points to the value
2149 //!
2150 //! <b>Complexity</b>: Constant.
2151 //!
2152 //! <b>Throws</b>: Nothing.
2153 const_iterator iterator_to(const_reference value) const
2154 { return tree_.iterator_to(value); }
2156 //! <b>Requires</b>: value shall not be in a treap_multiset/treap_multiset.
2157 //!
2158 //! <b>Effects</b>: init_node puts the hook of a value in a well-known default
2159 //! state.
2160 //!
2161 //! <b>Throws</b>: Nothing.
2162 //!
2163 //! <b>Complexity</b>: Constant time.
2164 //!
2165 //! <b>Note</b>: This function puts the hook in the well-known default state
2166 //! used by auto_unlink and safe hooks.
2167 static void init_node(reference value)
2168 { tree_type::init_node(value); }
2170 //! <b>Effects</b>: Unlinks the leftmost node from the tree.
2171 //!
2172 //! <b>Complexity</b>: Average complexity is constant time.
2173 //!
2174 //! <b>Throws</b>: Nothing.
2175 //!
2176 //! <b>Notes</b>: This function breaks the tree and the tree can
2177 //! only be used for more unlink_leftmost_without_rebalance calls.
2178 //! This function is normally used to achieve a step by step
2179 //! controlled destruction of the tree.
2180 pointer unlink_leftmost_without_rebalance()
2181 { return tree_.unlink_leftmost_without_rebalance(); }
2183 //! <b>Requires</b>: replace_this must be a valid iterator of *this
2184 //! and with_this must not be inserted in any tree.
2185 //!
2186 //! <b>Effects</b>: Replaces replace_this in its position in the
2187 //! tree with with_this. The tree does not need to be rebalanced.
2188 //!
2189 //! <b>Complexity</b>: Constant.
2190 //!
2191 //! <b>Throws</b>: Nothing.
2192 //!
2193 //! <b>Note</b>: This function will break container ordering invariants if
2194 //! with_this is not equivalent to *replace_this according to the
2195 //! ordering rules. This function is faster than erasing and inserting
2196 //! the node, since no rebalancing or comparison is needed.
2197 void replace_node(iterator replace_this, reference with_this)
2198 { tree_.replace_node(replace_this, with_this); }
2200 //! <b>Effects</b>: Rebalances the tree.
2201 //!
2202 //! <b>Throws</b>: Nothing.
2203 //!
2204 //! <b>Complexity</b>: Linear.
2205 void rebalance()
2206 { tree_.rebalance(); }
2208 //! <b>Requires</b>: old_root is a node of a tree.
2209 //!
2210 //! <b>Effects</b>: Rebalances the subtree rooted at old_root.
2212 //! <b>Returns</b>: The new root of the subtree.
2214 //! <b>Throws</b>: Nothing.
2215 //!
2216 //! <b>Complexity</b>: Linear to the elements in the subtree.
2217 iterator rebalance_subtree(iterator root)
2218 { return tree_.rebalance_subtree(root); }
2220 //! <b>Returns</b>: The balance factor (alpha) used in this tree
2222 //! <b>Throws</b>: Nothing.
2223 //!
2224 //! <b>Complexity</b>: Constant.
2225 float balance_factor() const
2226 { return tree_.balance_factor(); }
2228 //! <b>Requires</b>: new_alpha must be a value between 0.5 and 1.0
2229 //!
2230 //! <b>Effects</b>: Establishes a new balance factor (alpha) and rebalances
2231 //! the tree if the new balance factor is stricter (less) than the old factor.
2233 //! <b>Throws</b>: Nothing.
2234 //!
2235 //! <b>Complexity</b>: Linear to the elements in the subtree.
2236 void balance_factor(float new_alpha)
2237 { tree_.balance_factor(new_alpha); }
2239 /// @cond
2240 friend bool operator==(const treap_multiset_impl &x, const treap_multiset_impl &y)
2241 { return x.tree_ == y.tree_; }
2243 friend bool operator<(const treap_multiset_impl &x, const treap_multiset_impl &y)
2244 { return x.tree_ < y.tree_; }
2245 /// @endcond
2248 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2249 template<class T, class ...Options>
2250 #else
2251 template<class Config>
2252 #endif
2253 inline bool operator!=
2254 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2255 (const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y)
2256 #else
2257 (const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y)
2258 #endif
2259 { return !(x == y); }
2261 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2262 template<class T, class ...Options>
2263 #else
2264 template<class Config>
2265 #endif
2266 inline bool operator>
2267 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2268 (const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y)
2269 #else
2270 (const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y)
2271 #endif
2272 { return y < x; }
2274 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2275 template<class T, class ...Options>
2276 #else
2277 template<class Config>
2278 #endif
2279 inline bool operator<=
2280 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2281 (const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y)
2282 #else
2283 (const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y)
2284 #endif
2285 { return !(y < x); }
2287 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2288 template<class T, class ...Options>
2289 #else
2290 template<class Config>
2291 #endif
2292 inline bool operator>=
2293 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2294 (const treap_multiset_impl<T, Options...> &x, const treap_multiset_impl<T, Options...> &y)
2295 #else
2296 (const treap_multiset_impl<Config> &x, const treap_multiset_impl<Config> &y)
2297 #endif
2298 { return !(x < y); }
2300 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2301 template<class T, class ...Options>
2302 #else
2303 template<class Config>
2304 #endif
2305 inline void swap
2306 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
2307 (treap_multiset_impl<T, Options...> &x, treap_multiset_impl<T, Options...> &y)
2308 #else
2309 (treap_multiset_impl<Config> &x, treap_multiset_impl<Config> &y)
2310 #endif
2311 { x.swap(y); }
2313 //! Helper metafunction to define a \c treap_multiset that yields to the same type when the
2314 //! same options (either explicitly or implicitly) are used.
2315 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
2316 template<class T, class ...Options>
2317 #else
2318 template<class T, class O1 = none, class O2 = none
2319 , class O3 = none, class O4 = none>
2320 #endif
2321 struct make_treap_multiset
2323 /// @cond
2324 typedef treap_multiset_impl
2325 < typename make_treap_opt<T,
2326 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
2327 O1, O2, O3, O4
2328 #else
2329 Options...
2330 #endif
2331 >::type
2332 > implementation_defined;
2333 /// @endcond
2334 typedef implementation_defined type;
2337 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
2339 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
2340 template<class T, class O1, class O2, class O3, class O4>
2341 #else
2342 template<class T, class ...Options>
2343 #endif
2344 class treap_multiset
2345 : public make_treap_multiset<T,
2346 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
2347 O1, O2, O3, O4
2348 #else
2349 Options...
2350 #endif
2351 >::type
2353 typedef typename make_treap_multiset
2354 <T,
2355 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
2356 O1, O2, O3, O4
2357 #else
2358 Options...
2359 #endif
2360 >::type Base;
2362 public:
2363 typedef typename Base::value_compare value_compare;
2364 typedef typename Base::priority_compare priority_compare;
2365 typedef typename Base::value_traits value_traits;
2366 typedef typename Base::iterator iterator;
2367 typedef typename Base::const_iterator const_iterator;
2369 //Assert if passed value traits are compatible with the type
2370 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
2372 treap_multiset( const value_compare &cmp = value_compare()
2373 , const priority_compare &pcmp = priority_compare()
2374 , const value_traits &v_traits = value_traits())
2375 : Base(cmp, pcmp, v_traits)
2378 template<class Iterator>
2379 treap_multiset( Iterator b, Iterator e
2380 , const value_compare &cmp = value_compare()
2381 , const priority_compare &pcmp = priority_compare()
2382 , const value_traits &v_traits = value_traits())
2383 : Base(b, e, cmp, pcmp, v_traits)
2386 static treap_multiset &container_from_end_iterator(iterator end_iterator)
2387 { return static_cast<treap_multiset &>(Base::container_from_end_iterator(end_iterator)); }
2389 static const treap_multiset &container_from_end_iterator(const_iterator end_iterator)
2390 { return static_cast<const treap_multiset &>(Base::container_from_end_iterator(end_iterator)); }
2392 static treap_multiset &container_from_iterator(iterator it)
2393 { return static_cast<treap_multiset &>(Base::container_from_iterator(it)); }
2395 static const treap_multiset &container_from_iterator(const_iterator it)
2396 { return static_cast<const treap_multiset &>(Base::container_from_iterator(it)); }
2399 #endif
2401 } //namespace intrusive
2402 } //namespace boost
2404 #include <boost/intrusive/detail/config_end.hpp>
2406 #endif //BOOST_INTRUSIVE_TRIE_SET_HPP