Home | Libraries | People | FAQ | More |
boost::intrusive::unordered_set_base_hook
// In header: <boost/intrusive/unordered_set_hook.hpp> template<class ... Options> class unordered_set_base_hook : public make_unordered_set_base_hook::type< O1, O2, O3, O4 > { public: // construct/copy/destruct unordered_set_base_hook(); unordered_set_base_hook(const unordered_set_base_hook &); unordered_set_base_hook & operator=(const unordered_set_base_hook &); ~unordered_set_base_hook(); // public member functions void swap_nodes(unordered_set_base_hook &); bool is_linked() const; void unlink(); };
Derive a class from unordered_set_base_hook in order to store objects in in an unordered_set/unordered_multi_set. unordered_set_base_hook holds the data necessary to maintain the unordered_set/unordered_multi_set and provides an appropriate value_traits class for unordered_set/unordered_multi_set.
The hook admits the following options: tag<>
, void_pointer<>
, link_mode<>
, store_hash<>
and optimize_multikey<>
.
tag<>
defines a tag to identify the node. The same tag value can be used in different classes, but if a class is derived from more than one list_base_hook
, then each list_base_hook
needs its unique tag.
void_pointer<>
is the pointer type that will be used internally in the hook and the container configured to use this hook.
link_mode<>
will specify the linking mode of the hook (normal_link
, auto_unlink
or safe_link
).
store_hash<>
will tell the hook to store the hash of the value to speed up rehashings.
optimize_multikey<>
will tell the hook to store a link to form a group with other value with the same value to speed up searches and insertions in unordered_multisets with a great number of with equivalent keys.
unordered_set_base_hook
public
construct/copy/destructunordered_set_base_hook();
Effects: If link_mode
is auto_unlink
or safe_link
initializes the node to an unlinked state.
Throws: Nothing.
unordered_set_base_hook(const unordered_set_base_hook &);
Effects: If link_mode
is auto_unlink
or safe_link
initializes the node to an unlinked state. The argument is ignored.
Throws: Nothing.
Rationale: Providing a copy-constructor makes classes using the hook STL-compliant without forcing the user to do some additional work. swap
can be used to emulate move-semantics.
unordered_set_base_hook & operator=(const unordered_set_base_hook &);
Effects: Empty function. The argument is ignored.
Throws: Nothing.
Rationale: Providing an assignment operator makes classes using the hook STL-compliant without forcing the user to do some additional work. swap
can be used to emulate move-semantics.
~unordered_set_base_hook();
Effects: If link_mode
is normal_link
, the destructor does nothing (ie. no code is generated). If link_mode
is safe_link
and the object is stored in an unordered_set
an assertion is raised. If link_mode
is auto_unlink
and is_linked()
is true, the node is unlinked.
Throws: Nothing.
unordered_set_base_hook
public member functionsvoid swap_nodes(unordered_set_base_hook & other);
Effects: Swapping two nodes swaps the position of the elements related to those nodes in one or two containers. That is, if the node this is part of the element e1, the node x is part of the element e2 and both elements are included in the containers s1 and s2, then after the swap-operation e1 is in s2 at the position of e2 and e2 is in s1 at the position of e1. If one element is not in a container, then after the swap-operation the other element is not in a container. Iterators to e1 and e2 related to those nodes are invalidated.
Complexity: Constant
Throws: Nothing.
bool is_linked() const;
Precondition: link_mode
must be safe_link
or auto_unlink
.
Returns: true, if the node belongs to a container, false otherwise. This function can be used to test whether unordered_set::iterator_to
will return a valid iterator.
Complexity: Constant
void unlink();
Effects: Removes the node if it's inserted in a container. This function is only allowed if link_mode
is auto_unlink
.
Throws: Nothing.