Chris@16
|
1 /////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@101
|
3 // (C) Copyright Ion Gaztanaga 2007-2014
|
Chris@16
|
4 //
|
Chris@16
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // See http://www.boost.org/libs/intrusive for documentation.
|
Chris@16
|
10 //
|
Chris@16
|
11 /////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
12 #ifndef BOOST_INTRUSIVE_SPLAYTREE_HPP
|
Chris@16
|
13 #define BOOST_INTRUSIVE_SPLAYTREE_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/intrusive/detail/config_begin.hpp>
|
Chris@101
|
16 #include <boost/intrusive/intrusive_fwd.hpp>
|
Chris@16
|
17 #include <cstddef>
|
Chris@101
|
18 #include <boost/intrusive/detail/minimal_less_equal_header.hpp>
|
Chris@101
|
19 #include <boost/intrusive/detail/minimal_pair_header.hpp> //std::pair
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/static_assert.hpp>
|
Chris@16
|
22 #include <boost/intrusive/bstree.hpp>
|
Chris@16
|
23 #include <boost/intrusive/detail/tree_node.hpp>
|
Chris@16
|
24 #include <boost/intrusive/detail/mpl.hpp>
|
Chris@16
|
25 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@16
|
26 #include <boost/intrusive/detail/function_detector.hpp>
|
Chris@101
|
27 #include <boost/intrusive/detail/get_value_traits.hpp>
|
Chris@16
|
28 #include <boost/intrusive/splaytree_algorithms.hpp>
|
Chris@16
|
29 #include <boost/intrusive/link_mode.hpp>
|
Chris@101
|
30 #include <boost/intrusive/detail/key_nodeptr_comp.hpp>
|
Chris@101
|
31 #include <boost/move/utility_core.hpp>
|
Chris@101
|
32
|
Chris@101
|
33 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
34 # pragma once
|
Chris@101
|
35 #endif
|
Chris@16
|
36
|
Chris@16
|
37 namespace boost {
|
Chris@16
|
38 namespace intrusive {
|
Chris@16
|
39
|
Chris@16
|
40 /// @cond
|
Chris@16
|
41
|
Chris@16
|
42 struct splaytree_defaults
|
Chris@16
|
43 {
|
Chris@101
|
44 typedef default_bstree_hook_applier proto_value_traits;
|
Chris@16
|
45 static const bool constant_time_size = true;
|
Chris@16
|
46 typedef std::size_t size_type;
|
Chris@16
|
47 typedef void compare;
|
Chris@101
|
48 typedef void header_holder_type;
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 /// @endcond
|
Chris@16
|
52
|
Chris@16
|
53 //! The class template splaytree is an intrusive splay tree container that
|
Chris@16
|
54 //! is used to construct intrusive splay_set and splay_multiset containers. The no-throw
|
Chris@16
|
55 //! guarantee holds only, if the value_compare object
|
Chris@16
|
56 //! doesn't throw.
|
Chris@16
|
57 //!
|
Chris@16
|
58 //! The template parameter \c T is the type to be managed by the container.
|
Chris@16
|
59 //! The user can specify additional options and if no options are provided
|
Chris@16
|
60 //! default options are used.
|
Chris@16
|
61 //!
|
Chris@16
|
62 //! The container supports the following options:
|
Chris@16
|
63 //! \c base_hook<>/member_hook<>/value_traits<>,
|
Chris@16
|
64 //! \c constant_time_size<>, \c size_type<> and
|
Chris@16
|
65 //! \c compare<>.
|
Chris@16
|
66 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
Chris@16
|
67 template<class T, class ...Options>
|
Chris@16
|
68 #else
|
Chris@101
|
69 template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
|
Chris@16
|
70 #endif
|
Chris@16
|
71 class splaytree_impl
|
Chris@16
|
72 /// @cond
|
Chris@101
|
73 : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, SplayTreeAlgorithms, HeaderHolder>
|
Chris@16
|
74 /// @endcond
|
Chris@16
|
75 {
|
Chris@16
|
76 public:
|
Chris@16
|
77 typedef ValueTraits value_traits;
|
Chris@16
|
78 /// @cond
|
Chris@16
|
79 typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
|
Chris@101
|
80 , ConstantTimeSize, SplayTreeAlgorithms
|
Chris@101
|
81 , HeaderHolder> tree_type;
|
Chris@16
|
82 typedef tree_type implementation_defined;
|
Chris@16
|
83 /// @endcond
|
Chris@16
|
84
|
Chris@16
|
85 typedef typename implementation_defined::pointer pointer;
|
Chris@16
|
86 typedef typename implementation_defined::const_pointer const_pointer;
|
Chris@16
|
87 typedef typename implementation_defined::value_type value_type;
|
Chris@16
|
88 typedef typename implementation_defined::key_type key_type;
|
Chris@16
|
89 typedef typename implementation_defined::reference reference;
|
Chris@16
|
90 typedef typename implementation_defined::const_reference const_reference;
|
Chris@16
|
91 typedef typename implementation_defined::difference_type difference_type;
|
Chris@16
|
92 typedef typename implementation_defined::size_type size_type;
|
Chris@16
|
93 typedef typename implementation_defined::value_compare value_compare;
|
Chris@16
|
94 typedef typename implementation_defined::key_compare key_compare;
|
Chris@16
|
95 typedef typename implementation_defined::iterator iterator;
|
Chris@16
|
96 typedef typename implementation_defined::const_iterator const_iterator;
|
Chris@16
|
97 typedef typename implementation_defined::reverse_iterator reverse_iterator;
|
Chris@16
|
98 typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
|
Chris@16
|
99 typedef typename implementation_defined::node_traits node_traits;
|
Chris@16
|
100 typedef typename implementation_defined::node node;
|
Chris@16
|
101 typedef typename implementation_defined::node_ptr node_ptr;
|
Chris@16
|
102 typedef typename implementation_defined::const_node_ptr const_node_ptr;
|
Chris@16
|
103 typedef typename implementation_defined::node_algorithms node_algorithms;
|
Chris@16
|
104
|
Chris@16
|
105 static const bool constant_time_size = implementation_defined::constant_time_size;
|
Chris@16
|
106 /// @cond
|
Chris@16
|
107 private:
|
Chris@16
|
108
|
Chris@16
|
109 //noncopyable
|
Chris@16
|
110 BOOST_MOVABLE_BUT_NOT_COPYABLE(splaytree_impl)
|
Chris@16
|
111
|
Chris@16
|
112 /// @endcond
|
Chris@16
|
113
|
Chris@16
|
114 public:
|
Chris@16
|
115
|
Chris@16
|
116 typedef typename implementation_defined::insert_commit_data insert_commit_data;
|
Chris@16
|
117
|
Chris@16
|
118 //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &)
|
Chris@16
|
119 explicit splaytree_impl( const value_compare &cmp = value_compare()
|
Chris@16
|
120 , const value_traits &v_traits = value_traits())
|
Chris@16
|
121 : tree_type(cmp, v_traits)
|
Chris@16
|
122 {}
|
Chris@16
|
123
|
Chris@16
|
124 //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
|
Chris@16
|
125 template<class Iterator>
|
Chris@16
|
126 splaytree_impl( bool unique, Iterator b, Iterator e
|
Chris@16
|
127 , const value_compare &cmp = value_compare()
|
Chris@16
|
128 , const value_traits &v_traits = value_traits())
|
Chris@16
|
129 : tree_type(cmp, v_traits)
|
Chris@16
|
130 {
|
Chris@16
|
131 if(unique)
|
Chris@16
|
132 this->insert_unique(b, e);
|
Chris@16
|
133 else
|
Chris@16
|
134 this->insert_equal(b, e);
|
Chris@16
|
135 }
|
Chris@16
|
136
|
Chris@16
|
137 //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
|
Chris@16
|
138 splaytree_impl(BOOST_RV_REF(splaytree_impl) x)
|
Chris@101
|
139 : tree_type(BOOST_MOVE_BASE(tree_type, x))
|
Chris@16
|
140 {}
|
Chris@16
|
141
|
Chris@16
|
142 //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
|
Chris@16
|
143 splaytree_impl& operator=(BOOST_RV_REF(splaytree_impl) x)
|
Chris@101
|
144 { return static_cast<splaytree_impl&>(tree_type::operator=(BOOST_MOVE_BASE(tree_type, x))); }
|
Chris@16
|
145
|
Chris@16
|
146 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
Chris@16
|
147 //! @copydoc ::boost::intrusive::bstree::~bstree()
|
Chris@16
|
148 ~splaytree_impl();
|
Chris@16
|
149
|
Chris@16
|
150 //! @copydoc ::boost::intrusive::bstree::begin()
|
Chris@16
|
151 iterator begin();
|
Chris@16
|
152
|
Chris@16
|
153 //! @copydoc ::boost::intrusive::bstree::begin()const
|
Chris@16
|
154 const_iterator begin() const;
|
Chris@16
|
155
|
Chris@16
|
156 //! @copydoc ::boost::intrusive::bstree::cbegin()const
|
Chris@16
|
157 const_iterator cbegin() const;
|
Chris@16
|
158
|
Chris@16
|
159 //! @copydoc ::boost::intrusive::bstree::end()
|
Chris@16
|
160 iterator end();
|
Chris@16
|
161
|
Chris@16
|
162 //! @copydoc ::boost::intrusive::bstree::end()const
|
Chris@16
|
163 const_iterator end() const;
|
Chris@16
|
164
|
Chris@16
|
165 //! @copydoc ::boost::intrusive::bstree::cend()const
|
Chris@16
|
166 const_iterator cend() const;
|
Chris@16
|
167
|
Chris@16
|
168 //! @copydoc ::boost::intrusive::bstree::rbegin()
|
Chris@16
|
169 reverse_iterator rbegin();
|
Chris@16
|
170
|
Chris@16
|
171 //! @copydoc ::boost::intrusive::bstree::rbegin()const
|
Chris@16
|
172 const_reverse_iterator rbegin() const;
|
Chris@16
|
173
|
Chris@16
|
174 //! @copydoc ::boost::intrusive::bstree::crbegin()const
|
Chris@16
|
175 const_reverse_iterator crbegin() const;
|
Chris@16
|
176
|
Chris@16
|
177 //! @copydoc ::boost::intrusive::bstree::rend()
|
Chris@16
|
178 reverse_iterator rend();
|
Chris@16
|
179
|
Chris@16
|
180 //! @copydoc ::boost::intrusive::bstree::rend()const
|
Chris@16
|
181 const_reverse_iterator rend() const;
|
Chris@16
|
182
|
Chris@16
|
183 //! @copydoc ::boost::intrusive::bstree::crend()const
|
Chris@16
|
184 const_reverse_iterator crend() const;
|
Chris@16
|
185
|
Chris@16
|
186 //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
|
Chris@16
|
187 static splaytree_impl &container_from_end_iterator(iterator end_iterator);
|
Chris@16
|
188
|
Chris@16
|
189 //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
|
Chris@16
|
190 static const splaytree_impl &container_from_end_iterator(const_iterator end_iterator);
|
Chris@16
|
191
|
Chris@16
|
192 //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
|
Chris@16
|
193 static splaytree_impl &container_from_iterator(iterator it);
|
Chris@16
|
194
|
Chris@16
|
195 //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
|
Chris@16
|
196 static const splaytree_impl &container_from_iterator(const_iterator it);
|
Chris@16
|
197
|
Chris@16
|
198 //! @copydoc ::boost::intrusive::bstree::key_comp()const
|
Chris@16
|
199 key_compare key_comp() const;
|
Chris@16
|
200
|
Chris@16
|
201 //! @copydoc ::boost::intrusive::bstree::value_comp()const
|
Chris@16
|
202 value_compare value_comp() const;
|
Chris@16
|
203
|
Chris@16
|
204 //! @copydoc ::boost::intrusive::bstree::empty()const
|
Chris@16
|
205 bool empty() const;
|
Chris@16
|
206
|
Chris@16
|
207 //! @copydoc ::boost::intrusive::bstree::size()const
|
Chris@16
|
208 size_type size() const;
|
Chris@16
|
209
|
Chris@16
|
210 //! @copydoc ::boost::intrusive::bstree::swap
|
Chris@16
|
211 void swap(splaytree_impl& other);
|
Chris@16
|
212
|
Chris@16
|
213 //! @copydoc ::boost::intrusive::bstree::clone_from
|
Chris@16
|
214 template <class Cloner, class Disposer>
|
Chris@16
|
215 void clone_from(const splaytree_impl &src, Cloner cloner, Disposer disposer);
|
Chris@16
|
216
|
Chris@16
|
217 //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
|
Chris@16
|
218 iterator insert_equal(reference value);
|
Chris@16
|
219
|
Chris@16
|
220 //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
|
Chris@16
|
221 iterator insert_equal(const_iterator hint, reference value);
|
Chris@16
|
222
|
Chris@16
|
223 //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
|
Chris@16
|
224 template<class Iterator>
|
Chris@16
|
225 void insert_equal(Iterator b, Iterator e);
|
Chris@16
|
226
|
Chris@16
|
227 //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
|
Chris@16
|
228 std::pair<iterator, bool> insert_unique(reference value);
|
Chris@16
|
229
|
Chris@16
|
230 //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
|
Chris@16
|
231 iterator insert_unique(const_iterator hint, reference value);
|
Chris@16
|
232
|
Chris@16
|
233 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&)
|
Chris@16
|
234 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
235 std::pair<iterator, bool> insert_unique_check
|
Chris@16
|
236 (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data);
|
Chris@16
|
237
|
Chris@16
|
238 //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&)
|
Chris@16
|
239 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
240 std::pair<iterator, bool> insert_unique_check
|
Chris@16
|
241 (const_iterator hint, const KeyType &key
|
Chris@16
|
242 ,KeyValueCompare key_value_comp, insert_commit_data &commit_data);
|
Chris@16
|
243
|
Chris@16
|
244 //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
|
Chris@16
|
245 iterator insert_unique_commit(reference value, const insert_commit_data &commit_data);
|
Chris@16
|
246
|
Chris@16
|
247 //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
|
Chris@16
|
248 template<class Iterator>
|
Chris@16
|
249 void insert_unique(Iterator b, Iterator e);
|
Chris@16
|
250
|
Chris@16
|
251 //! @copydoc ::boost::intrusive::bstree::insert_before
|
Chris@16
|
252 iterator insert_before(const_iterator pos, reference value);
|
Chris@16
|
253
|
Chris@16
|
254 //! @copydoc ::boost::intrusive::bstree::push_back
|
Chris@16
|
255 void push_back(reference value);
|
Chris@16
|
256
|
Chris@16
|
257 //! @copydoc ::boost::intrusive::bstree::push_front
|
Chris@16
|
258 void push_front(reference value);
|
Chris@16
|
259
|
Chris@16
|
260 //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
|
Chris@16
|
261 iterator erase(const_iterator i);
|
Chris@16
|
262
|
Chris@16
|
263 //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
|
Chris@16
|
264 iterator erase(const_iterator b, const_iterator e);
|
Chris@16
|
265
|
Chris@16
|
266 //! @copydoc ::boost::intrusive::bstree::erase(const_reference)
|
Chris@16
|
267 size_type erase(const_reference value);
|
Chris@16
|
268
|
Chris@16
|
269 //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare)
|
Chris@16
|
270 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
271 size_type erase(const KeyType& key, KeyValueCompare comp);
|
Chris@16
|
272
|
Chris@16
|
273 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
|
Chris@16
|
274 template<class Disposer>
|
Chris@16
|
275 iterator erase_and_dispose(const_iterator i, Disposer disposer);
|
Chris@16
|
276
|
Chris@16
|
277 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
|
Chris@16
|
278 template<class Disposer>
|
Chris@16
|
279 iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
|
Chris@16
|
280
|
Chris@16
|
281 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer)
|
Chris@16
|
282 template<class Disposer>
|
Chris@16
|
283 size_type erase_and_dispose(const_reference value, Disposer disposer);
|
Chris@16
|
284
|
Chris@16
|
285 //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
|
Chris@16
|
286 template<class KeyType, class KeyValueCompare, class Disposer>
|
Chris@16
|
287 size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
|
Chris@16
|
288
|
Chris@16
|
289 //! @copydoc ::boost::intrusive::bstree::clear
|
Chris@16
|
290 void clear();
|
Chris@16
|
291
|
Chris@16
|
292 //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
|
Chris@16
|
293 template<class Disposer>
|
Chris@16
|
294 void clear_and_dispose(Disposer disposer);
|
Chris@16
|
295
|
Chris@101
|
296 //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
|
Chris@101
|
297 //! Additional note: non-const function, splaying is performed.
|
Chris@101
|
298 size_type count(const_reference value);
|
Chris@101
|
299
|
Chris@101
|
300 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
|
Chris@101
|
301 //! Additional note: non-const function, splaying is performed.
|
Chris@101
|
302 template<class KeyType, class KeyValueCompare>
|
Chris@101
|
303 size_type count(const KeyType &key, KeyValueCompare comp);
|
Chris@16
|
304
|
Chris@16
|
305 //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
|
Chris@101
|
306 //! Additional note: const function, no splaying is performed
|
Chris@101
|
307 size_type count(const_reference value) const;
|
Chris@16
|
308
|
Chris@16
|
309 //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
|
Chris@101
|
310 //! Additional note: const function, no splaying is performed
|
Chris@16
|
311 template<class KeyType, class KeyValueCompare>
|
Chris@101
|
312 size_type count(const KeyType &key, KeyValueCompare comp) const;
|
Chris@16
|
313
|
Chris@16
|
314 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)
|
Chris@101
|
315 //! Additional note: non-const function, splaying is performed.
|
Chris@16
|
316 iterator lower_bound(const_reference value);
|
Chris@16
|
317
|
Chris@16
|
318 //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const
|
Chris@16
|
319 //! Additional note: const function, no splaying is performed
|
Chris@16
|
320 const_iterator lower_bound(const_reference value) const;
|
Chris@16
|
321
|
Chris@16
|
322 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)
|
Chris@16
|
323 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
324 //! element of the equal range of "key"
|
Chris@16
|
325 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
326 iterator lower_bound(const KeyType &key, KeyValueCompare comp);
|
Chris@16
|
327
|
Chris@16
|
328 //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const
|
Chris@16
|
329 //! Additional note: const function, no splaying is performed
|
Chris@16
|
330 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
331 const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const;
|
Chris@16
|
332
|
Chris@16
|
333 //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)
|
Chris@16
|
334 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
335 //! element of the equal range of "value"
|
Chris@16
|
336 iterator upper_bound(const_reference value);
|
Chris@16
|
337
|
Chris@16
|
338 //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const
|
Chris@16
|
339 //! Additional note: const function, no splaying is performed
|
Chris@16
|
340 const_iterator upper_bound(const_reference value) const;
|
Chris@16
|
341
|
Chris@16
|
342 //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)
|
Chris@16
|
343 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
344 //! element of the equal range of "key"
|
Chris@16
|
345 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
346 iterator upper_bound(const KeyType &key, KeyValueCompare comp);
|
Chris@16
|
347
|
Chris@16
|
348 //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const
|
Chris@16
|
349 //! Additional note: const function, no splaying is performed
|
Chris@16
|
350 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
351 const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const;
|
Chris@16
|
352
|
Chris@16
|
353 //! @copydoc ::boost::intrusive::bstree::find(const_reference)
|
Chris@16
|
354 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
355 //! element of the equal range of "value"
|
Chris@16
|
356 iterator find(const_reference value);
|
Chris@16
|
357
|
Chris@16
|
358 //! @copydoc ::boost::intrusive::bstree::find(const_reference)const
|
Chris@16
|
359 //! Additional note: const function, no splaying is performed
|
Chris@16
|
360 const_iterator find(const_reference value) const;
|
Chris@16
|
361
|
Chris@16
|
362 //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)
|
Chris@16
|
363 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
364 //! element of the equal range of "key"
|
Chris@16
|
365 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
366 iterator find(const KeyType &key, KeyValueCompare comp);
|
Chris@16
|
367
|
Chris@16
|
368 //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const
|
Chris@16
|
369 //! Additional note: const function, no splaying is performed
|
Chris@16
|
370 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
371 const_iterator find(const KeyType &key, KeyValueCompare comp) const;
|
Chris@16
|
372
|
Chris@16
|
373 //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)
|
Chris@16
|
374 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
375 //! element of the equal range of "value"
|
Chris@16
|
376 std::pair<iterator, iterator> equal_range(const_reference value);
|
Chris@16
|
377
|
Chris@16
|
378 //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const
|
Chris@16
|
379 //! Additional note: const function, no splaying is performed
|
Chris@16
|
380 std::pair<const_iterator, const_iterator> equal_range(const_reference value) const;
|
Chris@16
|
381
|
Chris@16
|
382 //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)
|
Chris@16
|
383 //! Additional note: non-const function, splaying is performed for the first
|
Chris@16
|
384 //! element of the equal range of "key"
|
Chris@16
|
385 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
386 std::pair<iterator, iterator> equal_range(const KeyType &key, KeyValueCompare comp);
|
Chris@16
|
387
|
Chris@16
|
388 //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const
|
Chris@16
|
389 //! Additional note: const function, no splaying is performed
|
Chris@16
|
390 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
391 std::pair<const_iterator, const_iterator> equal_range(const KeyType &key, KeyValueCompare comp) const;
|
Chris@16
|
392
|
Chris@16
|
393 //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)
|
Chris@16
|
394 std::pair<iterator,iterator> bounded_range
|
Chris@16
|
395 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
|
Chris@16
|
396
|
Chris@16
|
397 //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)
|
Chris@16
|
398 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
399 std::pair<iterator,iterator> bounded_range
|
Chris@16
|
400 (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
|
Chris@16
|
401
|
Chris@16
|
402 //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const
|
Chris@16
|
403 std::pair<const_iterator, const_iterator> bounded_range
|
Chris@16
|
404 (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
|
Chris@16
|
405
|
Chris@16
|
406 //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const
|
Chris@16
|
407 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
408 std::pair<const_iterator, const_iterator> bounded_range
|
Chris@16
|
409 (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
|
Chris@16
|
410
|
Chris@16
|
411 //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
|
Chris@16
|
412 static iterator s_iterator_to(reference value);
|
Chris@16
|
413
|
Chris@16
|
414 //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
|
Chris@16
|
415 static const_iterator s_iterator_to(const_reference value);
|
Chris@16
|
416
|
Chris@16
|
417 //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
|
Chris@16
|
418 iterator iterator_to(reference value);
|
Chris@16
|
419
|
Chris@16
|
420 //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
|
Chris@16
|
421 const_iterator iterator_to(const_reference value) const;
|
Chris@16
|
422
|
Chris@16
|
423 //! @copydoc ::boost::intrusive::bstree::init_node(reference)
|
Chris@16
|
424 static void init_node(reference value);
|
Chris@16
|
425
|
Chris@16
|
426 //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
|
Chris@16
|
427 pointer unlink_leftmost_without_rebalance();
|
Chris@16
|
428
|
Chris@16
|
429 //! @copydoc ::boost::intrusive::bstree::replace_node
|
Chris@16
|
430 void replace_node(iterator replace_this, reference with_this);
|
Chris@16
|
431
|
Chris@16
|
432 //! @copydoc ::boost::intrusive::bstree::remove_node
|
Chris@16
|
433 void remove_node(reference value);
|
Chris@16
|
434
|
Chris@16
|
435 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
Chris@16
|
436
|
Chris@16
|
437 //! <b>Requires</b>: i must be a valid iterator of *this.
|
Chris@16
|
438 //!
|
Chris@16
|
439 //! <b>Effects</b>: Rearranges the container so that the element pointed by i
|
Chris@16
|
440 //! is placed as the root of the tree, improving future searches of this value.
|
Chris@16
|
441 //!
|
Chris@16
|
442 //! <b>Complexity</b>: Amortized logarithmic.
|
Chris@16
|
443 //!
|
Chris@16
|
444 //! <b>Throws</b>: Nothing.
|
Chris@16
|
445 void splay_up(iterator i)
|
Chris@16
|
446 { return node_algorithms::splay_up(i.pointed_node(), tree_type::header_ptr()); }
|
Chris@16
|
447
|
Chris@16
|
448 //! <b>Effects</b>: Rearranges the container so that if *this stores an element
|
Chris@16
|
449 //! with a key equivalent to value the element is placed as the root of the
|
Chris@16
|
450 //! tree. If the element is not present returns the last node compared with the key.
|
Chris@16
|
451 //! If the tree is empty, end() is returned.
|
Chris@16
|
452 //!
|
Chris@16
|
453 //! <b>Complexity</b>: Amortized logarithmic.
|
Chris@16
|
454 //!
|
Chris@16
|
455 //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty.
|
Chris@16
|
456 //!
|
Chris@16
|
457 //! <b>Throws</b>: If the comparison functor throws.
|
Chris@16
|
458 template<class KeyType, class KeyValueCompare>
|
Chris@16
|
459 iterator splay_down(const KeyType &key, KeyValueCompare comp)
|
Chris@16
|
460 {
|
Chris@101
|
461 detail::key_nodeptr_comp<value_compare, value_traits>
|
Chris@101
|
462 key_node_comp(comp, &this->get_value_traits());
|
Chris@16
|
463 node_ptr r = node_algorithms::splay_down(tree_type::header_ptr(), key, key_node_comp);
|
Chris@101
|
464 return iterator(r, this->priv_value_traits_ptr());
|
Chris@16
|
465 }
|
Chris@16
|
466
|
Chris@16
|
467 //! <b>Effects</b>: Rearranges the container so that if *this stores an element
|
Chris@16
|
468 //! with a key equivalent to value the element is placed as the root of the
|
Chris@16
|
469 //! tree.
|
Chris@16
|
470 //!
|
Chris@16
|
471 //! <b>Complexity</b>: Amortized logarithmic.
|
Chris@16
|
472 //!
|
Chris@16
|
473 //! <b>Returns</b>: An iterator to the new root of the tree, end() if the tree is empty.
|
Chris@16
|
474 //!
|
Chris@16
|
475 //! <b>Throws</b>: If the predicate throws.
|
Chris@16
|
476 iterator splay_down(const_reference value)
|
Chris@16
|
477 { return this->splay_down(value, this->value_comp()); }
|
Chris@16
|
478
|
Chris@16
|
479 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
Chris@16
|
480 //! @copydoc ::boost::intrusive::bstree::rebalance
|
Chris@16
|
481 void rebalance();
|
Chris@16
|
482
|
Chris@16
|
483 //! @copydoc ::boost::intrusive::bstree::rebalance_subtree
|
Chris@16
|
484 iterator rebalance_subtree(iterator root);
|
Chris@16
|
485 #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
Chris@16
|
486 };
|
Chris@16
|
487
|
Chris@16
|
488 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
Chris@16
|
489
|
Chris@16
|
490 template<class T, class ...Options>
|
Chris@16
|
491 bool operator< (const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y);
|
Chris@16
|
492
|
Chris@16
|
493 template<class T, class ...Options>
|
Chris@16
|
494 bool operator==(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y);
|
Chris@16
|
495
|
Chris@16
|
496 template<class T, class ...Options>
|
Chris@16
|
497 bool operator!= (const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y);
|
Chris@16
|
498
|
Chris@16
|
499 template<class T, class ...Options>
|
Chris@16
|
500 bool operator>(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y);
|
Chris@16
|
501
|
Chris@16
|
502 template<class T, class ...Options>
|
Chris@16
|
503 bool operator<=(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y);
|
Chris@16
|
504
|
Chris@16
|
505 template<class T, class ...Options>
|
Chris@16
|
506 bool operator>=(const splaytree_impl<T, Options...> &x, const splaytree_impl<T, Options...> &y);
|
Chris@16
|
507
|
Chris@16
|
508 template<class T, class ...Options>
|
Chris@16
|
509 void swap(splaytree_impl<T, Options...> &x, splaytree_impl<T, Options...> &y);
|
Chris@16
|
510
|
Chris@16
|
511 #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
Chris@16
|
512
|
Chris@16
|
513 //! Helper metafunction to define a \c splaytree that yields to the same type when the
|
Chris@16
|
514 //! same options (either explicitly or implicitly) are used.
|
Chris@16
|
515 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
516 template<class T, class ...Options>
|
Chris@16
|
517 #else
|
Chris@16
|
518 template<class T, class O1 = void, class O2 = void
|
Chris@101
|
519 , class O3 = void, class O4 = void
|
Chris@101
|
520 , class O5 = void>
|
Chris@16
|
521 #endif
|
Chris@16
|
522 struct make_splaytree
|
Chris@16
|
523 {
|
Chris@16
|
524 /// @cond
|
Chris@16
|
525 typedef typename pack_options
|
Chris@16
|
526 < splaytree_defaults,
|
Chris@16
|
527 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@101
|
528 O1, O2, O3, O4, O5
|
Chris@16
|
529 #else
|
Chris@16
|
530 Options...
|
Chris@16
|
531 #endif
|
Chris@16
|
532 >::type packed_options;
|
Chris@16
|
533
|
Chris@16
|
534 typedef typename detail::get_value_traits
|
Chris@16
|
535 <T, typename packed_options::proto_value_traits>::type value_traits;
|
Chris@16
|
536
|
Chris@16
|
537 typedef splaytree_impl
|
Chris@16
|
538 < value_traits
|
Chris@16
|
539 , typename packed_options::compare
|
Chris@16
|
540 , typename packed_options::size_type
|
Chris@16
|
541 , packed_options::constant_time_size
|
Chris@101
|
542 , typename packed_options::header_holder_type
|
Chris@16
|
543 > implementation_defined;
|
Chris@16
|
544 /// @endcond
|
Chris@16
|
545 typedef implementation_defined type;
|
Chris@16
|
546 };
|
Chris@16
|
547
|
Chris@16
|
548
|
Chris@16
|
549 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
Chris@16
|
550
|
Chris@16
|
551 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@101
|
552 template<class T, class O1, class O2, class O3, class O4, class O5>
|
Chris@16
|
553 #else
|
Chris@16
|
554 template<class T, class ...Options>
|
Chris@16
|
555 #endif
|
Chris@16
|
556 class splaytree
|
Chris@16
|
557 : public make_splaytree<T,
|
Chris@16
|
558 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@101
|
559 O1, O2, O3, O4, O5
|
Chris@16
|
560 #else
|
Chris@16
|
561 Options...
|
Chris@16
|
562 #endif
|
Chris@16
|
563 >::type
|
Chris@16
|
564 {
|
Chris@16
|
565 typedef typename make_splaytree
|
Chris@16
|
566 <T,
|
Chris@16
|
567 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@101
|
568 O1, O2, O3, O4, O5
|
Chris@16
|
569 #else
|
Chris@16
|
570 Options...
|
Chris@16
|
571 #endif
|
Chris@16
|
572 >::type Base;
|
Chris@16
|
573 BOOST_MOVABLE_BUT_NOT_COPYABLE(splaytree)
|
Chris@16
|
574
|
Chris@16
|
575 public:
|
Chris@16
|
576 typedef typename Base::value_compare value_compare;
|
Chris@16
|
577 typedef typename Base::value_traits value_traits;
|
Chris@16
|
578 typedef typename Base::iterator iterator;
|
Chris@16
|
579 typedef typename Base::const_iterator const_iterator;
|
Chris@16
|
580 typedef typename Base::reverse_iterator reverse_iterator;
|
Chris@16
|
581 typedef typename Base::const_reverse_iterator const_reverse_iterator;
|
Chris@16
|
582
|
Chris@16
|
583 //Assert if passed value traits are compatible with the type
|
Chris@101
|
584 BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
|
Chris@16
|
585
|
Chris@16
|
586 explicit splaytree( const value_compare &cmp = value_compare()
|
Chris@16
|
587 , const value_traits &v_traits = value_traits())
|
Chris@16
|
588 : Base(cmp, v_traits)
|
Chris@16
|
589 {}
|
Chris@16
|
590
|
Chris@16
|
591 template<class Iterator>
|
Chris@16
|
592 splaytree( bool unique, Iterator b, Iterator e
|
Chris@16
|
593 , const value_compare &cmp = value_compare()
|
Chris@16
|
594 , const value_traits &v_traits = value_traits())
|
Chris@16
|
595 : Base(unique, b, e, cmp, v_traits)
|
Chris@16
|
596 {}
|
Chris@16
|
597
|
Chris@16
|
598 splaytree(BOOST_RV_REF(splaytree) x)
|
Chris@101
|
599 : Base(BOOST_MOVE_BASE(Base, x))
|
Chris@16
|
600 {}
|
Chris@16
|
601
|
Chris@16
|
602 splaytree& operator=(BOOST_RV_REF(splaytree) x)
|
Chris@101
|
603 { return static_cast<splaytree &>(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); }
|
Chris@16
|
604
|
Chris@16
|
605 static splaytree &container_from_end_iterator(iterator end_iterator)
|
Chris@16
|
606 { return static_cast<splaytree &>(Base::container_from_end_iterator(end_iterator)); }
|
Chris@16
|
607
|
Chris@16
|
608 static const splaytree &container_from_end_iterator(const_iterator end_iterator)
|
Chris@16
|
609 { return static_cast<const splaytree &>(Base::container_from_end_iterator(end_iterator)); }
|
Chris@16
|
610
|
Chris@16
|
611 static splaytree &container_from_iterator(iterator it)
|
Chris@16
|
612 { return static_cast<splaytree &>(Base::container_from_iterator(it)); }
|
Chris@16
|
613
|
Chris@16
|
614 static const splaytree &container_from_iterator(const_iterator it)
|
Chris@16
|
615 { return static_cast<const splaytree &>(Base::container_from_iterator(it)); }
|
Chris@16
|
616 };
|
Chris@16
|
617
|
Chris@16
|
618 #endif
|
Chris@16
|
619
|
Chris@16
|
620 } //namespace intrusive
|
Chris@16
|
621 } //namespace boost
|
Chris@16
|
622
|
Chris@16
|
623 #include <boost/intrusive/detail/config_end.hpp>
|
Chris@16
|
624
|
Chris@16
|
625 #endif //BOOST_INTRUSIVE_SPLAYTREE_HPP
|