Chris@16
|
1 /////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Olaf Krzikalla 2004-2006.
|
Chris@16
|
4 // (C) Copyright Ion Gaztanaga 2006-2013
|
Chris@16
|
5 //
|
Chris@16
|
6 // Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
7 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
8 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
9 //
|
Chris@16
|
10 // See http://www.boost.org/libs/intrusive for documentation.
|
Chris@16
|
11 //
|
Chris@16
|
12 /////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP
|
Chris@16
|
15 #define BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/intrusive/detail/config_begin.hpp>
|
Chris@16
|
18 #include <boost/intrusive/intrusive_fwd.hpp>
|
Chris@101
|
19
|
Chris@16
|
20 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@16
|
21 #include <boost/intrusive/slist_hook.hpp>
|
Chris@16
|
22 #include <boost/intrusive/options.hpp>
|
Chris@16
|
23 #include <boost/intrusive/detail/generic_hook.hpp>
|
Chris@16
|
24
|
Chris@101
|
25 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
26 # pragma once
|
Chris@101
|
27 #endif
|
Chris@101
|
28
|
Chris@16
|
29 namespace boost {
|
Chris@16
|
30 namespace intrusive {
|
Chris@16
|
31
|
Chris@16
|
32 /// @cond
|
Chris@16
|
33
|
Chris@16
|
34 template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey>
|
Chris@16
|
35 struct unordered_node
|
Chris@16
|
36 : public slist_node<VoidPointer>
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef typename pointer_traits
|
Chris@16
|
39 <VoidPointer>::template rebind_pointer
|
Chris@16
|
40 < unordered_node<VoidPointer, StoreHash, OptimizeMultiKey> >::type
|
Chris@16
|
41 node_ptr;
|
Chris@16
|
42 node_ptr prev_in_group_;
|
Chris@16
|
43 std::size_t hash_;
|
Chris@16
|
44 };
|
Chris@16
|
45
|
Chris@16
|
46 template<class VoidPointer>
|
Chris@16
|
47 struct unordered_node<VoidPointer, false, true>
|
Chris@16
|
48 : public slist_node<VoidPointer>
|
Chris@16
|
49 {
|
Chris@16
|
50 typedef typename pointer_traits
|
Chris@16
|
51 <VoidPointer>::template rebind_pointer
|
Chris@16
|
52 < unordered_node<VoidPointer, false, true> >::type
|
Chris@16
|
53 node_ptr;
|
Chris@16
|
54 node_ptr prev_in_group_;
|
Chris@16
|
55 };
|
Chris@16
|
56
|
Chris@16
|
57 template<class VoidPointer>
|
Chris@16
|
58 struct unordered_node<VoidPointer, true, false>
|
Chris@16
|
59 : public slist_node<VoidPointer>
|
Chris@16
|
60 {
|
Chris@16
|
61 typedef typename pointer_traits
|
Chris@16
|
62 <VoidPointer>::template rebind_pointer
|
Chris@16
|
63 < unordered_node<VoidPointer, true, false> >::type
|
Chris@16
|
64 node_ptr;
|
Chris@16
|
65 std::size_t hash_;
|
Chris@16
|
66 };
|
Chris@16
|
67
|
Chris@16
|
68 template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey>
|
Chris@16
|
69 struct unordered_node_traits
|
Chris@16
|
70 : public slist_node_traits<VoidPointer>
|
Chris@16
|
71 {
|
Chris@16
|
72 typedef slist_node_traits<VoidPointer> reduced_slist_node_traits;
|
Chris@16
|
73 typedef unordered_node<VoidPointer, StoreHash, OptimizeMultiKey> node;
|
Chris@16
|
74
|
Chris@16
|
75 typedef typename pointer_traits
|
Chris@16
|
76 <VoidPointer>::template rebind_pointer
|
Chris@16
|
77 < node >::type node_ptr;
|
Chris@16
|
78 typedef typename pointer_traits
|
Chris@16
|
79 <VoidPointer>::template rebind_pointer
|
Chris@16
|
80 < const node >::type const_node_ptr;
|
Chris@16
|
81
|
Chris@16
|
82 static const bool store_hash = StoreHash;
|
Chris@16
|
83 static const bool optimize_multikey = OptimizeMultiKey;
|
Chris@16
|
84
|
Chris@16
|
85 static node_ptr get_next(const const_node_ptr & n)
|
Chris@101
|
86 { return pointer_traits<node_ptr>::static_cast_from(n->next_); }
|
Chris@16
|
87
|
Chris@16
|
88 static void set_next(const node_ptr & n, const node_ptr & next)
|
Chris@16
|
89 { n->next_ = next; }
|
Chris@16
|
90
|
Chris@16
|
91 static node_ptr get_prev_in_group(const const_node_ptr & n)
|
Chris@16
|
92 { return n->prev_in_group_; }
|
Chris@16
|
93
|
Chris@16
|
94 static void set_prev_in_group(const node_ptr & n, const node_ptr & prev)
|
Chris@16
|
95 { n->prev_in_group_ = prev; }
|
Chris@16
|
96
|
Chris@16
|
97 static std::size_t get_hash(const const_node_ptr & n)
|
Chris@16
|
98 { return n->hash_; }
|
Chris@16
|
99
|
Chris@16
|
100 static void set_hash(const node_ptr & n, std::size_t h)
|
Chris@16
|
101 { n->hash_ = h; }
|
Chris@16
|
102 };
|
Chris@16
|
103
|
Chris@16
|
104 template<class NodeTraits>
|
Chris@16
|
105 struct unordered_group_adapter
|
Chris@16
|
106 {
|
Chris@16
|
107 typedef typename NodeTraits::node node;
|
Chris@16
|
108 typedef typename NodeTraits::node_ptr node_ptr;
|
Chris@16
|
109 typedef typename NodeTraits::const_node_ptr const_node_ptr;
|
Chris@16
|
110
|
Chris@16
|
111 static node_ptr get_next(const const_node_ptr & n)
|
Chris@16
|
112 { return NodeTraits::get_prev_in_group(n); }
|
Chris@16
|
113
|
Chris@16
|
114 static void set_next(const node_ptr & n, const node_ptr & next)
|
Chris@16
|
115 { NodeTraits::set_prev_in_group(n, next); }
|
Chris@16
|
116 };
|
Chris@16
|
117
|
Chris@16
|
118 template<class NodeTraits>
|
Chris@16
|
119 struct unordered_algorithms
|
Chris@16
|
120 : public circular_slist_algorithms<NodeTraits>
|
Chris@16
|
121 {
|
Chris@16
|
122 typedef circular_slist_algorithms<NodeTraits> base_type;
|
Chris@16
|
123 typedef unordered_group_adapter<NodeTraits> group_traits;
|
Chris@16
|
124 typedef circular_slist_algorithms<group_traits> group_algorithms;
|
Chris@16
|
125 typedef NodeTraits node_traits;
|
Chris@16
|
126 typedef typename NodeTraits::node node;
|
Chris@16
|
127 typedef typename NodeTraits::node_ptr node_ptr;
|
Chris@16
|
128 typedef typename NodeTraits::const_node_ptr const_node_ptr;
|
Chris@16
|
129
|
Chris@16
|
130 static void init(typename base_type::node_ptr n)
|
Chris@16
|
131 {
|
Chris@16
|
132 base_type::init(n);
|
Chris@16
|
133 group_algorithms::init(n);
|
Chris@16
|
134 }
|
Chris@16
|
135
|
Chris@16
|
136 static void init_header(typename base_type::node_ptr n)
|
Chris@16
|
137 {
|
Chris@16
|
138 base_type::init_header(n);
|
Chris@16
|
139 group_algorithms::init_header(n);
|
Chris@16
|
140 }
|
Chris@16
|
141
|
Chris@16
|
142 static void unlink(typename base_type::node_ptr n)
|
Chris@16
|
143 {
|
Chris@16
|
144 base_type::unlink(n);
|
Chris@16
|
145 group_algorithms::unlink(n);
|
Chris@16
|
146 }
|
Chris@16
|
147 };
|
Chris@16
|
148
|
Chris@101
|
149 //Class to avoid defining the same algo as a circular list, as hooks would be ambiguous between them
|
Chris@101
|
150 template<class Algo>
|
Chris@101
|
151 struct uset_algo_wrapper : public Algo
|
Chris@101
|
152 {};
|
Chris@101
|
153
|
Chris@16
|
154 template<class VoidPointer, bool StoreHash, bool OptimizeMultiKey>
|
Chris@16
|
155 struct get_uset_node_algo
|
Chris@16
|
156 {
|
Chris@16
|
157 typedef typename detail::if_c
|
Chris@16
|
158 < (StoreHash || OptimizeMultiKey)
|
Chris@16
|
159 , unordered_node_traits<VoidPointer, StoreHash, OptimizeMultiKey>
|
Chris@16
|
160 , slist_node_traits<VoidPointer>
|
Chris@16
|
161 >::type node_traits_type;
|
Chris@16
|
162 typedef typename detail::if_c
|
Chris@101
|
163 < OptimizeMultiKey
|
Chris@101
|
164 , unordered_algorithms<node_traits_type>
|
Chris@101
|
165 , uset_algo_wrapper< circular_slist_algorithms<node_traits_type> >
|
Chris@16
|
166 >::type type;
|
Chris@16
|
167 };
|
Chris@16
|
168 /// @endcond
|
Chris@16
|
169
|
Chris@16
|
170 //! Helper metafunction to define a \c unordered_set_base_hook that yields to the same
|
Chris@16
|
171 //! type when the same options (either explicitly or implicitly) are used.
|
Chris@16
|
172 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
173 template<class ...Options>
|
Chris@16
|
174 #else
|
Chris@16
|
175 template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
|
Chris@16
|
176 #endif
|
Chris@16
|
177 struct make_unordered_set_base_hook
|
Chris@16
|
178 {
|
Chris@16
|
179 /// @cond
|
Chris@16
|
180 typedef typename pack_options
|
Chris@16
|
181 < hook_defaults,
|
Chris@16
|
182 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
183 O1, O2, O3, O4
|
Chris@16
|
184 #else
|
Chris@16
|
185 Options...
|
Chris@16
|
186 #endif
|
Chris@16
|
187 >::type packed_options;
|
Chris@16
|
188
|
Chris@16
|
189 typedef generic_hook
|
Chris@101
|
190 < typename get_uset_node_algo < typename packed_options::void_pointer
|
Chris@101
|
191 , packed_options::store_hash
|
Chris@101
|
192 , packed_options::optimize_multikey
|
Chris@101
|
193 >::type
|
Chris@16
|
194 , typename packed_options::tag
|
Chris@16
|
195 , packed_options::link_mode
|
Chris@16
|
196 , HashBaseHookId
|
Chris@16
|
197 > implementation_defined;
|
Chris@16
|
198 /// @endcond
|
Chris@16
|
199 typedef implementation_defined type;
|
Chris@16
|
200 };
|
Chris@16
|
201
|
Chris@16
|
202 //! Derive a class from unordered_set_base_hook in order to store objects in
|
Chris@16
|
203 //! in an unordered_set/unordered_multi_set. unordered_set_base_hook holds the data necessary to maintain
|
Chris@16
|
204 //! the unordered_set/unordered_multi_set and provides an appropriate value_traits class for unordered_set/unordered_multi_set.
|
Chris@16
|
205 //!
|
Chris@16
|
206 //! The hook admits the following options: \c tag<>, \c void_pointer<>,
|
Chris@16
|
207 //! \c link_mode<>, \c store_hash<> and \c optimize_multikey<>.
|
Chris@16
|
208 //!
|
Chris@16
|
209 //! \c tag<> defines a tag to identify the node.
|
Chris@16
|
210 //! The same tag value can be used in different classes, but if a class is
|
Chris@16
|
211 //! derived from more than one \c list_base_hook, then each \c list_base_hook needs its
|
Chris@16
|
212 //! unique tag.
|
Chris@16
|
213 //!
|
Chris@16
|
214 //! \c void_pointer<> is the pointer type that will be used internally in the hook
|
Chris@101
|
215 //! and the container configured to use this hook.
|
Chris@16
|
216 //!
|
Chris@16
|
217 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
|
Chris@16
|
218 //! \c auto_unlink or \c safe_link).
|
Chris@16
|
219 //!
|
Chris@16
|
220 //! \c store_hash<> will tell the hook to store the hash of the value
|
Chris@16
|
221 //! to speed up rehashings.
|
Chris@16
|
222 //!
|
Chris@16
|
223 //! \c optimize_multikey<> will tell the hook to store a link to form a group
|
Chris@16
|
224 //! with other value with the same value to speed up searches and insertions
|
Chris@16
|
225 //! in unordered_multisets with a great number of with equivalent keys.
|
Chris@16
|
226 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
227 template<class ...Options>
|
Chris@16
|
228 #else
|
Chris@16
|
229 template<class O1, class O2, class O3, class O4>
|
Chris@16
|
230 #endif
|
Chris@16
|
231 class unordered_set_base_hook
|
Chris@16
|
232 : public make_unordered_set_base_hook<
|
Chris@16
|
233 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
234 O1, O2, O3, O4
|
Chris@16
|
235 #else
|
Chris@16
|
236 Options...
|
Chris@16
|
237 #endif
|
Chris@16
|
238 >::type
|
Chris@16
|
239 {
|
Chris@16
|
240 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
Chris@16
|
241 public:
|
Chris@16
|
242 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
|
Chris@16
|
243 //! initializes the node to an unlinked state.
|
Chris@16
|
244 //!
|
Chris@16
|
245 //! <b>Throws</b>: Nothing.
|
Chris@16
|
246 unordered_set_base_hook();
|
Chris@16
|
247
|
Chris@16
|
248 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
|
Chris@16
|
249 //! initializes the node to an unlinked state. The argument is ignored.
|
Chris@16
|
250 //!
|
Chris@16
|
251 //! <b>Throws</b>: Nothing.
|
Chris@16
|
252 //!
|
Chris@16
|
253 //! <b>Rationale</b>: Providing a copy-constructor
|
Chris@16
|
254 //! makes classes using the hook STL-compliant without forcing the
|
Chris@16
|
255 //! user to do some additional work. \c swap can be used to emulate
|
Chris@16
|
256 //! move-semantics.
|
Chris@16
|
257 unordered_set_base_hook(const unordered_set_base_hook& );
|
Chris@16
|
258
|
Chris@16
|
259 //! <b>Effects</b>: Empty function. The argument is ignored.
|
Chris@16
|
260 //!
|
Chris@16
|
261 //! <b>Throws</b>: Nothing.
|
Chris@16
|
262 //!
|
Chris@16
|
263 //! <b>Rationale</b>: Providing an assignment operator
|
Chris@16
|
264 //! makes classes using the hook STL-compliant without forcing the
|
Chris@16
|
265 //! user to do some additional work. \c swap can be used to emulate
|
Chris@16
|
266 //! move-semantics.
|
Chris@16
|
267 unordered_set_base_hook& operator=(const unordered_set_base_hook& );
|
Chris@16
|
268
|
Chris@16
|
269 //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
|
Chris@16
|
270 //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
|
Chris@16
|
271 //! object is stored in an unordered_set an assertion is raised. If link_mode is
|
Chris@16
|
272 //! \c auto_unlink and \c is_linked() is true, the node is unlinked.
|
Chris@16
|
273 //!
|
Chris@16
|
274 //! <b>Throws</b>: Nothing.
|
Chris@16
|
275 ~unordered_set_base_hook();
|
Chris@16
|
276
|
Chris@16
|
277 //! <b>Effects</b>: Swapping two nodes swaps the position of the elements
|
Chris@16
|
278 //! related to those nodes in one or two containers. That is, if the node
|
Chris@16
|
279 //! this is part of the element e1, the node x is part of the element e2
|
Chris@16
|
280 //! and both elements are included in the containers s1 and s2, then after
|
Chris@16
|
281 //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1
|
Chris@16
|
282 //! at the position of e1. If one element is not in a container, then
|
Chris@16
|
283 //! after the swap-operation the other element is not in a container.
|
Chris@16
|
284 //! Iterators to e1 and e2 related to those nodes are invalidated.
|
Chris@16
|
285 //!
|
Chris@16
|
286 //! <b>Complexity</b>: Constant
|
Chris@16
|
287 //!
|
Chris@16
|
288 //! <b>Throws</b>: Nothing.
|
Chris@16
|
289 void swap_nodes(unordered_set_base_hook &other);
|
Chris@16
|
290
|
Chris@16
|
291 //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
|
Chris@16
|
292 //!
|
Chris@16
|
293 //! <b>Returns</b>: true, if the node belongs to a container, false
|
Chris@16
|
294 //! otherwise. This function can be used to test whether \c unordered_set::iterator_to
|
Chris@16
|
295 //! will return a valid iterator.
|
Chris@16
|
296 //!
|
Chris@16
|
297 //! <b>Complexity</b>: Constant
|
Chris@16
|
298 bool is_linked() const;
|
Chris@16
|
299
|
Chris@16
|
300 //! <b>Effects</b>: Removes the node if it's inserted in a container.
|
Chris@16
|
301 //! This function is only allowed if link_mode is \c auto_unlink.
|
Chris@16
|
302 //!
|
Chris@16
|
303 //! <b>Throws</b>: Nothing.
|
Chris@16
|
304 void unlink();
|
Chris@16
|
305 #endif
|
Chris@16
|
306 };
|
Chris@16
|
307
|
Chris@16
|
308
|
Chris@16
|
309 //! Helper metafunction to define a \c unordered_set_member_hook that yields to the same
|
Chris@16
|
310 //! type when the same options (either explicitly or implicitly) are used.
|
Chris@16
|
311 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
312 template<class ...Options>
|
Chris@16
|
313 #else
|
Chris@16
|
314 template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
|
Chris@16
|
315 #endif
|
Chris@16
|
316 struct make_unordered_set_member_hook
|
Chris@16
|
317 {
|
Chris@16
|
318 /// @cond
|
Chris@16
|
319 typedef typename pack_options
|
Chris@16
|
320 < hook_defaults,
|
Chris@16
|
321 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
322 O1, O2, O3, O4
|
Chris@16
|
323 #else
|
Chris@16
|
324 Options...
|
Chris@16
|
325 #endif
|
Chris@16
|
326 >::type packed_options;
|
Chris@16
|
327
|
Chris@16
|
328 typedef generic_hook
|
Chris@101
|
329 < typename get_uset_node_algo< typename packed_options::void_pointer
|
Chris@101
|
330 , packed_options::store_hash
|
Chris@101
|
331 , packed_options::optimize_multikey
|
Chris@101
|
332 >::type
|
Chris@16
|
333 , member_tag
|
Chris@16
|
334 , packed_options::link_mode
|
Chris@16
|
335 , NoBaseHookId
|
Chris@16
|
336 > implementation_defined;
|
Chris@16
|
337 /// @endcond
|
Chris@16
|
338 typedef implementation_defined type;
|
Chris@16
|
339 };
|
Chris@16
|
340
|
Chris@16
|
341 //! Put a public data member unordered_set_member_hook in order to store objects of this class in
|
Chris@16
|
342 //! an unordered_set/unordered_multi_set. unordered_set_member_hook holds the data necessary for maintaining the
|
Chris@16
|
343 //! unordered_set/unordered_multi_set and provides an appropriate value_traits class for unordered_set/unordered_multi_set.
|
Chris@16
|
344 //!
|
Chris@16
|
345 //! The hook admits the following options: \c void_pointer<>,
|
Chris@16
|
346 //! \c link_mode<> and \c store_hash<>.
|
Chris@16
|
347 //!
|
Chris@16
|
348 //! \c void_pointer<> is the pointer type that will be used internally in the hook
|
Chris@101
|
349 //! and the container configured to use this hook.
|
Chris@16
|
350 //!
|
Chris@16
|
351 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
|
Chris@16
|
352 //! \c auto_unlink or \c safe_link).
|
Chris@16
|
353 //!
|
Chris@16
|
354 //! \c store_hash<> will tell the hook to store the hash of the value
|
Chris@16
|
355 //! to speed up rehashings.
|
Chris@16
|
356 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
357 template<class ...Options>
|
Chris@16
|
358 #else
|
Chris@16
|
359 template<class O1, class O2, class O3, class O4>
|
Chris@16
|
360 #endif
|
Chris@16
|
361 class unordered_set_member_hook
|
Chris@16
|
362 : public make_unordered_set_member_hook<
|
Chris@16
|
363 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
|
Chris@16
|
364 O1, O2, O3, O4
|
Chris@16
|
365 #else
|
Chris@16
|
366 Options...
|
Chris@16
|
367 #endif
|
Chris@16
|
368 >::type
|
Chris@16
|
369 {
|
Chris@16
|
370 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
|
Chris@16
|
371 public:
|
Chris@16
|
372 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
|
Chris@16
|
373 //! initializes the node to an unlinked state.
|
Chris@16
|
374 //!
|
Chris@16
|
375 //! <b>Throws</b>: Nothing.
|
Chris@16
|
376 unordered_set_member_hook();
|
Chris@16
|
377
|
Chris@16
|
378 //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
|
Chris@16
|
379 //! initializes the node to an unlinked state. The argument is ignored.
|
Chris@16
|
380 //!
|
Chris@16
|
381 //! <b>Throws</b>: Nothing.
|
Chris@16
|
382 //!
|
Chris@16
|
383 //! <b>Rationale</b>: Providing a copy-constructor
|
Chris@16
|
384 //! makes classes using the hook STL-compliant without forcing the
|
Chris@16
|
385 //! user to do some additional work. \c swap can be used to emulate
|
Chris@16
|
386 //! move-semantics.
|
Chris@16
|
387 unordered_set_member_hook(const unordered_set_member_hook& );
|
Chris@16
|
388
|
Chris@16
|
389 //! <b>Effects</b>: Empty function. The argument is ignored.
|
Chris@16
|
390 //!
|
Chris@16
|
391 //! <b>Throws</b>: Nothing.
|
Chris@16
|
392 //!
|
Chris@16
|
393 //! <b>Rationale</b>: Providing an assignment operator
|
Chris@16
|
394 //! makes classes using the hook STL-compliant without forcing the
|
Chris@16
|
395 //! user to do some additional work. \c swap can be used to emulate
|
Chris@16
|
396 //! move-semantics.
|
Chris@16
|
397 unordered_set_member_hook& operator=(const unordered_set_member_hook& );
|
Chris@16
|
398
|
Chris@16
|
399 //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
|
Chris@16
|
400 //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
|
Chris@16
|
401 //! object is stored in an unordered_set an assertion is raised. If link_mode is
|
Chris@16
|
402 //! \c auto_unlink and \c is_linked() is true, the node is unlinked.
|
Chris@16
|
403 //!
|
Chris@16
|
404 //! <b>Throws</b>: Nothing.
|
Chris@16
|
405 ~unordered_set_member_hook();
|
Chris@16
|
406
|
Chris@16
|
407 //! <b>Effects</b>: Swapping two nodes swaps the position of the elements
|
Chris@16
|
408 //! related to those nodes in one or two containers. That is, if the node
|
Chris@16
|
409 //! this is part of the element e1, the node x is part of the element e2
|
Chris@16
|
410 //! and both elements are included in the containers s1 and s2, then after
|
Chris@16
|
411 //! the swap-operation e1 is in s2 at the position of e2 and e2 is in s1
|
Chris@16
|
412 //! at the position of e1. If one element is not in a container, then
|
Chris@16
|
413 //! after the swap-operation the other element is not in a container.
|
Chris@16
|
414 //! Iterators to e1 and e2 related to those nodes are invalidated.
|
Chris@16
|
415 //!
|
Chris@16
|
416 //! <b>Complexity</b>: Constant
|
Chris@16
|
417 //!
|
Chris@16
|
418 //! <b>Throws</b>: Nothing.
|
Chris@16
|
419 void swap_nodes(unordered_set_member_hook &other);
|
Chris@16
|
420
|
Chris@16
|
421 //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
|
Chris@16
|
422 //!
|
Chris@16
|
423 //! <b>Returns</b>: true, if the node belongs to a container, false
|
Chris@16
|
424 //! otherwise. This function can be used to test whether \c unordered_set::iterator_to
|
Chris@16
|
425 //! will return a valid iterator.
|
Chris@16
|
426 //!
|
Chris@16
|
427 //! <b>Complexity</b>: Constant
|
Chris@16
|
428 bool is_linked() const;
|
Chris@16
|
429
|
Chris@16
|
430 //! <b>Effects</b>: Removes the node if it's inserted in a container.
|
Chris@16
|
431 //! This function is only allowed if link_mode is \c auto_unlink.
|
Chris@16
|
432 //!
|
Chris@16
|
433 //! <b>Throws</b>: Nothing.
|
Chris@16
|
434 void unlink();
|
Chris@16
|
435 #endif
|
Chris@16
|
436 };
|
Chris@16
|
437
|
Chris@16
|
438 } //namespace intrusive
|
Chris@16
|
439 } //namespace boost
|
Chris@16
|
440
|
Chris@16
|
441 #include <boost/intrusive/detail/config_end.hpp>
|
Chris@16
|
442
|
Chris@16
|
443 #endif //BOOST_INTRUSIVE_UNORDERED_SET_HOOK_HPP
|