|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51296 - in sandbox/boost/intrusive: . detail
From: igaztanaga_at_[hidden]
Date: 2009-02-17 13:14:09
Author: igaztanaga
Date: 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
New Revision: 51296
URL: http://svn.boost.org/trac/boost/changeset/51296
Log:
Added move_semantics library
Added:
sandbox/boost/intrusive/any_hook.hpp (contents, props changed)
sandbox/boost/intrusive/avl_set.hpp (contents, props changed)
sandbox/boost/intrusive/avl_set_hook.hpp (contents, props changed)
sandbox/boost/intrusive/avltree.hpp (contents, props changed)
sandbox/boost/intrusive/avltree_algorithms.hpp (contents, props changed)
sandbox/boost/intrusive/bs_set_hook.hpp (contents, props changed)
sandbox/boost/intrusive/circular_list_algorithms.hpp (contents, props changed)
sandbox/boost/intrusive/circular_slist_algorithms.hpp (contents, props changed)
sandbox/boost/intrusive/derivation_value_traits.hpp (contents, props changed)
sandbox/boost/intrusive/detail/any_node_and_algorithms.hpp (contents, props changed)
sandbox/boost/intrusive/detail/assert.hpp (contents, props changed)
sandbox/boost/intrusive/detail/avltree_node.hpp (contents, props changed)
sandbox/boost/intrusive/detail/clear_on_destructor_base.hpp (contents, props changed)
sandbox/boost/intrusive/detail/common_slist_algorithms.hpp (contents, props changed)
sandbox/boost/intrusive/detail/config_begin.hpp (contents, props changed)
sandbox/boost/intrusive/detail/config_end.hpp (contents, props changed)
sandbox/boost/intrusive/detail/ebo_functor_holder.hpp (contents, props changed)
sandbox/boost/intrusive/detail/generic_hook.hpp (contents, props changed)
sandbox/boost/intrusive/detail/hashtable_node.hpp (contents, props changed)
Added: sandbox/boost/intrusive/any_hook.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/any_hook.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,344 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_ANY_HOOK_HPP
+#define BOOST_INTRUSIVE_ANY_HOOK_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/any_node_and_algorithms.hpp>
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/detail/generic_hook.hpp>
+#include <boost/intrusive/detail/pointer_to_other.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/// @cond
+template<class VoidPointer>
+struct get_any_node_algo
+{
+ typedef any_algorithms<VoidPointer> type;
+};
+/// @endcond
+
+//! Helper metafunction to define a \c \c any_base_hook that yields to the same
+//! type when the same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1 = none, class O2 = none, class O3 = none>
+#endif
+struct make_any_base_hook
+{
+ /// @cond
+ typedef typename pack_options
+ < hook_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef detail::generic_hook
+ < get_any_node_algo<typename packed_options::void_pointer>
+ , typename packed_options::tag
+ , packed_options::link_mode
+ , detail::AnyBaseHook
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+//! Derive a class from this hook in order to store objects of that class
+//! in an intrusive container.
+//!
+//! The hook admits the following options: \c tag<>, \c void_pointer<> and
+//! \c link_mode<>.
+//!
+//! \c 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 \c any_base_hook, then each \c any_base_hook needs its
+//! unique tag.
+//!
+//! \c link_mode<> will specify the linking mode of the hook (\c normal_link, \c safe_link).
+//!
+//! \c void_pointer<> is the pointer type that will be used internally in the hook
+//! and the the container configured to use this hook.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1, class O2, class O3>
+#endif
+class any_base_hook
+ : public make_any_base_hook
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <O1, O2, O3>
+ #else
+ <Options...>
+ #endif
+ ::type
+{
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ public:
+ //! <b>Effects</b>: If link_mode is or \c safe_link
+ //! initializes the node to an unlinked state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ any_base_hook();
+
+ //! <b>Effects</b>: If link_mode is or \c safe_link
+ //! initializes the node to an unlinked state. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing a copy-constructor
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ any_base_hook(const any_base_hook& );
+
+ //! <b>Effects</b>: Empty function. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing an assignment operator
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ any_base_hook& operator=(const any_base_hook& );
+
+ //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
+ //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
+ //! object is stored in a container an assertion is raised.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~any_base_hook();
+
+ //! <b>Precondition</b>: link_mode must be \c safe_link.
+ //!
+ //! <b>Returns</b>: true, if the node belongs to a container, false
+ //! otherwise. This function can be used to test whether \c container::iterator_to
+ //! will return a valid iterator.
+ //!
+ //! <b>Complexity</b>: Constant
+ bool is_linked() const;
+ #endif
+};
+
+//! Helper metafunction to define a \c \c any_member_hook that yields to the same
+//! type when the same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1 = none, class O2 = none, class O3 = none>
+#endif
+struct make_any_member_hook
+{
+ /// @cond
+ typedef typename pack_options
+ < hook_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef detail::generic_hook
+ < get_any_node_algo<typename packed_options::void_pointer>
+ , member_tag
+ , packed_options::link_mode
+ , detail::NoBaseHook
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+//! Store this hook in a class to be inserted
+//! in an intrusive container.
+//!
+//! The hook admits the following options: \c void_pointer<> and
+//! \c link_mode<>.
+//!
+//! \c link_mode<> will specify the linking mode of the hook (\c normal_link or \c safe_link).
+//!
+//! \c void_pointer<> is the pointer type that will be used internally in the hook
+//! and the the container configured to use this hook.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1, class O2, class O3>
+#endif
+class any_member_hook
+ : public make_any_member_hook
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <O1, O2, O3>
+ #else
+ <Options...>
+ #endif
+ ::type
+{
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ public:
+ //! <b>Effects</b>: If link_mode is or \c safe_link
+ //! initializes the node to an unlinked state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ any_member_hook();
+
+ //! <b>Effects</b>: If link_mode is or \c safe_link
+ //! initializes the node to an unlinked state. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing a copy-constructor
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ any_member_hook(const any_member_hook& );
+
+ //! <b>Effects</b>: Empty function. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing an assignment operator
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ any_member_hook& operator=(const any_member_hook& );
+
+ //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
+ //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
+ //! object is stored in a container an assertion is raised.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~any_member_hook();
+
+ //! <b>Precondition</b>: link_mode must be \c safe_link.
+ //!
+ //! <b>Returns</b>: true, if the node belongs to a container, false
+ //! otherwise. This function can be used to test whether \c container::iterator_to
+ //! will return a valid iterator.
+ //!
+ //! <b>Complexity</b>: Constant
+ bool is_linked() const;
+ #endif
+};
+
+/// @cond
+
+namespace detail{
+
+template<class ValueTraits>
+struct any_to_get_base_pointer_type
+{
+ typedef typename pointer_to_other
+ <typename ValueTraits::boost_intrusive_tags::node_traits::node_ptr, void>::type type;
+};
+
+template<class ValueTraits>
+struct any_to_get_member_pointer_type
+{
+ typedef typename pointer_to_other
+ <typename ValueTraits::node_ptr, void>::type type;
+};
+
+//!This option setter specifies that the container
+//!must use the specified base hook
+template<class BaseHook, template <class> class NodeTraits>
+struct any_to_some_hook
+{
+ typedef typename BaseHook::template pack<none>::value_traits old_value_traits;
+ template<class Base>
+ struct pack : public Base
+ {
+ struct value_traits : public old_value_traits
+ {
+ static const bool is_any_hook = true;
+ typedef typename detail::eval_if_c
+ < detail::internal_base_hook_bool_is_true<old_value_traits>::value
+ , any_to_get_base_pointer_type<old_value_traits>
+ , any_to_get_member_pointer_type<old_value_traits>
+ >::type void_pointer;
+ typedef NodeTraits<void_pointer> node_traits;
+ };
+ };
+};
+
+} //namespace detail{
+
+/// @endcond
+
+//!This option setter specifies that
+//!any hook should behave as an slist hook
+template<class BaseHook>
+struct any_to_slist_hook
+/// @cond
+ : public detail::any_to_some_hook<BaseHook, any_slist_node_traits>
+/// @endcond
+{};
+
+//!This option setter specifies that
+//!any hook should behave as an list hook
+template<class BaseHook>
+struct any_to_list_hook
+/// @cond
+ : public detail::any_to_some_hook<BaseHook, any_list_node_traits>
+/// @endcond
+{};
+
+//!This option setter specifies that
+//!any hook should behave as a set hook
+template<class BaseHook>
+struct any_to_set_hook
+/// @cond
+ : public detail::any_to_some_hook<BaseHook, any_rbtree_node_traits>
+/// @endcond
+{};
+
+//!This option setter specifies that
+//!any hook should behave as an avl_set hook
+template<class BaseHook>
+struct any_to_avl_set_hook
+/// @cond
+ : public detail::any_to_some_hook<BaseHook, any_avltree_node_traits>
+/// @endcond
+{};
+
+//!This option setter specifies that any
+//!hook should behave as a bs_set hook
+template<class BaseHook>
+struct any_to_bs_set_hook
+/// @cond
+ : public detail::any_to_some_hook<BaseHook, any_tree_node_traits>
+/// @endcond
+{};
+
+//!This option setter specifies that any hook
+//!should behave as an unordered set hook
+template<class BaseHook>
+struct any_to_unordered_set_hook
+/// @cond
+ : public detail::any_to_some_hook<BaseHook, any_unordered_node_traits>
+/// @endcond
+{};
+
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_ANY_HOOK_HPP
Added: sandbox/boost/intrusive/avl_set.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/avl_set.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,2212 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTRUSIVE_AVL_SET_HPP
+#define BOOST_INTRUSIVE_AVL_SET_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/avltree.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
+#include <iterator>
+
+namespace boost {
+namespace intrusive {
+
+//! The class template avl_set is an intrusive container, that mimics most of
+//! the interface of std::set as described in the C++ standard.
+//!
+//! The template parameter \c T is the type to be managed by the container.
+//! The user can specify additional options and if no options are provided
+//! default options are used.
+//!
+//! The container supports the following options:
+//! \c base_hook<>/member_hook<>/value_traits<>,
+//! \c constant_time_size<>, \c size_type<> and
+//! \c compare<>.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+class avl_set_impl
+{
+ /// @cond
+ typedef avltree_impl<Config> tree_type;
+ //! This class is
+ //! non-copyable
+ avl_set_impl (const avl_set_impl&);
+
+ //! This class is
+ //! non-assignable
+ avl_set_impl &operator =(const avl_set_impl&);
+
+ typedef tree_type implementation_defined;
+ /// @endcond
+
+ public:
+ typedef typename implementation_defined::value_type value_type;
+ typedef typename implementation_defined::value_traits value_traits;
+ typedef typename implementation_defined::pointer pointer;
+ typedef typename implementation_defined::const_pointer const_pointer;
+ typedef typename implementation_defined::reference reference;
+ typedef typename implementation_defined::const_reference const_reference;
+ typedef typename implementation_defined::difference_type difference_type;
+ typedef typename implementation_defined::size_type size_type;
+ typedef typename implementation_defined::value_compare value_compare;
+ typedef typename implementation_defined::key_compare key_compare;
+ typedef typename implementation_defined::iterator iterator;
+ typedef typename implementation_defined::const_iterator const_iterator;
+ typedef typename implementation_defined::reverse_iterator reverse_iterator;
+ typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
+ typedef typename implementation_defined::insert_commit_data insert_commit_data;
+ typedef typename implementation_defined::node_traits node_traits;
+ typedef typename implementation_defined::node node;
+ typedef typename implementation_defined::node_ptr node_ptr;
+ typedef typename implementation_defined::const_node_ptr const_node_ptr;
+ typedef typename implementation_defined::node_algorithms node_algorithms;
+
+ /// @cond
+ private:
+ tree_type tree_;
+ /// @endcond
+
+ public:
+ //! <b>Effects</b>: Constructs an empty avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_traits::node_traits::node
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
+ //! or the copy constructor of the value_compare object throws.
+ avl_set_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_(cmp, v_traits)
+ {}
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
+ //! cmp must be a comparison function that induces a strict weak ordering.
+ //!
+ //! <b>Effects</b>: Constructs an empty avl_set and inserts elements from
+ //! [b, e).
+ //!
+ //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using
+ //! comp and otherwise N * log N, where N is std::distance(last, first).
+ //!
+ //! <b>Throws</b>: If value_traits::node_traits::node
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
+ //! or the copy constructor/operator() of the value_compare object throws.
+ template<class Iterator>
+ avl_set_impl( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_(true, b, e, cmp, v_traits)
+ {}
+
+ //! <b>Effects</b>: Detaches all elements from this. The objects in the avl_set
+ //! are not deleted (i.e. no destructors are called).
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~avl_set_impl()
+ {}
+
+ //! <b>Effects</b>: Returns an iterator pointing to the beginning of the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator begin()
+ { return tree_.begin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator begin() const
+ { return tree_.begin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cbegin() const
+ { return tree_.cbegin(); }
+
+ //! <b>Effects</b>: Returns an iterator pointing to the end of the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator end()
+ { return tree_.end(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator end() const
+ { return tree_.end(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cend() const
+ { return tree_.cend(); }
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the
+ //! reversed avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rbegin()
+ { return tree_.rbegin(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rbegin() const
+ { return tree_.rbegin(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crbegin() const
+ { return tree_.crbegin(); }
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
+ //! of the reversed avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rend()
+ { return tree_.rend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rend() const
+ { return tree_.rend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crend() const
+ { return tree_.crend(); }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end iterator
+ //! of avl_set.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the avl_set associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static avl_set_impl &container_from_end_iterator(iterator end_iterator)
+ {
+ return *detail::parent_from_member<avl_set_impl, tree_type>
+ ( &tree_type::container_from_end_iterator(end_iterator)
+ , &avl_set_impl::tree_);
+ }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
+ //! of avl_set.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the set associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static const avl_set_impl &container_from_end_iterator(const_iterator end_iterator)
+ {
+ return *detail::parent_from_member<avl_set_impl, tree_type>
+ ( &tree_type::container_from_end_iterator(end_iterator)
+ , &avl_set_impl::tree_);
+ }
+
+ //! <b>Precondition</b>: it must be a valid iterator of set.
+ //!
+ //! <b>Effects</b>: Returns a reference to the set associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static avl_set_impl &container_from_iterator(iterator it)
+ {
+ return *detail::parent_from_member<avl_set_impl, tree_type>
+ ( &tree_type::container_from_iterator(it)
+ , &avl_set_impl::tree_);
+ }
+
+ //! <b>Precondition</b>: it must be a valid const_iterator of set.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the set associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static const avl_set_impl &container_from_iterator(const_iterator it)
+ {
+ return *detail::parent_from_member<avl_set_impl, tree_type>
+ ( &tree_type::container_from_iterator(it)
+ , &avl_set_impl::tree_);
+ }
+
+ //! <b>Effects</b>: Returns the key_compare object used by the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If key_compare copy-constructor throws.
+ key_compare key_comp() const
+ { return tree_.value_comp(); }
+
+ //! <b>Effects</b>: Returns the value_compare object used by the avl_set.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_compare copy-constructor throws.
+ value_compare value_comp() const
+ { return tree_.value_comp(); }
+
+ //! <b>Effects</b>: Returns true is the container is empty.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ bool empty() const
+ { return tree_.empty(); }
+
+ //! <b>Effects</b>: Returns the number of elements stored in the avl_set.
+ //!
+ //! <b>Complexity</b>: Linear to elements contained in *this if,
+ //! constant-time size option is enabled. Constant-time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ size_type size() const
+ { return tree_.size(); }
+
+ //! <b>Effects</b>: Swaps the contents of two sets.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If the swap() call for the comparison functor
+ //! found using ADL throws. Strong guarantee.
+ void swap(avl_set_impl& other)
+ { tree_.swap(other.tree_); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //! Cloner should yield to nodes equivalent to the original nodes.
+ //!
+ //! <b>Effects</b>: Erases all the elements from *this
+ //! calling Disposer::operator()(pointer), clones all the
+ //! elements from src calling Cloner::operator()(const_reference )
+ //! and inserts them on *this. Copies the predicate from the source container.
+ //!
+ //! If cloner throws, all cloned elements are unlinked and disposed
+ //! calling Disposer::operator()(pointer).
+ //!
+ //! <b>Complexity</b>: Linear to erased plus inserted elements.
+ //!
+ //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee.
+ template <class Cloner, class Disposer>
+ void clone_from(const avl_set_impl &src, Cloner cloner, Disposer disposer)
+ { tree_.clone_from(src.tree_, cloner, disposer); }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Treaps to inserts value into the avl_set.
+ //!
+ //! <b>Returns</b>: If the value
+ //! is not already present inserts it and returns a pair containing the
+ //! iterator to the new value and true. If there is an equivalent value
+ //! returns a pair containing an iterator to the already present value
+ //! and false.
+ //!
+ //! <b>Complexity</b>: Average complexity for insert element is at
+ //! most logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ std::pair<iterator, bool> insert(reference value)
+ { return tree_.insert_unique(value); }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Treaps to to insert x into the avl_set, using "hint"
+ //! as a hint to where it will be inserted.
+ //!
+ //! <b>Returns</b>: An iterator that points to the position where the
+ //! new element was inserted into the avl_set.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it's amortized
+ //! constant time if t is inserted immediately before hint.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ iterator insert(const_iterator hint, reference value)
+ { return tree_.insert_unique(hint, value); }
+
+ //! <b>Requires</b>: key_value_comp must be a comparison function that induces
+ //! the same strict weak ordering as value_compare. The difference is that
+ //! key_value_comp compares an arbitrary key with the contained values.
+ //!
+ //! <b>Effects</b>: Checks if a value can be inserted in the avl_set, using
+ //! a user provided key instead of the value itself.
+ //!
+ //! <b>Returns</b>: If there is an equivalent value
+ //! returns a pair containing an iterator to the already present value
+ //! and false. If the value can be inserted returns true in the returned
+ //! pair boolean and fills "commit_data" that is meant to be used with
+ //! the "insert_commit" function.
+ //!
+ //! <b>Complexity</b>: Average complexity is at most logarithmic.
+ //!
+ //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee.
+ //!
+ //! <b>Notes</b>: This function is used to improve performance when constructing
+ //! a value_type is expensive: if there is an equivalent value
+ //! the constructed object must be discarded. Many times, the part of the
+ //! node that is used to impose the order is much cheaper to construct
+ //! than the value_type and this function offers the possibility to use that
+ //! part to check if the insertion will be successful.
+ //!
+ //! If the check is successful, the user can construct the value_type and use
+ //! "insert_commit" to insert the object in constant-time. This gives a total
+ //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)).
+ //!
+ //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
+ //! objects are inserted or erased from the avl_set.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator, bool> insert_check
+ (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data)
+ { return tree_.insert_unique_check(key, key_value_comp, commit_data); }
+
+ //! <b>Requires</b>: key_value_comp must be a comparison function that induces
+ //! the same strict weak ordering as value_compare. The difference is that
+ //! key_value_comp compares an arbitrary key with the contained values.
+ //!
+ //! <b>Effects</b>: Checks if a value can be inserted in the avl_set, using
+ //! a user provided key instead of the value itself, using "hint"
+ //! as a hint to where it will be inserted.
+ //!
+ //! <b>Returns</b>: If there is an equivalent value
+ //! returns a pair containing an iterator to the already present value
+ //! and false. If the value can be inserted returns true in the returned
+ //! pair boolean and fills "commit_data" that is meant to be used with
+ //! the "insert_commit" function.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it's amortized
+ //! constant time if t is inserted immediately before hint.
+ //!
+ //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee.
+ //!
+ //! <b>Notes</b>: This function is used to improve performance when constructing
+ //! a value_type is expensive: if there is an equivalent value
+ //! the constructed object must be discarded. Many times, the part of the
+ //! constructing that is used to impose the order is much cheaper to construct
+ //! than the value_type and this function offers the possibility to use that key
+ //! to check if the insertion will be successful.
+ //!
+ //! If the check is successful, the user can construct the value_type and use
+ //! "insert_commit" to insert the object in constant-time. This can give a total
+ //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)).
+ //!
+ //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
+ //! objects are inserted or erased from the avl_set.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator, bool> insert_check
+ (const_iterator hint, const KeyType &key
+ ,KeyValueCompare key_value_comp, insert_commit_data &commit_data)
+ { return tree_.insert_unique_check(hint, key, key_value_comp, commit_data); }
+
+ //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
+ //! must have been obtained from a previous call to "insert_check".
+ //! No objects should have been inserted or erased from the avl_set between
+ //! the "insert_check" that filled "commit_data" and the call to "insert_commit".
+ //!
+ //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained
+ //! from the "commit_data" that a previous "insert_check" filled.
+ //!
+ //! <b>Returns</b>: An iterator to the newly inserted object.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function has only sense if a "insert_check" has been
+ //! previously executed to fill "commit_data". No value should be inserted or
+ //! erased between the "insert_check" and "insert_commit" calls.
+ iterator insert_commit(reference value, const insert_commit_data &commit_data)
+ { return tree_.insert_unique_commit(value, commit_data); }
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
+ //! of type value_type.
+ //!
+ //! <b>Effects</b>: Inserts a range into the avl_set.
+ //!
+ //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the
+ //! size of the range. However, it is linear in N if the range is already sorted
+ //! by value_comp().
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ template<class Iterator>
+ void insert(Iterator b, Iterator e)
+ { tree_.insert_unique(b, e); }
+
+ //! <b>Effects</b>: Erases the element pointed to by pos.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased element.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ iterator erase(const_iterator i)
+ { return tree_.erase(i); }
+
+ //! <b>Effects</b>: Erases the range pointed to by b end e.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase range is at most
+ //! O(log(size() + N)), where N is the number of elements in the range.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased elements.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ iterator erase(const_iterator b, const_iterator e)
+ { return tree_.erase(b, e); }
+
+ //! <b>Effects</b>: Erases all the elements with the given value.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size()) + this->count(value)).
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ size_type erase(const_reference value)
+ { return tree_.erase(value); }
+
+ //! <b>Effects</b>: Erases all the elements that compare equal with
+ //! the given key and the given comparison functor.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
+ //!
+ //! <b>Throws</b>: If the comp ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp
+ /// @cond
+ , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
+ /// @endcond
+ )
+ { return tree_.erase(key, comp); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases the element pointed to by pos.
+ //! Disposer::operator()(pointer) is called for the removed element.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase element is constant time.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased element.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator i, Disposer disposer)
+ { return tree_.erase_and_dispose(i, disposer); }
+
+ #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ template<class Disposer>
+ iterator erase_and_dispose(iterator i, Disposer disposer)
+ { return this->erase_and_dispose(const_iterator(i), disposer); }
+ #endif
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases the range pointed to by b end e.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase range is at most
+ //! O(log(size() + N)), where N is the number of elements in the range.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased elements.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
+ { return tree_.erase_and_dispose(b, e, disposer); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements with the given value.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(value)). Basic guarantee.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class Disposer>
+ size_type erase_and_dispose(const_reference value, Disposer disposer)
+ { return tree_.erase_and_dispose(value, disposer); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements with the given key.
+ //! according to the comparison functor "comp".
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
+ //!
+ //! <b>Throws</b>: If comp ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class KeyType, class KeyValueCompare, class Disposer>
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer
+ /// @cond
+ , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
+ /// @endcond
+ )
+ { return tree_.erase_and_dispose(key, comp, disposer); }
+
+ //! <b>Effects</b>: Erases all the elements of the container.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ void clear()
+ { return tree_.clear(); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements of the container.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class Disposer>
+ void clear_and_dispose(Disposer disposer)
+ { return tree_.clear_and_dispose(disposer); }
+
+ //! <b>Effects</b>: Returns the number of contained elements with the given key
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
+ //! to number of objects with the given key.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ size_type count(const_reference value) const
+ { return tree_.find(value) != end(); }
+
+ //! <b>Effects</b>: Returns the number of contained elements with the same key
+ //! compared with the given comparison functor.
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
+ //! to number of objects with the given key.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.find(key, comp) != end(); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ iterator lower_bound(const_reference value)
+ { return tree_.lower_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key according to the comparison functor is not less than k or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp)
+ { return tree_.lower_bound(key, comp); }
+
+ //! <b>Effects</b>: Returns a const iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ const_iterator lower_bound(const_reference value) const
+ { return tree_.lower_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns a const_iterator to the first element whose
+ //! key according to the comparison functor is not less than k or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.lower_bound(key, comp); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ iterator upper_bound(const_reference value)
+ { return tree_.upper_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key according to the comparison functor is greater than key or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp)
+ { return tree_.upper_bound(key, comp); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ const_iterator upper_bound(const_reference value) const
+ { return tree_.upper_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns a const_iterator to the first element whose
+ //! key according to the comparison functor is greater than key or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.upper_bound(key, comp); }
+
+ //! <b>Effects</b>: Finds an iterator to the first element whose value is
+ //! "value" or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ iterator find(const_reference value)
+ { return tree_.find(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is
+ //! "key" according to the comparison functor or end() if that element
+ //! does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType& key, KeyValueCompare comp)
+ { return tree_.find(key, comp); }
+
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose value is
+ //! "value" or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ const_iterator find(const_reference value) const
+ { return tree_.find(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
+ //! "key" according to the comparison functor or end() if that element
+ //! does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.find(key, comp); }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ std::pair<iterator,iterator> equal_range(const_reference value)
+ { return tree_.equal_range(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k
+ //! according to the comparison functor or an empty range
+ //! that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp)
+ { return tree_.equal_range(key, comp); }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ std::pair<const_iterator, const_iterator>
+ equal_range(const_reference value) const
+ { return tree_.equal_range(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k
+ //! according to the comparison functor or an empty range
+ //! that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator>
+ equal_range(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.equal_range(key, comp); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_set
+ //! that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This static function is available only if the <i>value traits</i>
+ //! is stateless.
+ static iterator s_iterator_to(reference value)
+ { return tree_type::s_iterator_to(value); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
+ //! avl_set that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This static function is available only if the <i>value traits</i>
+ //! is stateless.
+ static const_iterator s_iterator_to(const_reference value)
+ { return tree_type::s_iterator_to(value); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_set
+ //! that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator iterator_to(reference value)
+ { return tree_.iterator_to(value); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
+ //! avl_set that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator iterator_to(const_reference value) const
+ { return tree_.iterator_to(value); }
+
+ //! <b>Requires</b>: value shall not be in a avl_set/avl_multiset.
+ //!
+ //! <b>Effects</b>: init_node puts the hook of a value in a well-known default
+ //! state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Note</b>: This function puts the hook in the well-known default state
+ //! used by auto_unlink and safe hooks.
+ static void init_node(reference value)
+ { tree_type::init_node(value); }
+
+ //! <b>Effects</b>: Unlinks the leftmost node from the tree.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function breaks the tree and the tree can
+ //! only be used for more unlink_leftmost_without_rebalance calls.
+ //! This function is normally used to achieve a step by step
+ //! controlled destruction of the tree.
+ pointer unlink_leftmost_without_rebalance()
+ { return tree_.unlink_leftmost_without_rebalance(); }
+
+ //! <b>Requires</b>: replace_this must be a valid iterator of *this
+ //! and with_this must not be inserted in any tree.
+ //!
+ //! <b>Effects</b>: Replaces replace_this in its position in the
+ //! tree with with_this. The tree does not need to be rebalanced.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! with_this is not equivalent to *replace_this according to the
+ //! ordering rules. This function is faster than erasing and inserting
+ //! the node, since no rebalancing or comparison is needed.
+ void replace_node(iterator replace_this, reference with_this)
+ { tree_.replace_node(replace_this, with_this); }
+
+ /// @cond
+ friend bool operator==(const avl_set_impl &x, const avl_set_impl &y)
+ { return x.tree_ == y.tree_; }
+
+ friend bool operator<(const avl_set_impl &x, const avl_set_impl &y)
+ { return x.tree_ < y.tree_; }
+ /// @endcond
+};
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator!=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y)
+#else
+(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y)
+#endif
+{ return !(x == y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator>
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y)
+#else
+(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y)
+#endif
+{ return y < x; }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator<=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y)
+#else
+(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y)
+#endif
+{ return !(y < x); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator>=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &y)
+#else
+(const avl_set_impl<Config> &x, const avl_set_impl<Config> &y)
+#endif
+{ return !(x < y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline void swap
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(avl_set_impl<T, Options...> &x, avl_set_impl<T, Options...> &y)
+#else
+(avl_set_impl<Config> &x, avl_set_impl<Config> &y)
+#endif
+{ x.swap(y); }
+
+//! Helper metafunction to define a \c avl_set that yields to the same type when the
+//! same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class ...Options>
+#else
+template<class T, class O1 = none, class O2 = none
+ , class O3 = none, class O4 = none>
+#endif
+struct make_avl_set
+{
+ /// @cond
+ typedef avl_set_impl
+ < typename make_avltree_opt
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <T, O1, O2, O3, O4>
+ #else
+ <T, Options...>
+ #endif
+ ::type
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class O1, class O2, class O3, class O4>
+#else
+template<class T, class ...Options>
+#endif
+class avl_set
+ : public make_avl_set
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <T, O1, O2, O3, O4>
+ #else
+ <T, Options...>
+ #endif
+ ::type
+{
+ typedef typename make_avl_set
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <T, O1, O2, O3, O4>
+ #else
+ <T, Options...>
+ #endif
+ ::type Base;
+
+ public:
+ typedef typename Base::value_compare value_compare;
+ typedef typename Base::value_traits value_traits;
+ typedef typename Base::iterator iterator;
+ typedef typename Base::const_iterator const_iterator;
+
+ //Assert if passed value traits are compatible with the type
+ BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
+
+ avl_set( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(cmp, v_traits)
+ {}
+
+ template<class Iterator>
+ avl_set( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(b, e, cmp, v_traits)
+ {}
+
+ static avl_set &container_from_end_iterator(iterator end_iterator)
+ { return static_cast<avl_set &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static const avl_set &container_from_end_iterator(const_iterator end_iterator)
+ { return static_cast<const avl_set &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static avl_set &container_from_iterator(iterator end_iterator)
+ { return static_cast<avl_set &>(Base::container_from_iterator(end_iterator)); }
+
+ static const avl_set &container_from_iterator(const_iterator end_iterator)
+ { return static_cast<const avl_set &>(Base::container_from_iterator(end_iterator)); }
+};
+
+#endif
+
+//! The class template avl_multiset is an intrusive container, that mimics most of
+//! the interface of std::avl_multiset as described in the C++ standard.
+//!
+//! The template parameter \c T is the type to be managed by the container.
+//! The user can specify additional options and if no options are provided
+//! default options are used.
+//!
+//! The container supports the following options:
+//! \c base_hook<>/member_hook<>/value_traits<>,
+//! \c constant_time_size<>, \c size_type<> and
+//! \c compare<>.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+class avl_multiset_impl
+{
+ /// @cond
+ typedef avltree_impl<Config> tree_type;
+
+ //Non-copyable and non-assignable
+ avl_multiset_impl (const avl_multiset_impl&);
+ avl_multiset_impl &operator =(const avl_multiset_impl&);
+ typedef tree_type implementation_defined;
+ /// @endcond
+
+ public:
+ typedef typename implementation_defined::value_type value_type;
+ typedef typename implementation_defined::value_traits value_traits;
+ typedef typename implementation_defined::pointer pointer;
+ typedef typename implementation_defined::const_pointer const_pointer;
+ typedef typename implementation_defined::reference reference;
+ typedef typename implementation_defined::const_reference const_reference;
+ typedef typename implementation_defined::difference_type difference_type;
+ typedef typename implementation_defined::size_type size_type;
+ typedef typename implementation_defined::value_compare value_compare;
+ typedef typename implementation_defined::key_compare key_compare;
+ typedef typename implementation_defined::iterator iterator;
+ typedef typename implementation_defined::const_iterator const_iterator;
+ typedef typename implementation_defined::reverse_iterator reverse_iterator;
+ typedef typename implementation_defined::const_reverse_iterator const_reverse_iterator;
+ typedef typename implementation_defined::insert_commit_data insert_commit_data;
+ typedef typename implementation_defined::node_traits node_traits;
+ typedef typename implementation_defined::node node;
+ typedef typename implementation_defined::node_ptr node_ptr;
+ typedef typename implementation_defined::const_node_ptr const_node_ptr;
+ typedef typename implementation_defined::node_algorithms node_algorithms;
+
+ /// @cond
+ private:
+ tree_type tree_;
+ /// @endcond
+
+ public:
+ //! <b>Effects</b>: Constructs an empty avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_traits::node_traits::node
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
+ //! or the copy constructor/operator() of the value_compare object throws.
+ avl_multiset_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_(cmp, v_traits)
+ {}
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
+ //! cmp must be a comparison function that induces a strict weak ordering.
+ //!
+ //! <b>Effects</b>: Constructs an empty avl_multiset and inserts elements from
+ //! [b, e).
+ //!
+ //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using
+ //! comp and otherwise N * log N, where N is the distance between first and last
+ //!
+ //! <b>Throws</b>: If value_traits::node_traits::node
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
+ //! or the copy constructor/operator() of the value_compare object throws.
+ template<class Iterator>
+ avl_multiset_impl( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_(false, b, e, cmp, v_traits)
+ {}
+
+ //! <b>Effects</b>: Detaches all elements from this. The objects in the avl_multiset
+ //! are not deleted (i.e. no destructors are called).
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~avl_multiset_impl()
+ {}
+
+ //! <b>Effects</b>: Returns an iterator pointing to the beginning of the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator begin()
+ { return tree_.begin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator begin() const
+ { return tree_.begin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cbegin() const
+ { return tree_.cbegin(); }
+
+ //! <b>Effects</b>: Returns an iterator pointing to the end of the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator end()
+ { return tree_.end(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator end() const
+ { return tree_.end(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cend() const
+ { return tree_.cend(); }
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the
+ //! reversed avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rbegin()
+ { return tree_.rbegin(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rbegin() const
+ { return tree_.rbegin(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crbegin() const
+ { return tree_.crbegin(); }
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
+ //! of the reversed avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rend()
+ { return tree_.rend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rend() const
+ { return tree_.rend(); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crend() const
+ { return tree_.crend(); }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end iterator
+ //! of avl_multiset.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the avl_multiset associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static avl_multiset_impl &container_from_end_iterator(iterator end_iterator)
+ {
+ return *detail::parent_from_member<avl_multiset_impl, tree_type>
+ ( &tree_type::container_from_end_iterator(end_iterator)
+ , &avl_multiset_impl::tree_);
+ }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
+ //! of avl_multiset.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the avl_multiset associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static const avl_multiset_impl &container_from_end_iterator(const_iterator end_iterator)
+ {
+ return *detail::parent_from_member<avl_multiset_impl, tree_type>
+ ( &tree_type::container_from_end_iterator(end_iterator)
+ , &avl_multiset_impl::tree_);
+ }
+
+ //! <b>Precondition</b>: it must be a valid iterator of multiset.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static avl_multiset_impl &container_from_iterator(iterator it)
+ {
+ return *detail::parent_from_member<avl_multiset_impl, tree_type>
+ ( &tree_type::container_from_iterator(it)
+ , &avl_multiset_impl::tree_);
+ }
+
+ //! <b>Precondition</b>: it must be a valid const_iterator of multiset.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the multiset associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static const avl_multiset_impl &container_from_iterator(const_iterator it)
+ {
+ return *detail::parent_from_member<avl_multiset_impl, tree_type>
+ ( &tree_type::container_from_iterator(it)
+ , &avl_multiset_impl::tree_);
+ }
+
+ //! <b>Effects</b>: Returns the key_compare object used by the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If key_compare copy-constructor throws.
+ key_compare key_comp() const
+ { return tree_.value_comp(); }
+
+ //! <b>Effects</b>: Returns the value_compare object used by the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_compare copy-constructor throws.
+ value_compare value_comp() const
+ { return tree_.value_comp(); }
+
+ //! <b>Effects</b>: Returns true is the container is empty.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ bool empty() const
+ { return tree_.empty(); }
+
+ //! <b>Effects</b>: Returns the number of elements stored in the avl_multiset.
+ //!
+ //! <b>Complexity</b>: Linear to elements contained in *this if,
+ //! constant-time size option is enabled. Constant-time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ size_type size() const
+ { return tree_.size(); }
+
+ //! <b>Effects</b>: Swaps the contents of two avl_multisets.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If the swap() call for the comparison functor
+ //! found using ADL throws. Strong guarantee.
+ void swap(avl_multiset_impl& other)
+ { tree_.swap(other.tree_); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //! Cloner should yield to nodes equivalent to the original nodes.
+ //!
+ //! <b>Effects</b>: Erases all the elements from *this
+ //! calling Disposer::operator()(pointer), clones all the
+ //! elements from src calling Cloner::operator()(const_reference )
+ //! and inserts them on *this. Copies the predicate from the source container.
+ //!
+ //! If cloner throws, all cloned elements are unlinked and disposed
+ //! calling Disposer::operator()(pointer).
+ //!
+ //! <b>Complexity</b>: Linear to erased plus inserted elements.
+ //!
+ //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee.
+ template <class Cloner, class Disposer>
+ void clone_from(const avl_multiset_impl &src, Cloner cloner, Disposer disposer)
+ { tree_.clone_from(src.tree_, cloner, disposer); }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Inserts value into the avl_multiset.
+ //!
+ //! <b>Returns</b>: An iterator that points to the position where the new
+ //! element was inserted.
+ //!
+ //! <b>Complexity</b>: Average complexity for insert element is at
+ //! most logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ iterator insert(reference value)
+ { return tree_.insert_equal(value); }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Inserts x into the avl_multiset, using pos as a hint to
+ //! where it will be inserted.
+ //!
+ //! <b>Returns</b>: An iterator that points to the position where the new
+ //! element was inserted.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it is amortized
+ //! constant time if t is inserted immediately before hint.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ iterator insert(const_iterator hint, reference value)
+ { return tree_.insert_equal(hint, value); }
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
+ //! of type value_type.
+ //!
+ //! <b>Effects</b>: Inserts a range into the avl_multiset.
+ //!
+ //! <b>Returns</b>: An iterator that points to the position where the new
+ //! element was inserted.
+ //!
+ //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the
+ //! size of the range. However, it is linear in N if the range is already sorted
+ //! by value_comp().
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ template<class Iterator>
+ void insert(Iterator b, Iterator e)
+ { tree_.insert_equal(b, e); }
+
+ //! <b>Effects</b>: Erases the element pointed to by pos.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased element.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ iterator erase(const_iterator i)
+ { return tree_.erase(i); }
+
+ //! <b>Effects</b>: Erases the range pointed to by b end e.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased elements.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase range is at most
+ //! O(log(size() + N)), where N is the number of elements in the range.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ iterator erase(const_iterator b, const_iterator e)
+ { return tree_.erase(b, e); }
+
+ //! <b>Effects</b>: Erases all the elements with the given value.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(value)).
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ size_type erase(const_reference value)
+ { return tree_.erase(value); }
+
+ //! <b>Effects</b>: Erases all the elements that compare equal with
+ //! the given key and the given comparison functor.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
+ //!
+ //! <b>Throws</b>: If comp ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp
+ /// @cond
+ , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
+ /// @endcond
+ )
+ { return tree_.erase(key, comp); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased element.
+ //!
+ //! <b>Effects</b>: Erases the element pointed to by pos.
+ //! Disposer::operator()(pointer) is called for the removed element.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase element is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator i, Disposer disposer)
+ { return tree_.erase_and_dispose(i, disposer); }
+
+ #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ template<class Disposer>
+ iterator erase_and_dispose(iterator i, Disposer disposer)
+ { return this->erase_and_dispose(const_iterator(i), disposer); }
+ #endif
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Returns</b>: An iterator to the element after the erased elements.
+ //!
+ //! <b>Effects</b>: Erases the range pointed to by b end e.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase range is at most
+ //! O(log(size() + N)), where N is the number of elements in the range.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
+ { return tree_.erase_and_dispose(b, e, disposer); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements with the given value.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(value)).
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class Disposer>
+ size_type erase_and_dispose(const_reference value, Disposer disposer)
+ { return tree_.erase_and_dispose(value, disposer); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements with the given key.
+ //! according to the comparison functor "comp".
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + this->count(key, comp)).
+ //!
+ //! <b>Throws</b>: If comp ordering function throws. Basic guarantee.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class KeyType, class KeyValueCompare, class Disposer>
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer
+ /// @cond
+ , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
+ /// @endcond
+ )
+ { return tree_.erase_and_dispose(key, comp, disposer); }
+
+ //! <b>Effects</b>: Erases all the elements of the container.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ void clear()
+ { return tree_.clear(); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements of the container.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class Disposer>
+ void clear_and_dispose(Disposer disposer)
+ { return tree_.clear_and_dispose(disposer); }
+
+ //! <b>Effects</b>: Returns the number of contained elements with the given key
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
+ //! to number of objects with the given key.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ size_type count(const_reference value) const
+ { return tree_.count(value); }
+
+ //! <b>Effects</b>: Returns the number of contained elements with the same key
+ //! compared with the given comparison functor.
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
+ //! to number of objects with the given key.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.count(key, comp); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ iterator lower_bound(const_reference value)
+ { return tree_.lower_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key according to the comparison functor is not less than k or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp)
+ { return tree_.lower_bound(key, comp); }
+
+ //! <b>Effects</b>: Returns a const iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ const_iterator lower_bound(const_reference value) const
+ { return tree_.lower_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns a const_iterator to the first element whose
+ //! key according to the comparison functor is not less than k or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.lower_bound(key, comp); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ iterator upper_bound(const_reference value)
+ { return tree_.upper_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key according to the comparison functor is greater than key or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp)
+ { return tree_.upper_bound(key, comp); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ const_iterator upper_bound(const_reference value) const
+ { return tree_.upper_bound(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Returns a const_iterator to the first element whose
+ //! key according to the comparison functor is greater than key or
+ //! end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.upper_bound(key, comp); }
+
+ //! <b>Effects</b>: Finds an iterator to the first element whose value is
+ //! "value" or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ iterator find(const_reference value)
+ { return tree_.find(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is
+ //! "key" according to the comparison functor or end() if that element
+ //! does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType& key, KeyValueCompare comp)
+ { return tree_.find(key, comp); }
+
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose value is
+ //! "value" or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ const_iterator find(const_reference value) const
+ { return tree_.find(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
+ //! "key" according to the comparison functor or end() if that element
+ //! does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.find(key, comp); }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ std::pair<iterator,iterator> equal_range(const_reference value)
+ { return tree_.equal_range(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k
+ //! according to the comparison functor or an empty range
+ //! that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp)
+ { return tree_.equal_range(key, comp); }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws.
+ std::pair<const_iterator, const_iterator>
+ equal_range(const_reference value) const
+ { return tree_.equal_range(value); }
+
+ //! <b>Requires</b>: comp must imply the same element order as
+ //! value_compare. Usually key is the part of the value_type
+ //! that is used in the ordering functor.
+ //!
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k
+ //! according to the comparison functor or an empty range
+ //! that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If comp ordering function throws.
+ //!
+ //! <b>Note</b>: This function is used when constructing a value_type
+ //! is expensive and the value_type can be compared with a cheaper
+ //! key type. Usually this key is part of the value_type.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator>
+ equal_range(const KeyType& key, KeyValueCompare comp) const
+ { return tree_.equal_range(key, comp); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_multiset
+ //! that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This static function is available only if the <i>value traits</i>
+ //! is stateless.
+ static iterator s_iterator_to(reference value)
+ { return tree_type::s_iterator_to(value); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
+ //! avl_multiset that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This static function is available only if the <i>value traits</i>
+ //! is stateless.
+ static const_iterator s_iterator_to(const_reference value)
+ { return tree_type::s_iterator_to(value); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the avl_multiset
+ //! that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator iterator_to(reference value)
+ { return tree_.iterator_to(value); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a avl_multiset of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
+ //! avl_multiset that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator iterator_to(const_reference value) const
+ { return tree_.iterator_to(value); }
+
+ //! <b>Requires</b>: value shall not be in a avl_multiset/avl_multiset.
+ //!
+ //! <b>Effects</b>: init_node puts the hook of a value in a well-known default
+ //! state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Note</b>: This function puts the hook in the well-known default state
+ //! used by auto_unlink and safe hooks.
+ static void init_node(reference value)
+ { tree_type::init_node(value); }
+
+ //! <b>Effects</b>: Unlinks the leftmost node from the tree.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function breaks the tree and the tree can
+ //! only be used for more unlink_leftmost_without_rebalance calls.
+ //! This function is normally used to achieve a step by step
+ //! controlled destruction of the tree.
+ pointer unlink_leftmost_without_rebalance()
+ { return tree_.unlink_leftmost_without_rebalance(); }
+
+ //! <b>Requires</b>: replace_this must be a valid iterator of *this
+ //! and with_this must not be inserted in any tree.
+ //!
+ //! <b>Effects</b>: Replaces replace_this in its position in the
+ //! tree with with_this. The tree does not need to be rebalanced.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! with_this is not equivalent to *replace_this according to the
+ //! ordering rules. This function is faster than erasing and inserting
+ //! the node, since no rebalancing or comparison is needed.
+ void replace_node(iterator replace_this, reference with_this)
+ { tree_.replace_node(replace_this, with_this); }
+
+ /// @cond
+ friend bool operator==(const avl_multiset_impl &x, const avl_multiset_impl &y)
+ { return x.tree_ == y.tree_; }
+
+ friend bool operator<(const avl_multiset_impl &x, const avl_multiset_impl &y)
+ { return x.tree_ < y.tree_; }
+ /// @endcond
+};
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator!=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y)
+#else
+(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y)
+#endif
+{ return !(x == y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator>
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y)
+#else
+(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y)
+#endif
+{ return y < x; }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator<=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y)
+#else
+(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y)
+#endif
+{ return !(y < x); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator>=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &y)
+#else
+(const avl_multiset_impl<Config> &x, const avl_multiset_impl<Config> &y)
+#endif
+{ return !(x < y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline void swap
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(avl_multiset_impl<T, Options...> &x, avl_multiset_impl<T, Options...> &y)
+#else
+(avl_multiset_impl<Config> &x, avl_multiset_impl<Config> &y)
+#endif
+{ x.swap(y); }
+
+//! Helper metafunction to define a \c avl_multiset that yields to the same type when the
+//! same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class ...Options>
+#else
+template<class T, class O1 = none, class O2 = none
+ , class O3 = none, class O4 = none>
+#endif
+struct make_avl_multiset
+{
+ /// @cond
+ typedef avl_multiset_impl
+ < typename make_avltree_opt
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <T, O1, O2, O3, O4>
+ #else
+ <T, Options...>
+ #endif
+ ::type
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class O1, class O2, class O3, class O4>
+#else
+template<class T, class ...Options>
+#endif
+class avl_multiset
+ : public make_avl_multiset<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
+{
+ typedef typename make_avl_multiset
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <T, O1, O2, O3, O4>
+ #else
+ <T, Options...>
+ #endif
+ ::type Base;
+
+ public:
+ typedef typename Base::value_compare value_compare;
+ typedef typename Base::value_traits value_traits;
+ typedef typename Base::iterator iterator;
+ typedef typename Base::const_iterator const_iterator;
+
+ //Assert if passed value traits are compatible with the type
+ BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
+
+ avl_multiset( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(cmp, v_traits)
+ {}
+
+ template<class Iterator>
+ avl_multiset( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(b, e, cmp, v_traits)
+ {}
+
+ static avl_multiset &container_from_end_iterator(iterator end_iterator)
+ { return static_cast<avl_multiset &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static const avl_multiset &container_from_end_iterator(const_iterator end_iterator)
+ { return static_cast<const avl_multiset &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static avl_multiset &container_from_iterator(iterator end_iterator)
+ { return static_cast<avl_multiset &>(Base::container_from_iterator(end_iterator)); }
+
+ static const avl_multiset &container_from_iterator(const_iterator end_iterator)
+ { return static_cast<const avl_multiset &>(Base::container_from_iterator(end_iterator)); }
+};
+
+#endif
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_AVL_SET_HPP
Added: sandbox/boost/intrusive/avl_set_hook.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/avl_set_hook.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,295 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_AVL_SET_HOOK_HPP
+#define BOOST_INTRUSIVE_AVL_SET_HOOK_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/avltree_node.hpp>
+#include <boost/intrusive/avltree_algorithms.hpp>
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/detail/generic_hook.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/// @cond
+template<class VoidPointer, bool OptimizeSize = false>
+struct get_avl_set_node_algo
+{
+ typedef avltree_algorithms<avltree_node_traits<VoidPointer, OptimizeSize> > type;
+};
+/// @endcond
+
+//! Helper metafunction to define a \c avl_set_base_hook that yields to the same
+//! type when the same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1 = none, class O2 = none, class O3 = none, class O4 = none>
+#endif
+struct make_avl_set_base_hook
+{
+ /// @cond
+ typedef typename pack_options
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <hook_defaults, O1, O2, O3, O4>
+ #else
+ <hook_defaults, Options...>
+ #endif
+ ::type packed_options;
+
+ typedef detail::generic_hook
+ < get_avl_set_node_algo<typename packed_options::void_pointer
+ ,packed_options::optimize_size>
+ , typename packed_options::tag
+ , packed_options::link_mode
+ , detail::AvlSetBaseHook
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+//! Derive a class from avl_set_base_hook in order to store objects in
+//! in an avl_set/avl_multiset. avl_set_base_hook holds the data necessary to maintain
+//! the avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset.
+//!
+//! The hook admits the following options: \c tag<>, \c void_pointer<>,
+//! \c link_mode<> and \c optimize_size<>.
+//!
+//! \c 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 \c list_base_hook, then each \c list_base_hook needs its
+//! unique tag.
+//!
+//! \c void_pointer<> is the pointer type that will be used internally in the hook
+//! and the the container configured to use this hook.
+//!
+//! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
+//! \c auto_unlink or \c safe_link).
+//!
+//! \c optimize_size<> will tell the hook to optimize the hook for size instead
+//! of speed.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1, class O2, class O3, class O4>
+#endif
+class avl_set_base_hook
+ : public make_avl_set_base_hook
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <O1, O2, O3, O4>
+ #else
+ <Options...>
+ #endif
+ ::type
+{
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ avl_set_base_hook();
+
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing a copy-constructor
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ avl_set_base_hook(const avl_set_base_hook& );
+
+ //! <b>Effects</b>: Empty function. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing an assignment operator
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ avl_set_base_hook& operator=(const avl_set_base_hook& );
+
+ //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
+ //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
+ //! object is stored in a set an assertion is raised. If link_mode is
+ //! \c auto_unlink and \c is_linked() is true, the node is unlinked.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~avl_set_base_hook();
+
+ //! <b>Effects</b>: 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.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ void swap_nodes(avl_set_base_hook &other);
+
+ //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
+ //!
+ //! <b>Returns</b>: true, if the node belongs to a container, false
+ //! otherwise. This function can be used to test whether \c set::iterator_to
+ //! will return a valid iterator.
+ //!
+ //! <b>Complexity</b>: Constant
+ bool is_linked() const;
+
+ //! <b>Effects</b>: Removes the node if it's inserted in a container.
+ //! This function is only allowed if link_mode is \c auto_unlink.
+ //!
+ //! <b>Throws</b>: Nothing.
+ void unlink();
+ #endif
+};
+
+//! Helper metafunction to define a \c avl_set_member_hook that yields to the same
+//! type when the same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1 = none, class O2 = none, class O3 = none, class O4 = none>
+#endif
+struct make_avl_set_member_hook
+{
+ /// @cond
+ typedef typename pack_options
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <hook_defaults, O1, O2, O3, O4>
+ #else
+ <hook_defaults, Options...>
+ #endif
+ ::type packed_options;
+
+ typedef detail::generic_hook
+ < get_avl_set_node_algo<typename packed_options::void_pointer
+ ,packed_options::optimize_size>
+ , member_tag
+ , packed_options::link_mode
+ , detail::NoBaseHook
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+//! Put a public data member avl_set_member_hook in order to store objects of this class in
+//! an avl_set/avl_multiset. avl_set_member_hook holds the data necessary for maintaining the
+//! avl_set/avl_multiset and provides an appropriate value_traits class for avl_set/avl_multiset.
+//!
+//! The hook admits the following options: \c void_pointer<>,
+//! \c link_mode<> and \c optimize_size<>.
+//!
+//! \c void_pointer<> is the pointer type that will be used internally in the hook
+//! and the the container configured to use this hook.
+//!
+//! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
+//! \c auto_unlink or \c safe_link).
+//!
+//! \c optimize_size<> will tell the hook to optimize the hook for size instead
+//! of speed.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1, class O2, class O3, class O4>
+#endif
+class avl_set_member_hook
+ : public make_avl_set_member_hook
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <O1, O2, O3, O4>
+ #else
+ <Options...>
+ #endif
+ ::type
+{
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ avl_set_member_hook();
+
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing a copy-constructor
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ avl_set_member_hook(const avl_set_member_hook& );
+
+ //! <b>Effects</b>: Empty function. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing an assignment operator
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ avl_set_member_hook& operator=(const avl_set_member_hook& );
+
+ //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
+ //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
+ //! object is stored in a set an assertion is raised. If link_mode is
+ //! \c auto_unlink and \c is_linked() is true, the node is unlinked.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~avl_set_member_hook();
+
+ //! <b>Effects</b>: 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.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ void swap_nodes(avl_set_member_hook &other);
+
+ //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
+ //!
+ //! <b>Returns</b>: true, if the node belongs to a container, false
+ //! otherwise. This function can be used to test whether \c set::iterator_to
+ //! will return a valid iterator.
+ //!
+ //! <b>Complexity</b>: Constant
+ bool is_linked() const;
+
+ //! <b>Effects</b>: Removes the node if it's inserted in a container.
+ //! This function is only allowed if link_mode is \c auto_unlink.
+ //!
+ //! <b>Throws</b>: Nothing.
+ void unlink();
+ #endif
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_AVL_SET_HOOK_HPP
Added: sandbox/boost/intrusive/avltree.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/avltree.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,1577 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTRUSIVE_AVLTREE_HPP
+#define BOOST_INTRUSIVE_AVLTREE_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <algorithm>
+#include <cstddef>
+#include <functional>
+#include <iterator>
+#include <utility>
+
+#include <boost/intrusive/detail/assert.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/avl_set_hook.hpp>
+#include <boost/intrusive/detail/avltree_node.hpp>
+#include <boost/intrusive/detail/tree_node.hpp>
+#include <boost/intrusive/detail/ebo_functor_holder.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
+#include <boost/intrusive/detail/pointer_to_other.hpp>
+#include <boost/intrusive/detail/clear_on_destructor_base.hpp>
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/avltree_algorithms.hpp>
+#include <boost/intrusive/link_mode.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/// @cond
+
+template <class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
+struct avl_setopt
+{
+ typedef ValueTraits value_traits;
+ typedef Compare compare;
+ typedef SizeType size_type;
+ static const bool constant_time_size = ConstantTimeSize;
+};
+
+template <class T>
+struct avl_set_defaults
+ : pack_options
+ < none
+ , base_hook<detail::default_avl_set_hook>
+ , constant_time_size<true>
+ , size_type<std::size_t>
+ , compare<std::less<T> >
+ >::type
+{};
+
+/// @endcond
+
+//! The class template avltree is an intrusive AVL tree container, that
+//! is used to construct intrusive avl_set and avl_multiset containers.
+//! The no-throw guarantee holds only, if the value_compare object
+//! doesn't throw.
+//!
+//! The template parameter \c T is the type to be managed by the container.
+//! The user can specify additional options and if no options are provided
+//! default options are used.
+//!
+//! The container supports the following options:
+//! \c base_hook<>/member_hook<>/value_traits<>,
+//! \c constant_time_size<>, \c size_type<> and
+//! \c compare<>.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+class avltree_impl
+ : private detail::clear_on_destructor_base<avltree_impl<Config> >
+{
+ template<class C> friend class detail::clear_on_destructor_base;
+ public:
+ typedef typename Config::value_traits value_traits;
+ /// @cond
+ static const bool external_value_traits =
+ detail::external_value_traits_is_true<value_traits>::value;
+ typedef typename detail::eval_if_c
+ < external_value_traits
+ , detail::eval_value_traits<value_traits>
+ , detail::identity<value_traits>
+ >::type real_value_traits;
+ /// @endcond
+ typedef typename real_value_traits::pointer pointer;
+ typedef typename real_value_traits::const_pointer const_pointer;
+ typedef typename std::iterator_traits<pointer>::value_type value_type;
+ typedef value_type key_type;
+ typedef typename std::iterator_traits<pointer>::reference reference;
+ typedef typename std::iterator_traits<const_pointer>::reference const_reference;
+ typedef typename std::iterator_traits<pointer>::difference_type difference_type;
+ typedef typename Config::size_type size_type;
+ typedef typename Config::compare value_compare;
+ typedef value_compare key_compare;
+ typedef tree_iterator<avltree_impl, false> iterator;
+ typedef tree_iterator<avltree_impl, true> const_iterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename node_traits::node node;
+ typedef typename boost::pointer_to_other
+ <pointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <node_ptr, const node>::type const_node_ptr;
+ typedef avltree_algorithms<node_traits> node_algorithms;
+
+ static const bool constant_time_size = Config::constant_time_size;
+ static const bool stateful_value_traits = detail::store_cont_ptr_on_it<avltree_impl>::value;
+
+ /// @cond
+ private:
+ typedef detail::size_holder<constant_time_size, size_type> size_traits;
+
+ //noncopyable
+ avltree_impl (const avltree_impl&);
+ avltree_impl operator =(const avltree_impl&);
+
+ enum { safemode_or_autounlink =
+ (int)real_value_traits::link_mode == (int)auto_unlink ||
+ (int)real_value_traits::link_mode == (int)safe_link };
+
+ //Constant-time size is incompatible with auto-unlink hooks!
+ BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+
+ struct header_plus_size : public size_traits
+ { node header_; };
+
+ struct node_plus_pred_t : public detail::ebo_functor_holder<value_compare>
+ {
+ node_plus_pred_t(const value_compare &comp)
+ : detail::ebo_functor_holder<value_compare>(comp)
+ {}
+ header_plus_size header_plus_size_;
+ };
+
+ struct data_t : public avltree_impl::value_traits
+ {
+ typedef typename avltree_impl::value_traits value_traits;
+ data_t(const value_compare & comp, const value_traits &val_traits)
+ : value_traits(val_traits), node_plus_pred_(comp)
+ {}
+ node_plus_pred_t node_plus_pred_;
+ } data_;
+
+ const value_compare &priv_comp() const
+ { return data_.node_plus_pred_.get(); }
+
+ value_compare &priv_comp()
+ { return data_.node_plus_pred_.get(); }
+
+ const node &priv_header() const
+ { return data_.node_plus_pred_.header_plus_size_.header_; }
+
+ node &priv_header()
+ { return data_.node_plus_pred_.header_plus_size_.header_; }
+
+ static node_ptr uncast(const_node_ptr ptr)
+ {
+ return node_ptr(const_cast<node*>(detail::get_pointer(ptr)));
+ }
+
+ size_traits &priv_size_traits()
+ { return data_.node_plus_pred_.header_plus_size_; }
+
+ const size_traits &priv_size_traits() const
+ { return data_.node_plus_pred_.header_plus_size_; }
+
+ const real_value_traits &get_real_value_traits(detail::bool_<false>) const
+ { return data_; }
+
+ const real_value_traits &get_real_value_traits(detail::bool_<true>) const
+ { return data_.get_value_traits(*this); }
+
+ real_value_traits &get_real_value_traits(detail::bool_<false>)
+ { return data_; }
+
+ real_value_traits &get_real_value_traits(detail::bool_<true>)
+ { return data_.get_value_traits(*this); }
+
+ /// @endcond
+
+ public:
+
+ const real_value_traits &get_real_value_traits() const
+ { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+
+ real_value_traits &get_real_value_traits()
+ { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+
+ typedef typename node_algorithms::insert_commit_data insert_commit_data;
+
+ //! <b>Effects</b>: Constructs an empty tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_traits::node_traits::node
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
+ //! or the copy constructor of the value_compare object throws. Basic guarantee.
+ avltree_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : data_(cmp, v_traits)
+ {
+ node_algorithms::init_header(&priv_header());
+ this->priv_size_traits().set_size(size_type(0));
+ }
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue of type value_type.
+ //! cmp must be a comparison function that induces a strict weak ordering.
+ //!
+ //! <b>Effects</b>: Constructs an empty tree and inserts elements from
+ //! [b, e).
+ //!
+ //! <b>Complexity</b>: Linear in N if [b, e) is already sorted using
+ //! comp and otherwise N * log N, where N is the distance between first and last.
+ //!
+ //! <b>Throws</b>: If value_traits::node_traits::node
+ //! constructor throws (this does not happen with predefined Boost.Intrusive hooks)
+ //! or the copy constructor/operator() of the value_compare object throws. Basic guarantee.
+ template<class Iterator>
+ avltree_impl( bool unique, Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : data_(cmp, v_traits)
+ {
+ node_algorithms::init_header(&priv_header());
+ this->priv_size_traits().set_size(size_type(0));
+ if(unique)
+ this->insert_unique(b, e);
+ else
+ this->insert_equal(b, e);
+ }
+
+ //! <b>Effects</b>: Detaches all elements from this. The objects in the set
+ //! are not deleted (i.e. no destructors are called), but the nodes according to
+ //! the value_traits template parameter are reinitialized and thus can be reused.
+ //!
+ //! <b>Complexity</b>: Linear to elements contained in *this.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~avltree_impl()
+ {}
+
+ //! <b>Effects</b>: Returns an iterator pointing to the beginning of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator begin()
+ { return iterator (node_traits::get_left(node_ptr(&priv_header())), this); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator begin() const
+ { return cbegin(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cbegin() const
+ { return const_iterator (node_traits::get_left(const_node_ptr(&priv_header())), this); }
+
+ //! <b>Effects</b>: Returns an iterator pointing to the end of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator end()
+ { return iterator (node_ptr(&priv_header()), this); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator end() const
+ { return cend(); }
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cend() const
+ { return const_iterator (uncast(const_node_ptr(&priv_header())), this); }
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the
+ //! reversed tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rbegin()
+ { return reverse_iterator(end()); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rbegin() const
+ { return const_reverse_iterator(end()); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crbegin() const
+ { return const_reverse_iterator(end()); }
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
+ //! of the reversed tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rend()
+ { return reverse_iterator(begin()); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rend() const
+ { return const_reverse_iterator(begin()); }
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crend() const
+ { return const_reverse_iterator(begin()); }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end iterator
+ //! of avltree.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the avltree associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static avltree_impl &container_from_end_iterator(iterator end_iterator)
+ { return priv_container_from_end_iterator(end_iterator); }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
+ //! of avltree.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the avltree associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static const avltree_impl &container_from_end_iterator(const_iterator end_iterator)
+ { return priv_container_from_end_iterator(end_iterator); }
+
+ //! <b>Precondition</b>: it must be a valid iterator
+ //! of rbtree.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static avltree_impl &container_from_iterator(iterator it)
+ { return priv_container_from_iterator(it); }
+
+ //! <b>Precondition</b>: it must be a valid end const_iterator
+ //! of rbtree.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the tree associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static const avltree_impl &container_from_iterator(const_iterator it)
+ { return priv_container_from_iterator(it); }
+
+ //! <b>Effects</b>: Returns the value_compare object used by the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_compare copy-constructor throws.
+ value_compare value_comp() const
+ { return priv_comp(); }
+
+ //! <b>Effects</b>: Returns true if the container is empty.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ bool empty() const
+ { return node_algorithms::unique(const_node_ptr(&priv_header())); }
+
+ //! <b>Effects</b>: Returns the number of elements stored in the tree.
+ //!
+ //! <b>Complexity</b>: Linear to elements contained in *this
+ //! if constant-time size option is disabled. Constant time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ size_type size() const
+ {
+ if(constant_time_size)
+ return this->priv_size_traits().get_size();
+ else{
+ return (size_type)node_algorithms::size(const_node_ptr(&priv_header()));
+ }
+ }
+
+ //! <b>Effects</b>: Swaps the contents of two avltrees.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If the comparison functor's swap call throws.
+ void swap(avltree_impl& other)
+ {
+ //This can throw
+ using std::swap;
+ swap(priv_comp(), priv_comp());
+ //These can't throw
+ node_algorithms::swap_tree(node_ptr(&priv_header()), node_ptr(&other.priv_header()));
+ if(constant_time_size){
+ size_type backup = this->priv_size_traits().get_size();
+ this->priv_size_traits().set_size(other.priv_size_traits().get_size());
+ other.priv_size_traits().set_size(backup);
+ }
+ }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Inserts value into the tree before the upper bound.
+ //!
+ //! <b>Complexity</b>: Average complexity for insert element is at
+ //! most logarithmic.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ iterator insert_equal(reference value)
+ {
+ detail::key_nodeptr_comp<value_compare, avltree_impl>
+ key_node_comp(priv_comp(), this);
+ node_ptr to_insert(get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ this->priv_size_traits().increment();
+ return iterator(node_algorithms::insert_equal_upper_bound
+ (node_ptr(&priv_header()), to_insert, key_node_comp), this);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue, and "hint" must be
+ //! a valid iterator.
+ //!
+ //! <b>Effects</b>: Inserts x into the tree, using "hint" as a hint to
+ //! where it will be inserted. If "hint" is the upper_bound
+ //! the insertion takes constant time (two comparisons in the worst case)
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it is amortized
+ //! constant time if t is inserted immediately before hint.
+ //!
+ //! <b>Throws</b>: If the internal value_compare ordering function throws. Strong guarantee.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ iterator insert_equal(const_iterator hint, reference value)
+ {
+ detail::key_nodeptr_comp<value_compare, avltree_impl>
+ key_node_comp(priv_comp(), this);
+ node_ptr to_insert(get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ this->priv_size_traits().increment();
+ return iterator(node_algorithms::insert_equal
+ (node_ptr(&priv_header()), hint.pointed_node(), to_insert, key_node_comp), this);
+ }
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
+ //! of type value_type.
+ //!
+ //! <b>Effects</b>: Inserts a each element of a range into the tree
+ //! before the upper bound of the key of each element.
+ //!
+ //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the
+ //! size of the range. However, it is linear in N if the range is already sorted
+ //! by value_comp().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ template<class Iterator>
+ void insert_equal(Iterator b, Iterator e)
+ {
+ iterator end(this->end());
+ for (; b != e; ++b)
+ this->insert_equal(end, *b);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Inserts value into the tree if the value
+ //! is not already present.
+ //!
+ //! <b>Complexity</b>: Average complexity for insert element is at
+ //! most logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ std::pair<iterator, bool> insert_unique(reference value)
+ {
+ insert_commit_data commit_data;
+ std::pair<iterator, bool> ret = insert_unique_check(value, priv_comp(), commit_data);
+ if(!ret.second)
+ return ret;
+ return std::pair<iterator, bool> (insert_unique_commit(value, commit_data), true);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue, and "hint" must be
+ //! a valid iterator
+ //!
+ //! <b>Effects</b>: Tries to insert x into the tree, using "hint" as a hint
+ //! to where it will be inserted.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it is amortized
+ //! constant time (two comparisons in the worst case)
+ //! if t is inserted immediately before hint.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ iterator insert_unique(const_iterator hint, reference value)
+ {
+ insert_commit_data commit_data;
+ std::pair<iterator, bool> ret = insert_unique_check(hint, value, priv_comp(), commit_data);
+ if(!ret.second)
+ return ret.first;
+ return insert_unique_commit(value, commit_data);
+ }
+
+ //! <b>Requires</b>: Dereferencing iterator must yield an lvalue
+ //! of type value_type.
+ //!
+ //! <b>Effects</b>: Tries to insert each element of a range into the tree.
+ //!
+ //! <b>Complexity</b>: Insert range is in general O(N * log(N)), where N is the
+ //! size of the range. However, it is linear in N if the range is already sorted
+ //! by value_comp().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Does not affect the validity of iterators and references.
+ //! No copy-constructors are called.
+ template<class Iterator>
+ void insert_unique(Iterator b, Iterator e)
+ {
+ if(this->empty()){
+ iterator end(this->end());
+ for (; b != e; ++b)
+ this->insert_unique(end, *b);
+ }
+ else{
+ for (; b != e; ++b)
+ this->insert_unique(*b);
+ }
+ }
+
+ //! <b>Requires</b>: key_value_comp must be a comparison function that induces
+ //! the same strict weak ordering as value_compare. The difference is that
+ //! key_value_comp compares an arbitrary key with the contained values.
+ //!
+ //! <b>Effects</b>: Checks if a value can be inserted in the container, using
+ //! a user provided key instead of the value itself.
+ //!
+ //! <b>Returns</b>: If there is an equivalent value
+ //! returns a pair containing an iterator to the already present value
+ //! and false. If the value can be inserted returns true in the returned
+ //! pair boolean and fills "commit_data" that is meant to be used with
+ //! the "insert_commit" function.
+ //!
+ //! <b>Complexity</b>: Average complexity is at most logarithmic.
+ //!
+ //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee.
+ //!
+ //! <b>Notes</b>: This function is used to improve performance when constructing
+ //! a value_type is expensive: if there is an equivalent value
+ //! the constructed object must be discarded. Many times, the part of the
+ //! node that is used to impose the order is much cheaper to construct
+ //! than the value_type and this function offers the possibility to use that
+ //! part to check if the insertion will be successful.
+ //!
+ //! If the check is successful, the user can construct the value_type and use
+ //! "insert_commit" to insert the object in constant-time. This gives a total
+ //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)).
+ //!
+ //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
+ //! objects are inserted or erased from the container.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator, bool> insert_unique_check
+ (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ comp(key_value_comp, this);
+ std::pair<node_ptr, bool> ret =
+ (node_algorithms::insert_unique_check
+ (node_ptr(&priv_header()), key, comp, commit_data));
+ return std::pair<iterator, bool>(iterator(ret.first, this), ret.second);
+ }
+
+ //! <b>Requires</b>: key_value_comp must be a comparison function that induces
+ //! the same strict weak ordering as value_compare. The difference is that
+ //! key_value_comp compares an arbitrary key with the contained values.
+ //!
+ //! <b>Effects</b>: Checks if a value can be inserted in the container, using
+ //! a user provided key instead of the value itself, using "hint"
+ //! as a hint to where it will be inserted.
+ //!
+ //! <b>Returns</b>: If there is an equivalent value
+ //! returns a pair containing an iterator to the already present value
+ //! and false. If the value can be inserted returns true in the returned
+ //! pair boolean and fills "commit_data" that is meant to be used with
+ //! the "insert_commit" function.
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it's amortized
+ //! constant time if t is inserted immediately before hint.
+ //!
+ //! <b>Throws</b>: If the key_value_comp ordering function throws. Strong guarantee.
+ //!
+ //! <b>Notes</b>: This function is used to improve performance when constructing
+ //! a value_type is expensive: if there is an equivalent value
+ //! the constructed object must be discarded. Many times, the part of the
+ //! constructing that is used to impose the order is much cheaper to construct
+ //! than the value_type and this function offers the possibility to use that key
+ //! to check if the insertion will be successful.
+ //!
+ //! If the check is successful, the user can construct the value_type and use
+ //! "insert_commit" to insert the object in constant-time. This can give a total
+ //! constant-time complexity to the insertion: check(O(1)) + commit(O(1)).
+ //!
+ //! "commit_data" remains valid for a subsequent "insert_commit" only if no more
+ //! objects are inserted or erased from the container.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator, bool> insert_unique_check
+ (const_iterator hint, const KeyType &key
+ ,KeyValueCompare key_value_comp, insert_commit_data &commit_data)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ comp(key_value_comp, this);
+ std::pair<node_ptr, bool> ret =
+ (node_algorithms::insert_unique_check
+ (node_ptr(&priv_header()), hint.pointed_node(), key, comp, commit_data));
+ return std::pair<iterator, bool>(iterator(ret.first, this), ret.second);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
+ //! must have been obtained from a previous call to "insert_check".
+ //! No objects should have been inserted or erased from the container between
+ //! the "insert_check" that filled "commit_data" and the call to "insert_commit".
+ //!
+ //! <b>Effects</b>: Inserts the value in the avl_set using the information obtained
+ //! from the "commit_data" that a previous "insert_check" filled.
+ //!
+ //! <b>Returns</b>: An iterator to the newly inserted object.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function has only sense if a "insert_check" has been
+ //! previously executed to fill "commit_data". No value should be inserted or
+ //! erased between the "insert_check" and "insert_commit" calls.
+ iterator insert_unique_commit(reference value, const insert_commit_data &commit_data)
+ {
+ node_ptr to_insert(get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ this->priv_size_traits().increment();
+ node_algorithms::insert_unique_commit
+ (node_ptr(&priv_header()), to_insert, commit_data);
+ return iterator(to_insert, this);
+ }
+
+ //! <b>Effects</b>: Erases the element pointed to by pos.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase element is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ iterator erase(const_iterator i)
+ {
+ const_iterator ret(i);
+ ++ret;
+ node_ptr to_erase(i.pointed_node());
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase));
+ node_algorithms::erase(&priv_header(), to_erase);
+ this->priv_size_traits().decrement();
+ if(safemode_or_autounlink)
+ node_algorithms::init(to_erase);
+ return ret.unconst();
+ }
+
+ //! <b>Effects</b>: Erases the range pointed to by b end e.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase range is at most
+ //! O(log(size() + N)), where N is the number of elements in the range.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ iterator erase(const_iterator b, const_iterator e)
+ { size_type n; return private_erase(b, e, n); }
+
+ //! <b>Effects</b>: Erases all the elements with the given value.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + N).
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ size_type erase(const_reference value)
+ { return this->erase(value, priv_comp()); }
+
+ //! <b>Effects</b>: Erases all the elements with the given key.
+ //! according to the comparison functor "comp".
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + N).
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp
+ /// @cond
+ , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
+ /// @endcond
+ )
+ {
+ std::pair<iterator,iterator> p = this->equal_range(key, comp);
+ size_type n;
+ private_erase(p.first, p.second, n);
+ return n;
+ }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases the element pointed to by pos.
+ //! Disposer::operator()(pointer) is called for the removed element.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase element is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator i, Disposer disposer)
+ {
+ node_ptr to_erase(i.pointed_node());
+ iterator ret(this->erase(i));
+ disposer(get_real_value_traits().to_value_ptr(to_erase));
+ return ret;
+ }
+
+ #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ template<class Disposer>
+ iterator erase_and_dispose(iterator i, Disposer disposer)
+ { return this->erase_and_dispose(const_iterator(i), disposer); }
+ #endif
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases the range pointed to by b end e.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Complexity</b>: Average complexity for erase range is at most
+ //! O(log(size() + N)), where N is the number of elements in the range.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
+ { size_type n; return private_erase(b, e, n, disposer); }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements with the given value.
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + N).
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ template<class Disposer>
+ size_type erase_and_dispose(const_reference value, Disposer disposer)
+ {
+ std::pair<iterator,iterator> p = this->equal_range(value);
+ size_type n;
+ private_erase(p.first, p.second, n, disposer);
+ return n;
+ }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //!
+ //! <b>Effects</b>: Erases all the elements with the given key.
+ //! according to the comparison functor "comp".
+ //! Disposer::operator()(pointer) is called for the removed elements.
+ //!
+ //! <b>Returns</b>: The number of erased elements.
+ //!
+ //! <b>Complexity</b>: O(log(size() + N).
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators
+ //! to the erased elements.
+ template<class KeyType, class KeyValueCompare, class Disposer>
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer
+ /// @cond
+ , typename detail::enable_if_c<!detail::is_convertible<KeyValueCompare, const_iterator>::value >::type * = 0
+ /// @endcond
+ )
+ {
+ std::pair<iterator,iterator> p = this->equal_range(key, comp);
+ size_type n;
+ private_erase(p.first, p.second, n, disposer);
+ return n;
+ }
+
+ //! <b>Effects</b>: Erases all of the elements.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements on the container.
+ //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. No destructors are called.
+ void clear()
+ {
+ if(safemode_or_autounlink){
+ this->clear_and_dispose(detail::null_disposer());
+ }
+ else{
+ node_algorithms::init_header(&priv_header());
+ this->priv_size_traits().set_size(0);
+ }
+ }
+
+ //! <b>Effects</b>: Erases all of the elements calling disposer(p) for
+ //! each node to be erased.
+ //! <b>Complexity</b>: Average complexity for is at most O(log(size() + N)),
+ //! where N is the number of elements in the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: Invalidates the iterators (but not the references)
+ //! to the erased elements. Calls N times to disposer functor.
+ template<class Disposer>
+ void clear_and_dispose(Disposer disposer)
+ {
+ node_algorithms::clear_and_dispose(node_ptr(&priv_header())
+ , detail::node_disposer<Disposer, avltree_impl>(disposer, this));
+ node_algorithms::init_header(&priv_header());
+ this->priv_size_traits().set_size(0);
+ }
+
+ //! <b>Effects</b>: Returns the number of contained elements with the given value
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
+ //! to number of objects with the given value.
+ //!
+ //! <b>Throws</b>: Nothing.
+ size_type count(const_reference value) const
+ { return this->count(value, priv_comp()); }
+
+ //! <b>Effects</b>: Returns the number of contained elements with the given key
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of elements contained plus lineal
+ //! to number of objects with the given key.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType &key, KeyValueCompare comp) const
+ {
+ std::pair<const_iterator, const_iterator> ret = this->equal_range(key, comp);
+ return std::distance(ret.first, ret.second);
+ }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator lower_bound(const_reference value)
+ { return this->lower_bound(value, priv_comp()); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator lower_bound(const_reference value) const
+ { return this->lower_bound(value, priv_comp()); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ return iterator(node_algorithms::lower_bound
+ (const_node_ptr(&priv_header()), key, key_node_comp), this);
+ }
+
+ //! <b>Effects</b>: Returns a const iterator to the first element whose
+ //! key is not less than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ return const_iterator(node_algorithms::lower_bound
+ (const_node_ptr(&priv_header()), key, key_node_comp), this);
+ }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator upper_bound(const_reference value)
+ { return this->upper_bound(value, priv_comp()); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k according to comp or end() if that element
+ //! does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ return iterator(node_algorithms::upper_bound
+ (const_node_ptr(&priv_header()), key, key_node_comp), this);
+ }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator upper_bound(const_reference value) const
+ { return this->upper_bound(value, priv_comp()); }
+
+ //! <b>Effects</b>: Returns an iterator to the first element whose
+ //! key is greater than k according to comp or end() if that element
+ //! does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ return const_iterator(node_algorithms::upper_bound
+ (const_node_ptr(&priv_header()), key, key_node_comp), this);
+ }
+
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is
+ //! k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator find(const_reference value)
+ { return this->find(value, priv_comp()); }
+
+ //! <b>Effects</b>: Finds an iterator to the first element whose key is
+ //! k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ return iterator
+ (node_algorithms::find(const_node_ptr(&priv_header()), key, key_node_comp), this);
+ }
+
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
+ //! k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator find(const_reference value) const
+ { return this->find(value, priv_comp()); }
+
+ //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
+ //! k or end() if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ return const_iterator
+ (node_algorithms::find(const_node_ptr(&priv_header()), key, key_node_comp), this);
+ }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ std::pair<iterator,iterator> equal_range(const_reference value)
+ { return this->equal_range(value, priv_comp()); }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ std::pair<node_ptr, node_ptr> ret
+ (node_algorithms::equal_range(const_node_ptr(&priv_header()), key, key_node_comp));
+ return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this));
+ }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ std::pair<const_iterator, const_iterator>
+ equal_range(const_reference value) const
+ { return this->equal_range(value, priv_comp()); }
+
+ //! <b>Effects</b>: Finds a range containing all elements whose key is k or
+ //! an empty range that indicates the position where those elements would be
+ //! if they there is no elements with key k.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator>
+ equal_range(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
+ key_node_comp(comp, this);
+ std::pair<node_ptr, node_ptr> ret
+ (node_algorithms::equal_range(const_node_ptr(&priv_header()), key, key_node_comp));
+ return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this));
+ }
+
+ //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
+ //! Cloner should yield to nodes equivalent to the original nodes.
+ //!
+ //! <b>Effects</b>: Erases all the elements from *this
+ //! calling Disposer::operator()(pointer), clones all the
+ //! elements from src calling Cloner::operator()(const_reference )
+ //! and inserts them on *this. Copies the predicate from the source container.
+ //!
+ //! If cloner throws, all cloned elements are unlinked and disposed
+ //! calling Disposer::operator()(pointer).
+ //!
+ //! <b>Complexity</b>: Linear to erased plus inserted elements.
+ //!
+ //! <b>Throws</b>: If cloner throws or predicate copy assignment throws. Basic guarantee.
+ template <class Cloner, class Disposer>
+ void clone_from(const avltree_impl &src, Cloner cloner, Disposer disposer)
+ {
+ this->clear_and_dispose(disposer);
+ if(!src.empty()){
+ detail::exception_disposer<avltree_impl, Disposer>
+ rollback(*this, disposer);
+ node_algorithms::clone
+ (const_node_ptr(&src.priv_header())
+ ,node_ptr(&this->priv_header())
+ ,detail::node_cloner<Cloner, avltree_impl>(cloner, this)
+ ,detail::node_disposer<Disposer, avltree_impl>(disposer, this));
+ this->priv_size_traits().set_size(src.priv_size_traits().get_size());
+ this->priv_comp() = src.priv_comp();
+ rollback.release();
+ }
+ }
+
+ //! <b>Effects</b>: Unlinks the leftmost node from the tree.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function breaks the tree and the tree can
+ //! only be used for more unlink_leftmost_without_rebalance calls.
+ //! This function is normally used to achieve a step by step
+ //! controlled destruction of the tree.
+ pointer unlink_leftmost_without_rebalance()
+ {
+ node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance
+ (node_ptr(&priv_header())));
+ if(!to_be_disposed)
+ return 0;
+ this->priv_size_traits().decrement();
+ if(safemode_or_autounlink)//If this is commented does not work with normal_link
+ node_algorithms::init(to_be_disposed);
+ return get_real_value_traits().to_value_ptr(to_be_disposed);
+ }
+
+ //! <b>Requires</b>: replace_this must be a valid iterator of *this
+ //! and with_this must not be inserted in any tree.
+ //!
+ //! <b>Effects</b>: Replaces replace_this in its position in the
+ //! tree with with_this. The tree does not need to be rebalanced.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! with_this is not equivalent to *replace_this according to the
+ //! ordering rules. This function is faster than erasing and inserting
+ //! the node, since no rebalancing or comparison is needed.
+ void replace_node(iterator replace_this, reference with_this)
+ {
+ node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this)
+ , node_ptr(&priv_header())
+ , get_real_value_traits().to_node_ptr(with_this));
+ }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the set
+ //! that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This static function is available only if the <i>value traits</i>
+ //! is stateless.
+ static iterator s_iterator_to(reference value)
+ {
+ BOOST_STATIC_ASSERT((!stateful_value_traits));
+ return iterator (value_traits::to_node_ptr(value), 0);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
+ //! set that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This static function is available only if the <i>value traits</i>
+ //! is stateless.
+ static const_iterator s_iterator_to(const_reference value)
+ {
+ BOOST_STATIC_ASSERT((!stateful_value_traits));
+ return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), 0);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid iterator i belonging to the set
+ //! that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator iterator_to(reference value)
+ { return iterator (value_traits::to_node_ptr(value), this); }
+
+ //! <b>Requires</b>: value must be an lvalue and shall be in a set of
+ //! appropriate type. Otherwise the behavior is undefined.
+ //!
+ //! <b>Effects</b>: Returns: a valid const_iterator i belonging to the
+ //! set that points to the value
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator iterator_to(const_reference value) const
+ { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this); }
+
+ //! <b>Requires</b>: value shall not be in a tree.
+ //!
+ //! <b>Effects</b>: init_node puts the hook of a value in a well-known default
+ //! state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Note</b>: This function puts the hook in the well-known default state
+ //! used by auto_unlink and safe hooks.
+ static void init_node(reference value)
+ { node_algorithms::init(value_traits::to_node_ptr(value)); }
+
+/*
+ //! <b>Effects</b>: removes x from a tree of the appropriate type. It has no effect,
+ //! if x is not in such a tree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Note</b>: This static function is only usable with the "safe mode"
+ //! hook and non-constant time size lists. Otherwise, the user must use
+ //! the non-static "erase(reference )" member. If the user calls
+ //! this function with a non "safe mode" or constant time size list
+ //! a compilation error will be issued.
+ template<class T>
+ static void remove_node(T& value)
+ {
+ //This function is only usable for safe mode hooks and non-constant
+ //time lists.
+ //BOOST_STATIC_ASSERT((!(safemode_or_autounlink && constant_time_size)));
+ BOOST_STATIC_ASSERT((!constant_time_size));
+ BOOST_STATIC_ASSERT((boost::is_convertible<T, value_type>::value));
+ node_ptr to_remove(value_traits::to_node_ptr(value));
+ node_algorithms::unlink_and_rebalance(to_remove);
+ if(safemode_or_autounlink)
+ node_algorithms::init(to_remove);
+ }
+*/
+
+ /// @cond
+
+ private:
+ template<class Disposer>
+ iterator private_erase(const_iterator b, const_iterator e, size_type &n, Disposer disposer)
+ {
+ for(n = 0; b != e; ++n)
+ this->erase_and_dispose(b++, disposer);
+ return b.unconst();
+ }
+
+ iterator private_erase(const_iterator b, const_iterator e, size_type &n)
+ {
+ for(n = 0; b != e; ++n)
+ this->erase(b++);
+ return b.unconst();
+ }
+ /// @endcond
+
+ private:
+ static avltree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
+ {
+ header_plus_size *r = detail::parent_from_member<header_plus_size, node>
+ ( detail::get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
+ node_plus_pred_t *n = detail::parent_from_member
+ <node_plus_pred_t, header_plus_size>(r, &node_plus_pred_t::header_plus_size_);
+ data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_);
+ avltree_impl *avl = detail::parent_from_member<avltree_impl, data_t>(d, &avltree_impl::data_);
+ return *avl;
+ }
+
+ static avltree_impl &priv_container_from_iterator(const const_iterator &it)
+ { return priv_container_from_end_iterator(it.end_iterator_from_it()); }
+};
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator<
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y)
+#else
+(const avltree_impl<Config> &x, const avltree_impl<Config> &y)
+#endif
+{ return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+bool operator==
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y)
+#else
+(const avltree_impl<Config> &x, const avltree_impl<Config> &y)
+#endif
+{
+ typedef avltree_impl<Config> tree_type;
+ typedef typename tree_type::const_iterator const_iterator;
+
+ if(tree_type::constant_time_size && x.size() != y.size()){
+ return false;
+ }
+ const_iterator end1 = x.end();
+ const_iterator i1 = x.begin();
+ const_iterator i2 = y.begin();
+ if(tree_type::constant_time_size){
+ while (i1 != end1 && *i1 == *i2) {
+ ++i1;
+ ++i2;
+ }
+ return i1 == end1;
+ }
+ else{
+ const_iterator end2 = y.end();
+ while (i1 != end1 && i2 != end2 && *i1 == *i2) {
+ ++i1;
+ ++i2;
+ }
+ return i1 == end1 && i2 == end2;
+ }
+}
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator!=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y)
+#else
+(const avltree_impl<Config> &x, const avltree_impl<Config> &y)
+#endif
+{ return !(x == y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator>
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y)
+#else
+(const avltree_impl<Config> &x, const avltree_impl<Config> &y)
+#endif
+{ return y < x; }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator<=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y)
+#else
+(const avltree_impl<Config> &x, const avltree_impl<Config> &y)
+#endif
+{ return !(y < x); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline bool operator>=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y)
+#else
+(const avltree_impl<Config> &x, const avltree_impl<Config> &y)
+#endif
+{ return !(x < y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class Config>
+#endif
+inline void swap
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(avltree_impl<T, Options...> &x, avltree_impl<T, Options...> &y)
+#else
+(avltree_impl<Config> &x, avltree_impl<Config> &y)
+#endif
+{ x.swap(y); }
+
+/// @cond
+
+#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class O1 = none, class O2 = none
+ , class O3 = none, class O4 = none
+ >
+#else
+template<class T, class ...Options>
+#endif
+struct make_avltree_opt
+{
+ typedef typename pack_options
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ < avl_set_defaults<T>, O1, O2, O3, O4>
+ #else
+ < avl_set_defaults<T>, Options...>
+ #endif
+ ::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::value_traits>::type value_traits;
+
+ typedef avl_setopt
+ < value_traits
+ , typename packed_options::compare
+ , typename packed_options::size_type
+ , packed_options::constant_time_size
+ > type;
+};
+/// @endcond
+
+//! Helper metafunction to define a \c avltree that yields to the same type when the
+//! same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class ...Options>
+#else
+template<class T, class O1 = none, class O2 = none
+ , class O3 = none, class O4 = none>
+#endif
+struct make_avltree
+{
+ /// @cond
+ typedef avltree_impl
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ < typename make_avltree_opt<T, O1, O2, O3, O4>::type
+ #else
+ < typename make_avltree_opt<T, Options...>::type
+ #endif
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class T, class O1, class O2, class O3, class O4>
+#else
+template<class T, class ...Options>
+#endif
+class avltree
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ : public make_avltree<T, O1, O2, O3, O4>::type
+ #else
+ : public make_avltree<T, Options...>::type
+ #endif
+{
+ typedef typename make_avltree
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <T, O1, O2, O3, O4>
+ #else
+ <T, Options...>
+ #endif
+ ::type Base;
+
+ public:
+ typedef typename Base::value_compare value_compare;
+ typedef typename Base::value_traits value_traits;
+ typedef typename Base::real_value_traits real_value_traits;
+ typedef typename Base::iterator iterator;
+ typedef typename Base::const_iterator const_iterator;
+
+ //Assert if passed value traits are compatible with the type
+ BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value));
+
+ avltree( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(cmp, v_traits)
+ {}
+
+ template<class Iterator>
+ avltree( bool unique, Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(unique, b, e, cmp, v_traits)
+ {}
+
+ static avltree &container_from_end_iterator(iterator end_iterator)
+ { return static_cast<avltree &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static const avltree &container_from_end_iterator(const_iterator end_iterator)
+ { return static_cast<const avltree &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static avltree &container_from_iterator(iterator it)
+ { return static_cast<avltree &>(Base::container_from_iterator(it)); }
+
+ static const avltree &container_from_iterator(const_iterator it)
+ { return static_cast<const avltree &>(Base::container_from_iterator(it)); }
+};
+
+#endif
+
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_AVLTREE_HPP
Added: sandbox/boost/intrusive/avltree_algorithms.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/avltree_algorithms.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,993 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Daniel K. O. 2005.
+// (C) Copyright Ion Gaztanaga 2007.
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP
+#define BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+
+#include <cstddef>
+#include <boost/intrusive/intrusive_fwd.hpp>
+
+#include <boost/intrusive/detail/assert.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/tree_algorithms.hpp>
+
+
+namespace boost {
+namespace intrusive {
+
+//! avltree_algorithms is configured with a NodeTraits class, which encapsulates the
+//! information about the node to be manipulated. NodeTraits must support the
+//! following interface:
+//!
+//! <b>Typedefs</b>:
+//!
+//! <tt>node</tt>: The type of the node that forms the circular list
+//!
+//! <tt>node_ptr</tt>: A pointer to a node
+//!
+//! <tt>const_node_ptr</tt>: A pointer to a const node
+//!
+//! <tt>balance</tt>: The type of the balance factor
+//!
+//! <b>Static functions</b>:
+//!
+//! <tt>static node_ptr get_parent(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_parent(node_ptr n, node_ptr parent);</tt>
+//!
+//! <tt>static node_ptr get_left(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_left(node_ptr n, node_ptr left);</tt>
+//!
+//! <tt>static node_ptr get_right(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_right(node_ptr n, node_ptr right);</tt>
+//!
+//! <tt>static balance get_balance(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_balance(node_ptr n, balance b);</tt>
+//!
+//! <tt>static balance negative();</tt>
+//!
+//! <tt>static balance zero();</tt>
+//!
+//! <tt>static balance positive();</tt>
+template<class NodeTraits>
+class avltree_algorithms
+{
+ public:
+ typedef typename NodeTraits::node node;
+ typedef NodeTraits node_traits;
+ typedef typename NodeTraits::node_ptr node_ptr;
+ typedef typename NodeTraits::const_node_ptr const_node_ptr;
+ typedef typename NodeTraits::balance balance;
+
+ /// @cond
+ private:
+ typedef detail::tree_algorithms<NodeTraits> tree_algorithms;
+
+ template<class F>
+ struct avltree_node_cloner
+ : private detail::ebo_functor_holder<F>
+ {
+ typedef detail::ebo_functor_holder<F> base_t;
+
+ avltree_node_cloner(F f)
+ : base_t(f)
+ {}
+
+ node_ptr operator()(node_ptr p)
+ {
+ node_ptr n = base_t::get()(p);
+ NodeTraits::set_balance(n, NodeTraits::get_balance(p));
+ return n;
+ }
+ };
+
+ struct avltree_erase_fixup
+ {
+ void operator()(node_ptr to_erase, node_ptr successor)
+ { NodeTraits::set_balance(successor, NodeTraits::get_balance(to_erase)); }
+ };
+
+ static node_ptr uncast(const_node_ptr ptr)
+ {
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ }
+ /// @endcond
+
+ public:
+ static node_ptr begin_node(const_node_ptr header)
+ { return tree_algorithms::begin_node(header); }
+
+ static node_ptr end_node(const_node_ptr header)
+ { return tree_algorithms::end_node(header); }
+
+ //! This type is the information that will be
+ //! filled by insert_unique_check
+ typedef typename tree_algorithms::insert_commit_data insert_commit_data;
+
+ //! <b>Requires</b>: header1 and header2 must be the header nodes
+ //! of two trees.
+ //!
+ //! <b>Effects</b>: Swaps two trees. After the function header1 will contain
+ //! links to the second tree and header2 will have links to the first tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void swap_tree(node_ptr header1, node_ptr header2)
+ { return tree_algorithms::swap_tree(header1, header2); }
+
+ //! <b>Requires</b>: node1 and node2 can't be header nodes
+ //! of two trees.
+ //!
+ //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted
+ //! in the position node2 before the function. node2 will be inserted in the
+ //! position node1 had before the function.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! node1 and node2 are not equivalent according to the ordering rules.
+ //!
+ //!Experimental function
+ static void swap_nodes(node_ptr node1, node_ptr node2)
+ {
+ if(node1 == node2)
+ return;
+
+ node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2));
+ swap_nodes(node1, header1, node2, header2);
+ }
+
+ //! <b>Requires</b>: node1 and node2 can't be header nodes
+ //! of two trees with header header1 and header2.
+ //!
+ //! <b>Effects</b>: Swaps two nodes. After the function node1 will be inserted
+ //! in the position node2 before the function. node2 will be inserted in the
+ //! position node1 had before the function.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! node1 and node2 are not equivalent according to the ordering rules.
+ //!
+ //!Experimental function
+ static void swap_nodes(node_ptr node1, node_ptr header1, node_ptr node2, node_ptr header2)
+ {
+ if(node1 == node2) return;
+
+ tree_algorithms::swap_nodes(node1, header1, node2, header2);
+ //Swap balance
+ balance c = NodeTraits::get_balance(node1);
+ NodeTraits::set_balance(node1, NodeTraits::get_balance(node2));
+ NodeTraits::set_balance(node2, c);
+ }
+
+ //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree
+ //! and new_node must not be inserted in a tree.
+ //!
+ //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the
+ //! tree with new_node. The tree does not need to be rebalanced
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! new_node is not equivalent to node_to_be_replaced according to the
+ //! ordering rules. This function is faster than erasing and inserting
+ //! the node, since no rebalancing and comparison is needed.
+ //!
+ //!Experimental function
+ static void replace_node(node_ptr node_to_be_replaced, node_ptr new_node)
+ {
+ if(node_to_be_replaced == new_node)
+ return;
+ replace_node(node_to_be_replaced, tree_algorithms::get_header(node_to_be_replaced), new_node);
+ }
+
+ //! <b>Requires</b>: node_to_be_replaced must be inserted in a tree
+ //! with header "header" and new_node must not be inserted in a tree.
+ //!
+ //! <b>Effects</b>: Replaces node_to_be_replaced in its position in the
+ //! tree with new_node. The tree does not need to be rebalanced
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function will break container ordering invariants if
+ //! new_node is not equivalent to node_to_be_replaced according to the
+ //! ordering rules. This function is faster than erasing and inserting
+ //! the node, since no rebalancing or comparison is needed.
+ //!
+ //!Experimental function
+ static void replace_node(node_ptr node_to_be_replaced, node_ptr header, node_ptr new_node)
+ {
+ tree_algorithms::replace_node(node_to_be_replaced, header, new_node);
+ NodeTraits::set_balance(new_node, NodeTraits::get_balance(node_to_be_replaced));
+ }
+
+ //! <b>Requires</b>: node is a tree node but not the header.
+ //!
+ //! <b>Effects</b>: Unlinks the node and rebalances the tree.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void unlink(node_ptr node)
+ {
+ node_ptr x = NodeTraits::get_parent(node);
+ if(x){
+ while(!is_header(x))
+ x = NodeTraits::get_parent(x);
+ erase(x, node);
+ }
+ }
+
+ //! <b>Requires</b>: header is the header of a tree.
+ //!
+ //! <b>Effects</b>: Unlinks the leftmost node from the tree, and
+ //! updates the header link to the new leftmost node.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function breaks the tree and the tree can
+ //! only be used for more unlink_leftmost_without_rebalance calls.
+ //! This function is normally used to achieve a step by step
+ //! controlled destruction of the tree.
+ static node_ptr unlink_leftmost_without_rebalance(node_ptr header)
+ { return tree_algorithms::unlink_leftmost_without_rebalance(header); }
+
+ //! <b>Requires</b>: node is a node of the tree or an node initialized
+ //! by init(...).
+ //!
+ //! <b>Effects</b>: Returns true if the node is initialized by init().
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool unique(const_node_ptr node)
+ { return tree_algorithms::unique(node); }
+
+ //! <b>Requires</b>: node is a node of the tree but it's not the header.
+ //!
+ //! <b>Effects</b>: Returns the number of nodes of the subtree.
+ //!
+ //! <b>Complexity</b>: Linear time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static std::size_t count(const_node_ptr node)
+ { return tree_algorithms::count(node); }
+
+ //! <b>Requires</b>: header is the header node of the tree.
+ //!
+ //! <b>Effects</b>: Returns the number of nodes above the header.
+ //!
+ //! <b>Complexity</b>: Linear time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static std::size_t size(const_node_ptr header)
+ { return tree_algorithms::size(header); }
+
+ //! <b>Requires</b>: p is a node from the tree except the header.
+ //!
+ //! <b>Effects</b>: Returns the next node of the tree.
+ //!
+ //! <b>Complexity</b>: Average constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr next_node(node_ptr p)
+ { return tree_algorithms::next_node(p); }
+
+ //! <b>Requires</b>: p is a node from the tree except the leftmost node.
+ //!
+ //! <b>Effects</b>: Returns the previous node of the tree.
+ //!
+ //! <b>Complexity</b>: Average constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr prev_node(node_ptr p)
+ { return tree_algorithms::prev_node(p); }
+
+ //! <b>Requires</b>: node must not be part of any tree.
+ //!
+ //! <b>Effects</b>: After the function unique(node) == true.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree.
+ static void init(node_ptr node)
+ { tree_algorithms::init(node); }
+
+ //! <b>Requires</b>: node must not be part of any tree.
+ //!
+ //! <b>Effects</b>: Initializes the header to represent an empty tree.
+ //! unique(header) == true.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree.
+ static void init_header(node_ptr header)
+ {
+ tree_algorithms::init_header(header);
+ NodeTraits::set_balance(header, NodeTraits::zero());
+ }
+
+ //! <b>Requires</b>: header must be the header of a tree, z a node
+ //! of that tree and z != header.
+ //!
+ //! <b>Effects</b>: Erases node "z" from the tree with header "header".
+ //!
+ //! <b>Complexity</b>: Amortized constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr erase(node_ptr header, node_ptr z)
+ {
+ typename tree_algorithms::data_for_rebalance info;
+ tree_algorithms::erase(header, z, avltree_erase_fixup(), info);
+ node_ptr x = info.x;
+ node_ptr x_parent = info.x_parent;
+
+ //Rebalance avltree
+ rebalance_after_erasure(header, x, x_parent);
+ return z;
+ }
+
+ //! <b>Requires</b>: "cloner" must be a function
+ //! object taking a node_ptr and returning a new cloned node of it. "disposer" must
+ //! take a node_ptr and shouldn't throw.
+ //!
+ //! <b>Effects</b>: First empties target tree calling
+ //! <tt>void disposer::operator()(node_ptr)</tt> for every node of the tree
+ //! except the header.
+ //!
+ //! Then, duplicates the entire tree pointed by "source_header" cloning each
+ //! source node with <tt>node_ptr Cloner::operator()(node_ptr)</tt> to obtain
+ //! the nodes of the target tree. If "cloner" throws, the cloned target nodes
+ //! are disposed using <tt>void disposer(node_ptr)</tt>.
+ //!
+ //! <b>Complexity</b>: Linear to the number of element of the source tree plus the.
+ //! number of elements of tree target tree when calling this function.
+ //!
+ //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed.
+ template <class Cloner, class Disposer>
+ static void clone
+ (const_node_ptr source_header, node_ptr target_header, Cloner cloner, Disposer disposer)
+ {
+ avltree_node_cloner<Cloner> new_cloner(cloner);
+ tree_algorithms::clone(source_header, target_header, new_cloner, disposer);
+ }
+
+ //! <b>Requires</b>: "disposer" must be an object function
+ //! taking a node_ptr parameter and shouldn't throw.
+ //!
+ //! <b>Effects</b>: Empties the target tree calling
+ //! <tt>void disposer::operator()(node_ptr)</tt> for every node of the tree
+ //! except the header.
+ //!
+ //! <b>Complexity</b>: Linear to the number of element of the source tree plus the.
+ //! number of elements of tree target tree when calling this function.
+ //!
+ //! <b>Throws</b>: If cloner functor throws. If this happens target nodes are disposed.
+ template<class Disposer>
+ static void clear_and_dispose(node_ptr header, Disposer disposer)
+ { tree_algorithms::clear_and_dispose(header, disposer); }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! KeyNodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs.
+ //!
+ //! <b>Effects</b>: Returns an node_ptr to the first element that is
+ //! not less than "key" according to "comp" or "header" if that element does
+ //! not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class KeyType, class KeyNodePtrCompare>
+ static node_ptr lower_bound
+ (const_node_ptr header, const KeyType &key, KeyNodePtrCompare comp)
+ { return tree_algorithms::lower_bound(header, key, comp); }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! KeyNodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs.
+ //!
+ //! <b>Effects</b>: Returns an node_ptr to the first element that is greater
+ //! than "key" according to "comp" or "header" if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class KeyType, class KeyNodePtrCompare>
+ static node_ptr upper_bound
+ (const_node_ptr header, const KeyType &key, KeyNodePtrCompare comp)
+ { return tree_algorithms::upper_bound(header, key, comp); }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! KeyNodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs.
+ //!
+ //! <b>Effects</b>: Returns an node_ptr to the element that is equivalent to
+ //! "key" according to "comp" or "header" if that element does not exist.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class KeyType, class KeyNodePtrCompare>
+ static node_ptr find
+ (const_node_ptr header, const KeyType &key, KeyNodePtrCompare comp)
+ { return tree_algorithms::find(header, key, comp); }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! KeyNodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. KeyNodePtrCompare can compare KeyType with tree's node_ptrs.
+ //!
+ //! <b>Effects</b>: Returns an a pair of node_ptr delimiting a range containing
+ //! all elements that are equivalent to "key" according to "comp" or an
+ //! empty range that indicates the position where those elements would be
+ //! if they there are no equivalent elements.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class KeyType, class KeyNodePtrCompare>
+ static std::pair<node_ptr, node_ptr> equal_range
+ (const_node_ptr header, const KeyType &key, KeyNodePtrCompare comp)
+ { return tree_algorithms::equal_range(header, key, comp); }
+
+ //! <b>Requires</b>: "h" must be the header node of a tree.
+ //! NodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. NodePtrCompare compares two node_ptrs.
+ //!
+ //! <b>Effects</b>: Inserts new_node into the tree before the upper bound
+ //! according to "comp".
+ //!
+ //! <b>Complexity</b>: Average complexity for insert element is at
+ //! most logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class NodePtrCompare>
+ static node_ptr insert_equal_upper_bound
+ (node_ptr h, node_ptr new_node, NodePtrCompare comp)
+ {
+ tree_algorithms::insert_equal_upper_bound(h, new_node, comp);
+ rebalance_after_insertion(h, new_node);
+ return new_node;
+ }
+
+ //! <b>Requires</b>: "h" must be the header node of a tree.
+ //! NodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. NodePtrCompare compares two node_ptrs.
+ //!
+ //! <b>Effects</b>: Inserts new_node into the tree before the lower bound
+ //! according to "comp".
+ //!
+ //! <b>Complexity</b>: Average complexity for insert element is at
+ //! most logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class NodePtrCompare>
+ static node_ptr insert_equal_lower_bound
+ (node_ptr h, node_ptr new_node, NodePtrCompare comp)
+ {
+ tree_algorithms::insert_equal_lower_bound(h, new_node, comp);
+ rebalance_after_insertion(h, new_node);
+ return new_node;
+ }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! NodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. NodePtrCompare compares two node_ptrs. "hint" is node from
+ //! the "header"'s tree.
+ //!
+ //! <b>Effects</b>: Inserts new_node into the tree, using "hint" as a hint to
+ //! where it will be inserted. If "hint" is the upper_bound
+ //! the insertion takes constant time (two comparisons in the worst case).
+ //!
+ //! <b>Complexity</b>: Logarithmic in general, but it is amortized
+ //! constant time if new_node is inserted immediately before "hint".
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class NodePtrCompare>
+ static node_ptr insert_equal
+ (node_ptr header, node_ptr hint, node_ptr new_node, NodePtrCompare comp)
+ {
+ tree_algorithms::insert_equal(header, hint, new_node, comp);
+ rebalance_after_insertion(header, new_node);
+ return new_node;
+ }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! KeyNodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. NodePtrCompare compares KeyType with a node_ptr.
+ //!
+ //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the
+ //! tree according to "comp" and obtains the needed information to realize
+ //! a constant-time node insertion if there is no equivalent node.
+ //!
+ //! <b>Returns</b>: If there is an equivalent value
+ //! returns a pair containing a node_ptr to the already present node
+ //! and false. If there is not equivalent key can be inserted returns true
+ //! in the returned pair's boolean and fills "commit_data" that is meant to
+ //! be used with the "insert_commit" function to achieve a constant-time
+ //! insertion function.
+ //!
+ //! <b>Complexity</b>: Average complexity is at most logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ //!
+ //! <b>Notes</b>: This function is used to improve performance when constructing
+ //! a node is expensive and the user does not want to have two equivalent nodes
+ //! in the tree: if there is an equivalent value
+ //! the constructed object must be discarded. Many times, the part of the
+ //! node that is used to impose the order is much cheaper to construct
+ //! than the node and this function offers the possibility to use that part
+ //! to check if the insertion will be successful.
+ //!
+ //! If the check is successful, the user can construct the node and use
+ //! "insert_commit" to insert the node in constant-time. This gives a total
+ //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)).
+ //!
+ //! "commit_data" remains valid for a subsequent "insert_unique_commit" only
+ //! if no more objects are inserted or erased from the set.
+ template<class KeyType, class KeyNodePtrCompare>
+ static std::pair<node_ptr, bool> insert_unique_check
+ (const_node_ptr header, const KeyType &key
+ ,KeyNodePtrCompare comp, insert_commit_data &commit_data)
+ { return tree_algorithms::insert_unique_check(header, key, comp, commit_data); }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! KeyNodePtrCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the tree. NodePtrCompare compares KeyType with a node_ptr.
+ //! "hint" is node from the "header"'s tree.
+ //!
+ //! <b>Effects</b>: Checks if there is an equivalent node to "key" in the
+ //! tree according to "comp" using "hint" as a hint to where it should be
+ //! inserted and obtains the needed information to realize
+ //! a constant-time node insertion if there is no equivalent node.
+ //! If "hint" is the upper_bound the function has constant time
+ //! complexity (two comparisons in the worst case).
+ //!
+ //! <b>Returns</b>: If there is an equivalent value
+ //! returns a pair containing a node_ptr to the already present node
+ //! and false. If there is not equivalent key can be inserted returns true
+ //! in the returned pair's boolean and fills "commit_data" that is meant to
+ //! be used with the "insert_commit" function to achieve a constant-time
+ //! insertion function.
+ //!
+ //! <b>Complexity</b>: Average complexity is at most logarithmic, but it is
+ //! amortized constant time if new_node should be inserted immediately before "hint".
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ //!
+ //! <b>Notes</b>: This function is used to improve performance when constructing
+ //! a node is expensive and the user does not want to have two equivalent nodes
+ //! in the tree: if there is an equivalent value
+ //! the constructed object must be discarded. Many times, the part of the
+ //! node that is used to impose the order is much cheaper to construct
+ //! than the node and this function offers the possibility to use that part
+ //! to check if the insertion will be successful.
+ //!
+ //! If the check is successful, the user can construct the node and use
+ //! "insert_commit" to insert the node in constant-time. This gives a total
+ //! logarithmic complexity to the insertion: check(O(log(N)) + commit(O(1)).
+ //!
+ //! "commit_data" remains valid for a subsequent "insert_unique_commit" only
+ //! if no more objects are inserted or erased from the set.
+ template<class KeyType, class KeyNodePtrCompare>
+ static std::pair<node_ptr, bool> insert_unique_check
+ (const_node_ptr header, node_ptr hint, const KeyType &key
+ ,KeyNodePtrCompare comp, insert_commit_data &commit_data)
+ { return tree_algorithms::insert_unique_check(header, hint, key, comp, commit_data); }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! "commit_data" must have been obtained from a previous call to
+ //! "insert_unique_check". No objects should have been inserted or erased
+ //! from the set between the "insert_unique_check" that filled "commit_data"
+ //! and the call to "insert_commit".
+ //!
+ //!
+ //! <b>Effects</b>: Inserts new_node in the set using the information obtained
+ //! from the "commit_data" that a previous "insert_check" filled.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function has only sense if a "insert_unique_check" has been
+ //! previously executed to fill "commit_data". No value should be inserted or
+ //! erased between the "insert_check" and "insert_commit" calls.
+ static void insert_unique_commit
+ (node_ptr header, node_ptr new_value, const insert_commit_data &commit_data)
+ {
+ tree_algorithms::insert_unique_commit(header, new_value, commit_data);
+ rebalance_after_insertion(header, new_value);
+ }
+
+ //! <b>Requires</b>: "n" must be a node inserted in a tree.
+ //!
+ //! <b>Effects</b>: Returns a pointer to the header node of the tree.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr get_header(node_ptr n)
+ { return tree_algorithms::get_header(n); }
+
+ /// @cond
+ private:
+
+ //! <b>Requires</b>: p is a node of a tree.
+ //!
+ //! <b>Effects</b>: Returns true if p is the header of the tree.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool is_header(const_node_ptr p)
+ { return NodeTraits::get_balance(p) == NodeTraits::zero() && tree_algorithms::is_header(p); }
+
+ static void rebalance_after_erasure(node_ptr header, node_ptr x, node_ptr x_parent)
+ {
+ node_ptr root = NodeTraits::get_parent(header);
+ while (x != root) {
+ const balance x_parent_balance = NodeTraits::get_balance(x_parent);
+ if(x_parent_balance == NodeTraits::zero()){
+ NodeTraits::set_balance(x_parent,
+ (x == NodeTraits::get_right(x_parent) ? NodeTraits::negative() : NodeTraits::positive()));
+ break; // the height didn't change, let's stop here
+ }
+ else if(x_parent_balance == NodeTraits::negative()){
+ if (x == NodeTraits::get_left(x_parent)) {
+ NodeTraits::set_balance(x_parent, NodeTraits::zero()); // balanced
+ x = x_parent;
+ x_parent = NodeTraits::get_parent(x_parent);
+ }
+ else {
+ // x is right child
+ // a is left child
+ node_ptr a = NodeTraits::get_left(x_parent);
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(a);
+ if (NodeTraits::get_balance(a) == NodeTraits::positive()) {
+ // a MUST have a right child
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_right(a));
+ rotate_left_right(x_parent, root);
+
+ x = NodeTraits::get_parent(x_parent);
+ x_parent = NodeTraits::get_parent(x);
+ }
+ else {
+ rotate_right(x_parent, root);
+ x = NodeTraits::get_parent(x_parent);
+ x_parent = NodeTraits::get_parent(x);
+
+ }
+
+ // if changed from negative to NodeTraits::positive(), no need to check above
+ if (NodeTraits::get_balance(x) == NodeTraits::positive()){
+ break;
+ }
+ }
+ }
+ else if(x_parent_balance == NodeTraits::positive()){
+ if (x == NodeTraits::get_right(x_parent)) {
+ NodeTraits::set_balance(x_parent, NodeTraits::zero()); // balanced
+ x = x_parent;
+ x_parent = NodeTraits::get_parent(x_parent);
+ }
+ else {
+ // x is left child
+ // a is right child
+ node_ptr a = NodeTraits::get_right(x_parent);
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(a);
+ if (NodeTraits::get_balance(a) == NodeTraits::negative()) {
+ // a MUST have then a left child
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(NodeTraits::get_left(a));
+ rotate_right_left(x_parent, root);
+
+ x = NodeTraits::get_parent(x_parent);
+ x_parent = NodeTraits::get_parent(x);
+ }
+ else {
+ rotate_left(x_parent, root);
+ x = NodeTraits::get_parent(x_parent);
+ x_parent = NodeTraits::get_parent(x);
+ }
+ // if changed from NodeTraits::positive() to negative, no need to check above
+ if (NodeTraits::get_balance(x) == NodeTraits::negative()){
+ break;
+ }
+ }
+ }
+ else{
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached
+ }
+ }
+ NodeTraits::set_parent(header, root);
+ }
+
+
+ static void rebalance_after_insertion(node_ptr header, node_ptr x)
+ {
+ node_ptr root = NodeTraits::get_parent(header);
+ NodeTraits::set_balance(x, NodeTraits::zero());
+
+ // Rebalance.
+ while (x != root){
+ const balance x_parent_balance = NodeTraits::get_balance(NodeTraits::get_parent(x));
+
+ if(x_parent_balance == NodeTraits::zero()){
+ // if x is left, parent will have parent->bal_factor = negative
+ // else, parent->bal_factor = NodeTraits::positive()
+ NodeTraits::set_balance( NodeTraits::get_parent(x)
+ , x == NodeTraits::get_left(NodeTraits::get_parent(x))
+ ? NodeTraits::negative() : NodeTraits::positive() );
+ x = NodeTraits::get_parent(x);
+ }
+ else if(x_parent_balance == NodeTraits::positive()){
+ // if x is a left child, parent->bal_factor = zero
+ if (x == NodeTraits::get_left(NodeTraits::get_parent(x)))
+ NodeTraits::set_balance(NodeTraits::get_parent(x), NodeTraits::zero());
+ else{ // x is a right child, needs rebalancing
+ if (NodeTraits::get_balance(x) == NodeTraits::negative())
+ rotate_right_left(NodeTraits::get_parent(x), root);
+ else
+ rotate_left(NodeTraits::get_parent(x), root);
+ }
+ break;
+ }
+ else if(x_parent_balance == NodeTraits::negative()){
+ // if x is a left child, needs rebalancing
+ if (x == NodeTraits::get_left(NodeTraits::get_parent(x))) {
+ if (NodeTraits::get_balance(x) == NodeTraits::positive())
+ rotate_left_right(NodeTraits::get_parent(x), root);
+ else
+ rotate_right(NodeTraits::get_parent(x), root);
+ }
+ else
+ NodeTraits::set_balance(NodeTraits::get_parent(x), NodeTraits::zero());
+ break;
+ }
+ else{
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached
+ }
+ }
+ NodeTraits::set_parent(header, root);
+ }
+
+ static void rotate_left_right(node_ptr a, node_ptr &root)
+ {
+ // | | //
+ // a(-2) c //
+ // / \ / \ //
+ // / \ ==> / \ //
+ // (pos)b [g] b a //
+ // / \ / \ / \ //
+ // [d] c [d] e f [g] //
+ // / \ //
+ // e f //
+ node_ptr b = NodeTraits::get_left(a), c = NodeTraits::get_right(b);
+
+ // switch
+ NodeTraits::set_left(a, NodeTraits::get_right(c));
+ NodeTraits::set_right(b, NodeTraits::get_left(c));
+
+ NodeTraits::set_right(c, a);
+ NodeTraits::set_left(c, b);
+
+ // set the parents
+ NodeTraits::set_parent(c, NodeTraits::get_parent(a));
+ NodeTraits::set_parent(a, c);
+ NodeTraits::set_parent(b, c);
+
+ if (NodeTraits::get_left(a)) // do we have f?
+ NodeTraits::set_parent(NodeTraits::get_left(a), a);
+ if (NodeTraits::get_right(b)) // do we have e?
+ NodeTraits::set_parent(NodeTraits::get_right(b), b);
+
+ if (a==root) root = c;
+ else // a had a parent, his child is now c
+ if (a == NodeTraits::get_left(NodeTraits::get_parent(c)))
+ NodeTraits::set_left(NodeTraits::get_parent(c), c);
+ else
+ NodeTraits::set_right(NodeTraits::get_parent(c), c);
+
+ // balancing...
+ const balance c_balance = NodeTraits::get_balance(c);
+ if(c_balance == NodeTraits::negative()){
+ NodeTraits::set_balance(a, NodeTraits::positive());
+ NodeTraits::set_balance(b, NodeTraits::zero());
+ }
+ else if(c_balance == NodeTraits::zero()){
+ NodeTraits::set_balance(a, NodeTraits::zero());
+ NodeTraits::set_balance(b, NodeTraits::zero());
+ }
+ else if(c_balance == NodeTraits::positive()){
+ NodeTraits::set_balance(a, NodeTraits::zero());
+ NodeTraits::set_balance(b, NodeTraits::negative());
+ }
+ else{
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(false); // never reached
+ }
+ NodeTraits::set_balance(c, NodeTraits::zero());
+ }
+
+ static void rotate_right_left(node_ptr a, node_ptr &root)
+ {
+ // | | //
+ // a(pos) c //
+ // / \ / \ //
+ // / \ / \ //
+ // [d] b(neg) ==> a b //
+ // / \ / \ / \ //
+ // c [g] [d] e f [g] //
+ // / \ //
+ // e f //
+ node_ptr b = NodeTraits::get_right(a), c = NodeTraits::get_left(b);
+
+ // switch
+ NodeTraits::set_right(a, NodeTraits::get_left(c));
+ NodeTraits::set_left(b, NodeTraits::get_right(c));
+
+ NodeTraits::set_left(c, a);
+ NodeTraits::set_right(c, b);
+
+ // set the parents
+ NodeTraits::set_parent(c, NodeTraits::get_parent(a));
+ NodeTraits::set_parent(a, c);
+ NodeTraits::set_parent(b, c);
+
+ if (NodeTraits::get_right(a)) // do we have e?
+ NodeTraits::set_parent(NodeTraits::get_right(a), a);
+ if (NodeTraits::get_left(b)) // do we have f?
+ NodeTraits::set_parent(NodeTraits::get_left(b), b);
+
+ if (a==root) root = c;
+ else // a had a parent, his child is now c
+ if (a == NodeTraits::get_left(NodeTraits::get_parent(c)))
+ NodeTraits::set_left(NodeTraits::get_parent(c), c);
+ else
+ NodeTraits::set_right(NodeTraits::get_parent(c), c);
+
+ // balancing...
+ const balance c_balance = NodeTraits::get_balance(c);
+ if(c_balance == NodeTraits::negative()){
+ NodeTraits::set_balance(a, NodeTraits::zero());
+ NodeTraits::set_balance(b, NodeTraits::positive());
+ }
+ else if(c_balance == NodeTraits::zero()){
+ NodeTraits::set_balance(a, NodeTraits::zero());
+ NodeTraits::set_balance(b, NodeTraits::zero());
+ }
+ else if(c_balance == NodeTraits::positive()){
+ NodeTraits::set_balance(a, NodeTraits::negative());
+ NodeTraits::set_balance(b, NodeTraits::zero());
+ }
+ else{
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(false);
+ }
+ NodeTraits::set_balance(c, NodeTraits::zero());
+ }
+
+ static void rotate_left(node_ptr x, node_ptr & root)
+ {
+ // | | //
+ // x(2) y(0) //
+ // / \ ==> / \ //
+ // n[a] y(1)n+2 n+1(0)x [c]n+1 //
+ // / \ / \ //
+ // n[b] [c]n+1 n[a] [b]n //
+ node_ptr y = NodeTraits::get_right(x);
+
+ // switch
+ NodeTraits::set_right(x, NodeTraits::get_left(y));
+ NodeTraits::set_left(y, x);
+
+ // rearrange parents
+ NodeTraits::set_parent(y, NodeTraits::get_parent(x));
+ NodeTraits::set_parent(x, y);
+
+ // do we have [b]?
+ if (NodeTraits::get_right(x))
+ NodeTraits::set_parent(NodeTraits::get_right(x), x);
+
+ if (x == root)
+ root = y;
+ else
+ // need to reparent y
+ if (NodeTraits::get_left(NodeTraits::get_parent(y)) == x)
+ NodeTraits::set_left(NodeTraits::get_parent(y), y);
+ else
+ NodeTraits::set_right(NodeTraits::get_parent(y), y);
+
+ // reset the balancing factor
+ if (NodeTraits::get_balance(y) == NodeTraits::positive()) {
+ NodeTraits::set_balance(x, NodeTraits::zero());
+ NodeTraits::set_balance(y, NodeTraits::zero());
+ }
+ else { // this doesn't happen during insertions
+ NodeTraits::set_balance(x, NodeTraits::positive());
+ NodeTraits::set_balance(y, NodeTraits::negative());
+ }
+ }
+
+ static void rotate_right(node_ptr x, node_ptr &root)
+ {
+ node_ptr y = NodeTraits::get_left(x);
+
+ // switch
+ NodeTraits::set_left(x, NodeTraits::get_right(y));
+ NodeTraits::set_right(y, x);
+
+ // rearrange parents
+ NodeTraits::set_parent(y, NodeTraits::get_parent(x));
+ NodeTraits::set_parent(x, y);
+
+ // do we have [b]?
+ if (NodeTraits::get_left(x))
+ NodeTraits::set_parent(NodeTraits::get_left(x), x);
+
+ if (x == root)
+ root = y;
+ else
+ // need to reparent y
+ if (NodeTraits::get_left(NodeTraits::get_parent(y)) == x)
+ NodeTraits::set_left(NodeTraits::get_parent(y), y);
+ else
+ NodeTraits::set_right(NodeTraits::get_parent(y), y);
+
+ // reset the balancing factor
+ if (NodeTraits::get_balance(y) == NodeTraits::negative()) {
+ NodeTraits::set_balance(x, NodeTraits::zero());
+ NodeTraits::set_balance(y, NodeTraits::zero());
+ }
+ else { // this doesn't happen during insertions
+ NodeTraits::set_balance(x, NodeTraits::negative());
+ NodeTraits::set_balance(y, NodeTraits::positive());
+ }
+ }
+
+ /// @endcond
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_AVLTREE_ALGORITHMS_HPP
Added: sandbox/boost/intrusive/bs_set_hook.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/bs_set_hook.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,294 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_BS_SET_HOOK_HPP
+#define BOOST_INTRUSIVE_BS_SET_HOOK_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/tree_node.hpp>
+#include <boost/intrusive/detail/tree_algorithms.hpp>
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/detail/generic_hook.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/// @cond
+template<class VoidPointer>
+struct get_bs_set_node_algo
+{
+ typedef detail::tree_algorithms<tree_node_traits<VoidPointer> > type;
+};
+/// @endcond
+
+//! Helper metafunction to define a \c bs_set_base_hook that yields to the same
+//! type when the same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1 = none, class O2 = none, class O3 = none>
+#endif
+struct make_bs_set_base_hook
+{
+ /// @cond
+ typedef typename pack_options
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ < hook_defaults, O1, O2, O3>
+ #else
+ < hook_defaults, Options...>
+ #endif
+ ::type packed_options;
+
+ //Scapegoat trees can't be auto unlink trees
+ BOOST_STATIC_ASSERT(((int)packed_options::link_mode != (int)auto_unlink));
+
+ typedef detail::generic_hook
+ < get_bs_set_node_algo<typename packed_options::void_pointer>
+ , typename packed_options::tag
+ , packed_options::link_mode
+ , detail::BsSetBaseHook
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+//! Derive a class from bs_set_base_hook in order to store objects in
+//! in a bs_set/bs_multiset. bs_set_base_hook holds the data necessary to maintain
+//! the bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset.
+//!
+//! The hook admits the following options: \c tag<>, \c void_pointer<>,
+//! \c link_mode<>.
+//!
+//! \c 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 \c list_base_hook, then each \c list_base_hook needs its
+//! unique tag.
+//!
+//! \c void_pointer<> is the pointer type that will be used internally in the hook
+//! and the the container configured to use this hook.
+//!
+//! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
+//! \c auto_unlink or \c safe_link).
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1, class O2, class O3>
+#endif
+class bs_set_base_hook
+ : public make_bs_set_base_hook
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <O1, O2, O3>
+ #else
+ <Options...>
+ #endif
+ ::type
+
+{
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ bs_set_base_hook();
+
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing a copy-constructor
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ bs_set_base_hook(const bs_set_base_hook& );
+
+ //! <b>Effects</b>: Empty function. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing an assignment operator
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ bs_set_base_hook& operator=(const bs_set_base_hook& );
+
+ //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
+ //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
+ //! object is stored in a set an assertion is raised. If link_mode is
+ //! \c auto_unlink and \c is_linked() is true, the node is unlinked.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~bs_set_base_hook();
+
+ //! <b>Effects</b>: 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.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ void swap_nodes(bs_set_base_hook &other);
+
+ //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
+ //!
+ //! <b>Returns</b>: true, if the node belongs to a container, false
+ //! otherwise. This function can be used to test whether \c set::iterator_to
+ //! will return a valid iterator.
+ //!
+ //! <b>Complexity</b>: Constant
+ bool is_linked() const;
+
+ //! <b>Effects</b>: Removes the node if it's inserted in a container.
+ //! This function is only allowed if link_mode is \c auto_unlink.
+ //!
+ //! <b>Throws</b>: Nothing.
+ void unlink();
+ #endif
+};
+
+//! Helper metafunction to define a \c bs_set_member_hook that yields to the same
+//! type when the same options (either explicitly or implicitly) are used.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1 = none, class O2 = none, class O3 = none>
+#endif
+struct make_bs_set_member_hook
+{
+ /// @cond
+ typedef typename pack_options
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ < hook_defaults, O1, O2, O3>
+ #else
+ < hook_defaults, Options...>
+ #endif
+
+ ::type packed_options;
+
+ //Scapegoat trees can't be auto unlink trees
+ BOOST_STATIC_ASSERT(((int)packed_options::link_mode != (int)auto_unlink));
+
+ typedef detail::generic_hook
+ < get_bs_set_node_algo<typename packed_options::void_pointer>
+ , member_tag
+ , packed_options::link_mode
+ , detail::NoBaseHook
+ > implementation_defined;
+ /// @endcond
+ typedef implementation_defined type;
+};
+
+//! Put a public data member bs_set_member_hook in order to store objects of this class in
+//! a bs_set/bs_multiset. bs_set_member_hook holds the data necessary for maintaining the
+//! bs_set/bs_multiset and provides an appropriate value_traits class for bs_set/bs_multiset.
+//!
+//! The hook admits the following options: \c void_pointer<>, \c link_mode<>.
+//!
+//! \c void_pointer<> is the pointer type that will be used internally in the hook
+//! and the the container configured to use this hook.
+//!
+//! \c link_mode<> will specify the linking mode of the hook (\c normal_link,
+//! \c auto_unlink or \c safe_link).
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template<class ...Options>
+#else
+template<class O1, class O2, class O3>
+#endif
+class bs_set_member_hook
+ : public make_bs_set_member_hook
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ <O1, O2, O3>
+ #else
+ <Options...>
+ #endif
+ ::type
+{
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state.
+ //!
+ //! <b>Throws</b>: Nothing.
+ bs_set_member_hook();
+
+ //! <b>Effects</b>: If link_mode is \c auto_unlink or \c safe_link
+ //! initializes the node to an unlinked state. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing a copy-constructor
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ bs_set_member_hook(const bs_set_member_hook& );
+
+ //! <b>Effects</b>: Empty function. The argument is ignored.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Rationale</b>: Providing an assignment operator
+ //! makes classes using the hook STL-compliant without forcing the
+ //! user to do some additional work. \c swap can be used to emulate
+ //! move-semantics.
+ bs_set_member_hook& operator=(const bs_set_member_hook& );
+
+ //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
+ //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
+ //! object is stored in a set an assertion is raised. If link_mode is
+ //! \c auto_unlink and \c is_linked() is true, the node is unlinked.
+ //!
+ //! <b>Throws</b>: Nothing.
+ ~bs_set_member_hook();
+
+ //! <b>Effects</b>: 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.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ void swap_nodes(bs_set_member_hook &other);
+
+ //! <b>Precondition</b>: link_mode must be \c safe_link or \c auto_unlink.
+ //!
+ //! <b>Returns</b>: true, if the node belongs to a container, false
+ //! otherwise. This function can be used to test whether \c set::iterator_to
+ //! will return a valid iterator.
+ //!
+ //! <b>Complexity</b>: Constant
+ bool is_linked() const;
+
+ //! <b>Effects</b>: Removes the node if it's inserted in a container.
+ //! This function is only allowed if link_mode is \c auto_unlink.
+ //!
+ //! <b>Throws</b>: Nothing.
+ void unlink();
+ #endif
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_BS_SET_HOOK_HPP
Added: sandbox/boost/intrusive/circular_list_algorithms.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/circular_list_algorithms.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,407 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Olaf Krzikalla 2004-2006.
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP
+#define BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <cstddef>
+
+namespace boost {
+namespace intrusive {
+
+//! circular_list_algorithms provides basic algorithms to manipulate nodes
+//! forming a circular doubly linked list. An empty circular list is formed by a node
+//! whose pointers point to itself.
+//!
+//! circular_list_algorithms is configured with a NodeTraits class, which encapsulates the
+//! information about the node to be manipulated. NodeTraits must support the
+//! following interface:
+//!
+//! <b>Typedefs</b>:
+//!
+//! <tt>node</tt>: The type of the node that forms the circular list
+//!
+//! <tt>node_ptr</tt>: A pointer to a node
+//!
+//! <tt>const_node_ptr</tt>: A pointer to a const node
+//!
+//! <b>Static functions</b>:
+//!
+//! <tt>static node_ptr get_previous(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_previous(node_ptr n, node_ptr prev);</tt>
+//!
+//! <tt>static node_ptr get_next(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_next(node_ptr n, node_ptr next);</tt>
+template<class NodeTraits>
+class circular_list_algorithms
+{
+ public:
+ typedef typename NodeTraits::node node;
+ typedef typename NodeTraits::node_ptr node_ptr;
+ typedef typename NodeTraits::const_node_ptr const_node_ptr;
+ typedef NodeTraits node_traits;
+
+ //! <b>Effects</b>: Constructs an non-used list element, so that
+ //! inited(this_node) == true
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void init(node_ptr this_node)
+ {
+ NodeTraits::set_next(this_node, node_ptr(0));
+ NodeTraits::set_previous(this_node, node_ptr(0));
+ }
+
+ //! <b>Effects</b>: Returns true is "this_node" is in a non-used state
+ //! as if it was initialized by the "init" function.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool inited(const_node_ptr this_node)
+ { return !NodeTraits::get_next(this_node); }
+
+ //! <b>Effects</b>: Constructs an empty list, making this_node the only
+ //! node of the circular list:
+ //! <tt>NodeTraits::get_next(this_node) == NodeTraits::get_previous(this_node)
+ //! == this_node</tt>.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void init_header(node_ptr this_node)
+ {
+ NodeTraits::set_next(this_node, this_node);
+ NodeTraits::set_previous(this_node, this_node);
+ }
+
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list:
+ //! <tt>return NodeTraits::get_next(this_node) == this_node</tt>
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool unique(const_node_ptr this_node)
+ {
+ node_ptr next = NodeTraits::get_next(this_node);
+ return !next || next == this_node;
+ }
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Returns the number of nodes in a circular list. If the circular list
+ //! is empty, returns 1.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static std::size_t count(const_node_ptr this_node)
+ {
+ std::size_t result = 0;
+ const_node_ptr p = this_node;
+ do{
+ p = NodeTraits::get_next(p);
+ ++result;
+ }while (p != this_node);
+ return result;
+ }
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Unlinks the node from the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr unlink(node_ptr this_node)
+ {
+ if(NodeTraits::get_next(this_node)){
+ node_ptr next(NodeTraits::get_next(this_node));
+ node_ptr prev(NodeTraits::get_previous(this_node));
+ NodeTraits::set_next(prev, next);
+ NodeTraits::set_previous(next, prev);
+ return next;
+ }
+ else{
+ return this_node;
+ }
+ }
+
+ //! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range.
+ //!
+ //! <b>Effects</b>: Unlinks the node [b, e) from the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void unlink(node_ptr b, node_ptr e)
+ {
+ if (b != e) {
+ node_ptr prevb(NodeTraits::get_previous(b));
+ NodeTraits::set_previous(e, prevb);
+ NodeTraits::set_next(prevb, e);
+ }
+ }
+
+ //! <b>Requires</b>: nxt_node must be a node of a circular list.
+ //!
+ //! <b>Effects</b>: Links this_node before nxt_node in the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void link_before(node_ptr nxt_node, node_ptr this_node)
+ {
+ node_ptr prev(NodeTraits::get_previous(nxt_node));
+ NodeTraits::set_previous(this_node, prev);
+ NodeTraits::set_next(prev, this_node);
+ NodeTraits::set_previous(nxt_node, this_node);
+ NodeTraits::set_next(this_node, nxt_node);
+ }
+
+ //! <b>Requires</b>: prev_node must be a node of a circular list.
+ //!
+ //! <b>Effects</b>: Links this_node after prev_node in the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void link_after(node_ptr prev_node, node_ptr this_node)
+ {
+ node_ptr next(NodeTraits::get_next(prev_node));
+ NodeTraits::set_previous(this_node, prev_node);
+ NodeTraits::set_next(this_node, next);
+ NodeTraits::set_previous(next, this_node);
+ NodeTraits::set_next(prev_node, this_node);
+ }
+
+ //! <b>Requires</b>: this_node and other_node must be nodes inserted
+ //! in circular lists or be empty circular lists.
+ //!
+ //! <b>Effects</b>: Swaps the position of the nodes: this_node is inserted in
+ //! other_nodes position in the second circular list and the other_node is inserted
+ //! in this_node's position in the first circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+/*
+ static void swap_nodes(node_ptr this_node, node_ptr other_node)
+ {
+
+ if (other_node == this_node)
+ return;
+ bool empty1 = unique(this_node);
+ bool empty2 = unique(other_node);
+
+ node_ptr next_this(NodeTraits::get_next(this_node));
+ node_ptr prev_this(NodeTraits::get_previous(this_node));
+ node_ptr next_other(NodeTraits::get_next(other_node));
+ node_ptr prev_other(NodeTraits::get_previous(other_node));
+
+ //Do the swap
+ NodeTraits::set_next(this_node, next_other);
+ NodeTraits::set_next(other_node, next_this);
+
+ NodeTraits::set_previous(this_node, prev_other);
+ NodeTraits::set_previous(other_node, prev_this);
+
+ if (empty2){
+ init(this_node);
+ }
+ else{
+ NodeTraits::set_next(prev_other, this_node);
+ NodeTraits::set_previous(next_other, this_node);
+ }
+ if (empty1){
+ init(other_node);
+ }
+ else{
+ NodeTraits::set_next(prev_this, other_node);
+ NodeTraits::set_previous(next_this, other_node);
+ }
+ }
+*/
+
+ //Watanabe version
+ private:
+ static void swap_prev(node_ptr this_node, node_ptr other_node)
+ {
+ node_ptr temp(NodeTraits::get_previous(this_node));
+ NodeTraits::set_previous(this_node, NodeTraits::get_previous(other_node));
+ NodeTraits::set_previous(other_node, temp);
+ }
+ static void swap_next(node_ptr this_node, node_ptr other_node)
+ {
+ node_ptr temp(NodeTraits::get_next(this_node));
+ NodeTraits::set_next(this_node, NodeTraits::get_next(other_node));
+ NodeTraits::set_next(other_node, temp);
+ }
+
+ public:
+ static void swap_nodes(node_ptr this_node, node_ptr other_node)
+ {
+ if (other_node == this_node)
+ return;
+ bool this_inited = inited(this_node);
+ bool other_inited = inited(other_node);
+ if(this_inited){
+ init_header(this_node);
+ }
+ if(other_inited){
+ init_header(other_node);
+ }
+
+ node_ptr next_this(NodeTraits::get_next(this_node));
+ node_ptr prev_this(NodeTraits::get_previous(this_node));
+ node_ptr next_other(NodeTraits::get_next(other_node));
+ node_ptr prev_other(NodeTraits::get_previous(other_node));
+ //these first two swaps must happen before the other two
+ swap_prev(next_this, next_other);
+ swap_next(prev_this, prev_other);
+ swap_next(this_node, other_node);
+ swap_prev(this_node, other_node);
+
+ if(this_inited){
+ init(other_node);
+ }
+ if(other_inited){
+ init(this_node);
+ }
+ }
+
+ //! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range.
+ //! and p must be a node of a different circular list or may not be an iterator in
+ // [b, e).
+ //!
+ //! <b>Effects</b>: Removes the nodes from [b, e) range from their circular list and inserts
+ //! them before p in p's circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void transfer(node_ptr p, node_ptr b, node_ptr e)
+ {
+ if (b != e) {
+ node_ptr prev_p(NodeTraits::get_previous(p));
+ node_ptr prev_b(NodeTraits::get_previous(b));
+ node_ptr prev_e(NodeTraits::get_previous(e));
+ NodeTraits::set_next(prev_e, p);
+ NodeTraits::set_previous(p, prev_e);
+ NodeTraits::set_next(prev_b, e);
+ NodeTraits::set_previous(e, prev_b);
+ NodeTraits::set_next(prev_p, b);
+ NodeTraits::set_previous(b, prev_p);
+ }
+ }
+
+ //! <b>Requires</b>: i must a node of a circular list
+ //! and p must be a node of a different circular list.
+ //!
+ //! <b>Effects</b>: Removes the node i from its circular list and inserts
+ //! it before p in p's circular list.
+ //! If p == i or p == NodeTraits::get_next(i), this function is a null operation.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void transfer(node_ptr p, node_ptr i)
+ {
+ node_ptr n(NodeTraits::get_next(i));
+ if(n != p && i != p){
+ node_ptr prev_p(NodeTraits::get_previous(p));
+ node_ptr prev_i(NodeTraits::get_previous(i));
+ NodeTraits::set_next(prev_p, i);
+ NodeTraits::set_previous(i, prev_p);
+ NodeTraits::set_next(i, p);
+ NodeTraits::set_previous(p, i);
+ NodeTraits::set_previous(n, prev_i);
+ NodeTraits::set_next(prev_i, n);
+
+ }
+ }
+
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear time.
+ static void reverse(node_ptr p)
+ {
+ node_ptr f(NodeTraits::get_next(p));
+ node_ptr i(NodeTraits::get_next(f)), e(p);
+
+ while(i != e) {
+ node_ptr n = i;
+ i = NodeTraits::get_next(i);
+ transfer(f, n, i);
+ f = n;
+ }
+ }
+
+ //! <b>Effects</b>: Moves the node p n positions towards the end of the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of moved positions.
+ static void move_backwards(node_ptr p, std::size_t n)
+ {
+ //Null shift, nothing to do
+ if(!n) return;
+ node_ptr first = NodeTraits::get_next(p);
+ //size() == 0 or 1, nothing to do
+ if(first == NodeTraits::get_previous(p)) return;
+ unlink(p);
+ //Now get the new first node
+ while(n--){
+ first = NodeTraits::get_next(first);
+ }
+ link_before(first, p);
+ }
+
+ //! <b>Effects</b>: Moves the node p n positions towards the beginning of the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of moved positions.
+ static void move_forward(node_ptr p, std::size_t n)
+ {
+ //Null shift, nothing to do
+ if(!n) return;
+ node_ptr last = NodeTraits::get_previous(p);
+ //size() == 0 or 1, nothing to do
+ if(last == NodeTraits::get_next(p)) return;
+
+ unlink(p);
+ //Now get the new last node
+ while(n--){
+ last = NodeTraits::get_previous(last);
+ }
+ link_after(last, p);
+ }
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_CIRCULAR_LIST_ALGORITHMS_HPP
Added: sandbox/boost/intrusive/circular_slist_algorithms.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/circular_slist_algorithms.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,405 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Olaf Krzikalla 2004-2006.
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP
+#define BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/common_slist_algorithms.hpp>
+#include <boost/intrusive/detail/assert.hpp>
+#include <cstddef>
+
+namespace boost {
+namespace intrusive {
+
+//! circular_slist_algorithms provides basic algorithms to manipulate nodes
+//! forming a circular singly linked list. An empty circular list is formed by a node
+//! whose pointer to the next node points to itself.
+//!
+//! circular_slist_algorithms is configured with a NodeTraits class, which encapsulates the
+//! information about the node to be manipulated. NodeTraits must support the
+//! following interface:
+//!
+//! <b>Typedefs</b>:
+//!
+//! <tt>node</tt>: The type of the node that forms the circular list
+//!
+//! <tt>node_ptr</tt>: A pointer to a node
+//!
+//! <tt>const_node_ptr</tt>: A pointer to a const node
+//!
+//! <b>Static functions</b>:
+//!
+//! <tt>static node_ptr get_next(const_node_ptr n);</tt>
+//!
+//! <tt>static void set_next(node_ptr n, node_ptr next);</tt>
+template<class NodeTraits>
+class circular_slist_algorithms
+ /// @cond
+ : public detail::common_slist_algorithms<NodeTraits>
+ /// @endcond
+{
+ /// @cond
+ typedef detail::common_slist_algorithms<NodeTraits> base_t;
+ /// @endcond
+ public:
+ typedef typename NodeTraits::node node;
+ typedef typename NodeTraits::node_ptr node_ptr;
+ typedef typename NodeTraits::const_node_ptr const_node_ptr;
+ typedef NodeTraits node_traits;
+
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Constructs an non-used list element, putting the next
+ //! pointer to null:
+ //! <tt>NodeTraits::get_next(this_node) == 0
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void init(node_ptr this_node);
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Returns true is "this_node" is the only node of a circular list:
+ //! or it's a not inserted node:
+ //! <tt>return !NodeTraits::get_next(this_node) || NodeTraits::get_next(this_node) == this_node</tt>
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool unique(const_node_ptr this_node);
+
+ //! <b>Effects</b>: Returns true is "this_node" has the same state as
+ //! if it was inited using "init(node_ptr)"
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool inited(const_node_ptr this_node);
+
+ //! <b>Requires</b>: prev_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Unlinks the next node of prev_node from the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void unlink_after(node_ptr prev_node);
+
+ //! <b>Requires</b>: prev_node and last_node must be in a circular list
+ //! or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Unlinks the range (prev_node, last_node) from the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void unlink_after(node_ptr prev_node, node_ptr last_node);
+
+ //! <b>Requires</b>: prev_node must be a node of a circular list.
+ //!
+ //! <b>Effects</b>: Links this_node after prev_node in the circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void link_after(node_ptr prev_node, node_ptr this_node);
+
+ //! <b>Requires</b>: b and e must be nodes of the same circular list or an empty range.
+ //! and p must be a node of a different circular list.
+ //!
+ //! <b>Effects</b>: Removes the nodes from (b, e] range from their circular list and inserts
+ //! them after p in p's circular list.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void transfer_after(node_ptr p, node_ptr b, node_ptr e);
+
+ #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Constructs an empty list, making this_node the only
+ //! node of the circular list:
+ //! <tt>NodeTraits::get_next(this_node) == this_node</tt>.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void init_header(node_ptr this_node)
+ { NodeTraits::set_next(this_node, this_node); }
+
+ //! <b>Requires</b>: this_node and prev_init_node must be in the same circular list.
+ //!
+ //! <b>Effects</b>: Returns the previous node of this_node in the circular list starting.
+ //! the search from prev_init_node. The first node checked for equality
+ //! is NodeTraits::get_next(prev_init_node).
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements between prev_init_node and this_node.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr get_previous_node(node_ptr prev_init_node, node_ptr this_node)
+ { return base_t::get_previous_node(prev_init_node, this_node); }
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Returns the previous node of this_node in the circular list.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in the circular list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr get_previous_node(node_ptr this_node)
+ { return base_t::get_previous_node(this_node, this_node); }
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Returns the previous node of the previous node of this_node in the circular list.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in the circular list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr get_previous_previous_node(node_ptr this_node)
+ { return get_previous_previous_node(this_node, this_node); }
+
+ //! <b>Requires</b>: this_node and prev_prev_init_node must be in the same circular list.
+ //!
+ //! <b>Effects</b>: Returns the previous node of the previous node of this_node in the
+ //! circular list starting. the search from prev_init_node. The first node checked
+ //! for equality is NodeTraits::get_next((NodeTraits::get_next(prev_prev_init_node)).
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in the circular list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr get_previous_previous_node(node_ptr prev_prev_init_node, node_ptr this_node)
+ {
+ node_ptr p = prev_prev_init_node;
+ node_ptr p_next = NodeTraits::get_next(p);
+ node_ptr p_next_next = NodeTraits::get_next(p_next);
+ while (this_node != p_next_next){
+ p = p_next;
+ p_next = p_next_next;
+ p_next_next = NodeTraits::get_next(p_next);
+ }
+ return p;
+ }
+
+ //! <b>Requires</b>: this_node must be in a circular list or be an empty circular list.
+ //!
+ //! <b>Effects</b>: Returns the number of nodes in a circular list. If the circular list
+ //! is empty, returns 1.
+ //!
+ //! <b>Complexity</b>: Constant
+ //!
+ //! <b>Throws</b>: Nothing.
+ static std::size_t count(const_node_ptr this_node)
+ {
+ std::size_t result = 0;
+ const_node_ptr p = this_node;
+ do{
+ p = NodeTraits::get_next(p);
+ ++result;
+ } while (p != this_node);
+ return result;
+ }
+
+ //! <b>Requires</b>: this_node must be in a circular list, be an empty circular list or be inited.
+ //!
+ //! <b>Effects</b>: Unlinks the node from the circular list.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in the circular list
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void unlink(node_ptr this_node)
+ {
+ if(NodeTraits::get_next(this_node))
+ base_t::unlink_after(get_previous_node(this_node));
+ }
+
+ //! <b>Requires</b>: nxt_node must be a node of a circular list.
+ //!
+ //! <b>Effects</b>: Links this_node before nxt_node in the circular list.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements in the circular list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void link_before (node_ptr nxt_node, node_ptr this_node)
+ { base_t::link_after(get_previous_node(nxt_node), this_node); }
+
+ //! <b>Requires</b>: this_node and other_node must be nodes inserted
+ //! in circular lists or be empty circular lists.
+ //!
+ //! <b>Effects</b>: Swaps the position of the nodes: this_node is inserted in
+ //! other_nodes position in the second circular list and the other_node is inserted
+ //! in this_node's position in the first circular list.
+ //!
+ //! <b>Complexity</b>: Linear to number of elements of both lists
+ //!
+ //! <b>Throws</b>: Nothing.
+ static void swap_nodes(node_ptr this_node, node_ptr other_node)
+ {
+ if (other_node == this_node)
+ return;
+ bool this_inited = base_t::inited(this_node);
+ bool other_inited = base_t::inited(other_node);
+ if(this_inited){
+ base_t::init_header(this_node);
+ }
+ if(other_inited){
+ base_t::init_header(other_node);
+ }
+
+ bool empty1 = base_t::unique(this_node);
+ bool empty2 = base_t::unique(other_node);
+ node_ptr prev_this (get_previous_node(this_node));
+ node_ptr prev_other(get_previous_node(other_node));
+
+ node_ptr this_next (NodeTraits::get_next(this_node));
+ node_ptr other_next(NodeTraits::get_next(other_node));
+ NodeTraits::set_next(this_node, other_next);
+ NodeTraits::set_next(other_node, this_next);
+ NodeTraits::set_next(empty1 ? other_node : prev_this, other_node);
+ NodeTraits::set_next(empty2 ? this_node : prev_other, this_node);
+
+ if(this_inited){
+ base_t::init(other_node);
+ }
+ if(other_inited){
+ base_t::init(this_node);
+ }
+ }
+
+ //! <b>Effects</b>: Reverses the order of elements in the list.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: This function is linear to the contained elements.
+ static void reverse(node_ptr p)
+ {
+ node_ptr i = NodeTraits::get_next(p), e(p);
+ for (;;) {
+ node_ptr nxt(NodeTraits::get_next(i));
+ if (nxt == e)
+ break;
+ base_t::transfer_after(e, i, nxt);
+ }
+ }
+
+ //! <b>Effects</b>: Moves the node p n positions towards the end of the list.
+ //!
+ //! <b>Returns</b>: The previous node of p after the function if there has been any movement,
+ //! Null if n leads to no movement.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements plus the number moved positions.
+ static node_ptr move_backwards(node_ptr p, std::size_t n)
+ {
+ //Null shift, nothing to do
+ if(!n) return node_ptr(0);
+ node_ptr first = NodeTraits::get_next(p);
+
+ //count() == 1 or 2, nothing to do
+ if(NodeTraits::get_next(first) == p)
+ return node_ptr(0);
+
+ bool end_found = false;
+ node_ptr new_last(0);
+
+ //Now find the new last node according to the shift count.
+ //If we find p before finding the new last node
+ //unlink p, shortcut the search now that we know the size of the list
+ //and continue.
+ for(std::size_t i = 1; i <= n; ++i){
+ new_last = first;
+ first = NodeTraits::get_next(first);
+ if(first == p){
+ //Shortcut the shift with the modulo of the size of the list
+ n %= i;
+ if(!n)
+ return node_ptr(0);
+ i = 0;
+ //Unlink p and continue the new first node search
+ first = NodeTraits::get_next(p);
+ base_t::unlink_after(new_last);
+ end_found = true;
+ }
+ }
+
+ //If the p has not been found in the previous loop, find it
+ //starting in the new first node and unlink it
+ if(!end_found){
+ base_t::unlink_after(base_t::get_previous_node(first, p));
+ }
+
+ //Now link p after the new last node
+ base_t::link_after(new_last, p);
+ return new_last;
+ }
+
+ //! <b>Effects</b>: Moves the node p n positions towards the beginning of the list.
+ //!
+ //! <b>Returns</b>: The previous node of p after the function if there has been any movement,
+ //! Null if n leads equals to no movement.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the number of elements plus the number moved positions.
+ static node_ptr move_forward(node_ptr p, std::size_t n)
+ {
+ //Null shift, nothing to do
+ if(!n) return node_ptr(0);
+ node_ptr first = node_traits::get_next(p);
+
+ //count() == 1 or 2, nothing to do
+ if(node_traits::get_next(first) == p) return node_ptr(0);
+
+ //Iterate until p is found to know where the current last node is.
+ //If the shift count is less than the size of the list, we can also obtain
+ //the position of the new last node after the shift.
+ node_ptr old_last(first), next_to_it, new_last(p);
+ std::size_t distance = 1;
+ while(p != (next_to_it = node_traits::get_next(old_last))){
+ if(++distance > n)
+ new_last = node_traits::get_next(new_last);
+ old_last = next_to_it;
+ }
+ //If the shift was bigger or equal than the size, obtain the equivalent
+ //forward shifts and find the new last node.
+ if(distance <= n){
+ //Now find the equivalent forward shifts.
+ //Shortcut the shift with the modulo of the size of the list
+ std::size_t new_before_last_pos = (distance - (n % distance))% distance;
+ //If the shift is a multiple of the size there is nothing to do
+ if(!new_before_last_pos) return node_ptr(0);
+
+ for( new_last = p
+ ; new_before_last_pos--
+ ; new_last = node_traits::get_next(new_last)){
+ //empty
+ }
+ }
+
+ //Now unlink p and link it after the new last node
+ base_t::unlink_after(old_last);
+ base_t::link_after(new_last, p);
+ return new_last;
+ }
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_CIRCULAR_SLIST_ALGORITHMS_HPP
Added: sandbox/boost/intrusive/derivation_value_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/derivation_value_traits.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,56 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
+#define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
+
+#include <boost/intrusive/link_mode.hpp>
+#include <iterator>
+
+namespace boost {
+namespace intrusive {
+
+//!This value traits template is used to create value traits
+//!from user defined node traits where value_traits::value_type will
+//!derive from node_traits::node
+template<class T, class NodeTraits, link_mode_type LinkMode = safe_link>
+struct derivation_value_traits
+{
+ public:
+ typedef NodeTraits node_traits;
+ typedef T value_type;
+ typedef typename node_traits::node node;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::const_node_ptr const_node_ptr;
+ typedef typename boost::pointer_to_other<node_ptr, T>::type pointer;
+ typedef typename boost::pointer_to_other<node_ptr, const T>::type const_pointer;
+ typedef typename std::iterator_traits<pointer>::reference reference;
+ typedef typename std::iterator_traits<const_pointer>::reference const_reference;
+ static const link_mode_type link_mode = LinkMode;
+
+ static node_ptr to_node_ptr(reference value)
+ { return node_ptr(&value); }
+
+ static const_node_ptr to_node_ptr(const_reference value)
+ { return node_ptr(&value); }
+
+ static pointer to_value_ptr(node_ptr n)
+ { return pointer(static_cast<T*>(detail::get_pointer(n))); }
+
+ static const_pointer to_value_ptr(const_node_ptr n)
+ { return const_pointer(static_cast<T*>(detail::get_pointer(n))); }
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
Added: sandbox/boost/intrusive/detail/any_node_and_algorithms.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/any_node_and_algorithms.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,296 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_ANY_NODE_HPP
+#define BOOST_INTRUSIVE_ANY_NODE_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <iterator>
+#include <boost/intrusive/detail/assert.hpp>
+#include <boost/intrusive/detail/pointer_to_other.hpp>
+#include <cstddef>
+#include <boost/intrusive/detail/mpl.hpp>
+
+namespace boost {
+namespace intrusive {
+
+template<class VoidPointer>
+struct any_node
+{
+ typedef typename boost::pointer_to_other
+ <VoidPointer, any_node>::type node_ptr;
+ node_ptr node_ptr_1;
+ node_ptr node_ptr_2;
+ node_ptr node_ptr_3;
+ std::size_t size_t_1;
+};
+
+template<class VoidPointer>
+struct any_list_node_traits
+{
+ typedef any_node<VoidPointer> node;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+
+ static node_ptr get_next(const_node_ptr n)
+ { return n->node_ptr_1; }
+
+ static void set_next(node_ptr n, node_ptr next)
+ { n->node_ptr_1 = next; }
+
+ static node_ptr get_previous(const_node_ptr n)
+ { return n->node_ptr_2; }
+
+ static void set_previous(node_ptr n, node_ptr prev)
+ { n->node_ptr_2 = prev; }
+};
+
+
+template<class VoidPointer>
+struct any_slist_node_traits
+{
+ typedef any_node<VoidPointer> node;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+
+ static node_ptr get_next(const_node_ptr n)
+ { return n->node_ptr_1; }
+
+ static void set_next(node_ptr n, node_ptr next)
+ { n->node_ptr_1 = next; }
+};
+
+
+template<class VoidPointer>
+struct any_unordered_node_traits
+ : public any_slist_node_traits<VoidPointer>
+{
+ typedef any_slist_node_traits<VoidPointer> reduced_slist_node_traits;
+ typedef typename reduced_slist_node_traits::node node;
+ typedef typename reduced_slist_node_traits::node_ptr node_ptr;
+ typedef typename reduced_slist_node_traits::const_node_ptr const_node_ptr;
+
+ static const bool store_hash = true;
+ static const bool optimize_multikey = true;
+
+ static node_ptr get_next(const_node_ptr n)
+ { return node_ptr(&static_cast<node &>(*n->node_ptr_1)); }
+
+ static void set_next(node_ptr n, node_ptr next)
+ { n->node_ptr_1 = next; }
+
+ static node_ptr get_prev_in_group(const_node_ptr n)
+ { return n->node_ptr_2; }
+
+ static void set_prev_in_group(node_ptr n, node_ptr prev)
+ { n->node_ptr_2 = prev; }
+
+ static std::size_t get_hash(const_node_ptr n)
+ { return n->size_t_1; }
+
+ static void set_hash(node_ptr n, std::size_t h)
+ { n->size_t_1 = h; }
+};
+
+
+template<class VoidPointer>
+struct any_rbtree_node_traits
+{
+ typedef any_node<VoidPointer> node;
+
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+
+ typedef std::size_t color;
+
+ static node_ptr get_parent(const_node_ptr n)
+ { return n->node_ptr_1; }
+
+ static void set_parent(node_ptr n, node_ptr p)
+ { n->node_ptr_1 = p; }
+
+ static node_ptr get_left(const_node_ptr n)
+ { return n->node_ptr_2; }
+
+ static void set_left(node_ptr n, node_ptr l)
+ { n->node_ptr_2 = l; }
+
+ static node_ptr get_right(const_node_ptr n)
+ { return n->node_ptr_3; }
+
+ static void set_right(node_ptr n, node_ptr r)
+ { n->node_ptr_3 = r; }
+
+ static color get_color(const_node_ptr n)
+ { return n->size_t_1; }
+
+ static void set_color(node_ptr n, color c)
+ { n->size_t_1 = c; }
+
+ static color black()
+ { return 0u; }
+
+ static color red()
+ { return 1u; }
+};
+
+
+template<class VoidPointer>
+struct any_avltree_node_traits
+{
+ typedef any_node<VoidPointer> node;
+
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+ typedef std::size_t balance;
+
+ static node_ptr get_parent(const_node_ptr n)
+ { return n->node_ptr_1; }
+
+ static void set_parent(node_ptr n, node_ptr p)
+ { n->node_ptr_1 = p; }
+
+ static node_ptr get_left(const_node_ptr n)
+ { return n->node_ptr_2; }
+
+ static void set_left(node_ptr n, node_ptr l)
+ { n->node_ptr_2 = l; }
+
+ static node_ptr get_right(const_node_ptr n)
+ { return n->node_ptr_3; }
+
+ static void set_right(node_ptr n, node_ptr r)
+ { n->node_ptr_3 = r; }
+
+ static balance get_balance(const_node_ptr n)
+ { return n->size_t_1; }
+
+ static void set_balance(node_ptr n, balance b)
+ { n->size_t_1 = b; }
+
+ static balance negative()
+ { return 0u; }
+
+ static balance zero()
+ { return 1u; }
+
+ static balance positive()
+ { return 2u; }
+};
+
+
+template<class VoidPointer>
+struct any_tree_node_traits
+{
+ typedef any_node<VoidPointer> node;
+
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+
+ static node_ptr get_parent(const_node_ptr n)
+ { return n->node_ptr_1; }
+
+ static void set_parent(node_ptr n, node_ptr p)
+ { n->node_ptr_1 = p; }
+
+ static node_ptr get_left(const_node_ptr n)
+ { return n->node_ptr_2; }
+
+ static void set_left(node_ptr n, node_ptr l)
+ { n->node_ptr_2 = l; }
+
+ static node_ptr get_right(const_node_ptr n)
+ { return n->node_ptr_3; }
+
+ static void set_right(node_ptr n, node_ptr r)
+ { n->node_ptr_3 = r; }
+};
+
+template<class VoidPointer>
+class any_node_traits
+{
+ public:
+ typedef any_node<VoidPointer> node;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+};
+
+template<class VoidPointer>
+class any_algorithms
+{
+ template <class T>
+ static void function_not_available_for_any_hooks(typename detail::enable_if<detail::is_same<T, bool> >::type)
+ {}
+
+ public:
+ typedef any_node<VoidPointer> node;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+ typedef any_node_traits<VoidPointer> node_traits;
+
+ //! <b>Requires</b>: node must not be part of any tree.
+ //!
+ //! <b>Effects</b>: After the function unique(node) == true.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree.
+ static void init(node_ptr node)
+ { node->node_ptr_1 = 0; };
+
+ //! <b>Effects</b>: Returns true if node is in the same state as if called init(node)
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool inited(const_node_ptr node)
+ { return !node->node_ptr_1; };
+
+ static bool unique(const_node_ptr node)
+ { return 0 == node->node_ptr_1; }
+
+ static void unlink(node_ptr)
+ {
+ //Auto-unlink hooks and unlink() are not available for any hooks
+ any_algorithms<VoidPointer>::template function_not_available_for_any_hooks<node_ptr>();
+ }
+
+ static void swap_nodes(node_ptr l, node_ptr r)
+ {
+ //Any nodes have no swap_nodes capability because they don't know
+ //what algorithm they must use to unlink the node from the container
+ any_algorithms<VoidPointer>::template function_not_available_for_any_hooks<node_ptr>();
+ }
+};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_ANY_NODE_HPP
Added: sandbox/boost/intrusive/detail/assert.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/assert.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,41 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_DETAIL_ASSERT_HPP
+#define BOOST_INTRUSIVE_DETAIL_ASSERT_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#if !defined(BOOST_INTRUSIVE_INVARIANT_ASSERT)
+ #include <boost/assert.hpp>
+ #define BOOST_INTRUSIVE_INVARIANT_ASSERT BOOST_ASSERT
+#elif defined(BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE)
+ #include BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE
+#endif
+
+#if !defined(BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT)
+ #include <boost/assert.hpp>
+ #define BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT BOOST_ASSERT
+#elif defined(BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE)
+ #include BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT_INCLUDE
+#endif
+
+#if !defined(BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT)
+ #include <boost/assert.hpp>
+ #define BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT BOOST_ASSERT
+#elif defined(BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE)
+ #include BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT_INCLUDE
+#endif
+
+#endif //BOOST_INTRUSIVE_DETAIL_ASSERT_HPP
Added: sandbox/boost/intrusive/detail/avltree_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/avltree_node.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,179 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007.
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_AVLTREE_NODE_HPP
+#define BOOST_INTRUSIVE_AVLTREE_NODE_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <iterator>
+#include <boost/intrusive/detail/pointer_to_other.hpp>
+#include <boost/intrusive/avltree_algorithms.hpp>
+#include <boost/intrusive/pointer_plus_bits.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/////////////////////////////////////////////////////////////////////////////
+// //
+// Generic node_traits for any pointer type //
+// //
+/////////////////////////////////////////////////////////////////////////////
+
+//This is the compact representation: 3 pointers
+template<class VoidPointer>
+struct compact_avltree_node
+{
+ typedef typename pointer_to_other
+ <VoidPointer
+ ,compact_avltree_node<VoidPointer> >::type node_ptr;
+ enum balance { negative_t, zero_t, positive_t };
+ node_ptr parent_, left_, right_;
+};
+
+//This is the normal representation: 3 pointers + enum
+template<class VoidPointer>
+struct avltree_node
+{
+ typedef typename pointer_to_other
+ <VoidPointer
+ ,avltree_node<VoidPointer> >::type node_ptr;
+ enum balance { negative_t, zero_t, positive_t };
+ node_ptr parent_, left_, right_;
+ balance balance_;
+};
+
+//This is the default node traits implementation
+//using a node with 3 generic pointers plus an enum
+template<class VoidPointer>
+struct default_avltree_node_traits_impl
+{
+ typedef avltree_node<VoidPointer> node;
+
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+ typedef typename node::balance balance;
+
+ static node_ptr get_parent(const_node_ptr n)
+ { return n->parent_; }
+
+ static void set_parent(node_ptr n, node_ptr p)
+ { n->parent_ = p; }
+
+ static node_ptr get_left(const_node_ptr n)
+ { return n->left_; }
+
+ static void set_left(node_ptr n, node_ptr l)
+ { n->left_ = l; }
+
+ static node_ptr get_right(const_node_ptr n)
+ { return n->right_; }
+
+ static void set_right(node_ptr n, node_ptr r)
+ { n->right_ = r; }
+
+ static balance get_balance(const_node_ptr n)
+ { return n->balance_; }
+
+ static void set_balance(node_ptr n, balance b)
+ { n->balance_ = b; }
+
+ static balance negative()
+ { return node::negative_t; }
+
+ static balance zero()
+ { return node::zero_t; }
+
+ static balance positive()
+ { return node::positive_t; }
+};
+
+//This is the compact node traits implementation
+//using a node with 3 generic pointers
+template<class VoidPointer>
+struct compact_avltree_node_traits_impl
+{
+ typedef compact_avltree_node<VoidPointer> node;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, node>::type node_ptr;
+ typedef typename boost::pointer_to_other
+ <VoidPointer, const node>::type const_node_ptr;
+ typedef typename node::balance balance;
+
+ typedef pointer_plus_bits<node_ptr, 2> ptr_bit;
+
+ static node_ptr get_parent(const_node_ptr n)
+ { return ptr_bit::get_pointer(n->parent_); }
+
+ static void set_parent(node_ptr n, node_ptr p)
+ { ptr_bit::set_pointer(n->parent_, p); }
+
+ static node_ptr get_left(const_node_ptr n)
+ { return n->left_; }
+
+ static void set_left(node_ptr n, node_ptr l)
+ { n->left_ = l; }
+
+ static node_ptr get_right(const_node_ptr n)
+ { return n->right_; }
+
+ static void set_right(node_ptr n, node_ptr r)
+ { n->right_ = r; }
+
+ static balance get_balance(const_node_ptr n)
+ { return (balance)ptr_bit::get_bits(n->parent_); }
+
+ static void set_balance(node_ptr n, balance b)
+ { ptr_bit::set_bits(n->parent_, (std::size_t)b); }
+
+ static balance negative()
+ { return node::negative_t; }
+
+ static balance zero()
+ { return node::zero_t; }
+
+ static balance positive()
+ { return node::positive_t; }
+};
+
+//Dispatches the implementation based on the boolean
+template<class VoidPointer, bool Compact>
+struct avltree_node_traits_dispatch
+ : public default_avltree_node_traits_impl<VoidPointer>
+{};
+
+template<class VoidPointer>
+struct avltree_node_traits_dispatch<VoidPointer, true>
+ : public compact_avltree_node_traits_impl<VoidPointer>
+{};
+
+//Inherit from the detail::link_dispatch depending on the embedding capabilities
+template<class VoidPointer, bool OptimizeSize = false>
+struct avltree_node_traits
+ : public avltree_node_traits_dispatch
+ < VoidPointer
+ , OptimizeSize &&
+ max_pointer_plus_bits
+ < VoidPointer
+ , detail::alignment_of<compact_avltree_node<VoidPointer> >::value
+ >::value >= 2u
+ >
+{};
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_AVLTREE_NODE_HPP
Added: sandbox/boost/intrusive/detail/clear_on_destructor_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/clear_on_destructor_base.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,36 @@
+//////} // ///////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2008-2008. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_DETAIL_CLEAR_ON_DESTRUCTOR_HPP
+#define BOOST_INTRUSIVE_DETAIL_CLEAR_ON_DESTRUCTOR_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+
+namespace boost {
+namespace intrusive {
+namespace detail {
+
+template<class Derived>
+class clear_on_destructor_base
+{
+ protected:
+ ~clear_on_destructor_base()
+ {
+ static_cast<Derived*>(this)->clear();
+ }
+};
+
+} // namespace detail {
+} // namespace intrusive {
+} // namespace boost {
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //#ifndef BOOST_INTRUSIVE_DETAIL_CLEAR_ON_DESTRUCTOR_HPP
Added: sandbox/boost/intrusive/detail/common_slist_algorithms.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/common_slist_algorithms.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,96 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP
+#define BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/assert.hpp>
+#include <cstddef>
+
+namespace boost {
+namespace intrusive {
+namespace detail {
+
+template<class NodeTraits>
+class common_slist_algorithms
+{
+ public:
+ typedef typename NodeTraits::node node;
+ typedef typename NodeTraits::node_ptr node_ptr;
+ typedef typename NodeTraits::const_node_ptr const_node_ptr;
+ typedef NodeTraits node_traits;
+
+ static node_ptr get_previous_node(node_ptr prev_init_node, node_ptr this_node)
+ {
+ node_ptr p = prev_init_node;
+ for( node_ptr p_next
+ ; this_node != (p_next = NodeTraits::get_next(p))
+ ; p = p_next){
+ //Logic error: possible use of linear lists with
+ //operations only permitted with lists
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(p);
+ }
+ return p;
+ }
+
+ static void init_header(node_ptr this_node)
+ { NodeTraits::set_next(this_node, this_node); }
+
+ static void init(node_ptr this_node)
+ { NodeTraits::set_next(this_node, node_ptr(0)); }
+
+ static bool unique(const_node_ptr this_node)
+ {
+ node_ptr next = NodeTraits::get_next(this_node);
+ return !next || next == this_node;
+ }
+
+ static bool inited(const_node_ptr this_node)
+ { return !NodeTraits::get_next(this_node); }
+
+ static void unlink_after(node_ptr prev_node)
+ {
+ node_ptr this_node(NodeTraits::get_next(prev_node));
+ NodeTraits::set_next(prev_node, NodeTraits::get_next(this_node));
+ }
+
+ static void unlink_after(node_ptr prev_node, node_ptr last_node)
+ { NodeTraits::set_next(prev_node, last_node); }
+
+ static void link_after(node_ptr prev_node, node_ptr this_node)
+ {
+ NodeTraits::set_next(this_node, NodeTraits::get_next(prev_node));
+ NodeTraits::set_next(prev_node, this_node);
+ }
+
+ static void transfer_after(node_ptr p, node_ptr b, node_ptr e)
+ {
+ if (p != b && p != e && b != e) {
+ node_ptr next_b = NodeTraits::get_next(b);
+ node_ptr next_e = NodeTraits::get_next(e);
+ node_ptr next_p = NodeTraits::get_next(p);
+ NodeTraits::set_next(b, next_e);
+ NodeTraits::set_next(e, next_p);
+ NodeTraits::set_next(p, next_b);
+ }
+ }
+};
+
+} //namespace detail
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_COMMON_SLIST_ALGORITHMS_HPP
Added: sandbox/boost/intrusive/detail/config_begin.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/config_begin.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,52 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_CONFIG_INCLUDED
+#define BOOST_INTRUSIVE_CONFIG_INCLUDED
+#include <boost/config.hpp>
+#endif
+
+#ifdef BOOST_MSVC
+
+ #pragma warning (push)
+ //
+ //'function' : resolved overload was found by argument-dependent lookup
+ //A function found by argument-dependent lookup (Koenig lookup) was eventually
+ //chosen by overload resolution.
+ //
+ //In Visual C++ .NET and earlier compilers, a different function would have
+ //been called. To pick the original function, use an explicitly qualified name.
+ //
+
+ //warning C4275: non dll-interface class 'x' used as base for
+ //dll-interface class 'Y'
+ #pragma warning (disable : 4275)
+ //warning C4251: 'x' : class 'y' needs to have dll-interface to
+ //be used by clients of class 'z'
+ #pragma warning (disable : 4251)
+ #pragma warning (disable : 4675)
+ #pragma warning (disable : 4996)
+ #pragma warning (disable : 4503)
+ #pragma warning (disable : 4284) // odd return type for operator->
+ #pragma warning (disable : 4244) // possible loss of data
+ #pragma warning (disable : 4521) ////Disable "multiple copy constructors specified"
+ #pragma warning (disable : 4522)
+ #pragma warning (disable : 4146)
+ #pragma warning (disable : 4267) //conversion from 'X' to 'Y', possible loss of data
+ #pragma warning (disable : 4127) //conditional expression is constant
+ #pragma warning (disable : 4706) //assignment within conditional expression
+ #pragma warning (disable : 4541) //'typeid' used on polymorphic type 'boost::exception' with /GR-
+ #pragma warning (disable : 4512) //'typeid' used on polymorphic type 'boost::exception' with /GR-
+#endif
+
+//#define BOOST_INTRUSIVE_USE_ITERATOR_FACADE
+//#define BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE
Added: sandbox/boost/intrusive/detail/config_end.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/config_end.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,15 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#if defined BOOST_MSVC
+ #pragma warning (pop)
+#endif
Added: sandbox/boost/intrusive/detail/ebo_functor_holder.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/ebo_functor_holder.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,92 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Joaquin M Lopez Munoz 2006-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
+#define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
+
+#include <boost/intrusive/detail/mpl.hpp>
+
+namespace boost {
+namespace intrusive {
+namespace detail {
+
+template<typename T, bool IsEmpty = true>
+class ebo_functor_holder_impl
+{
+ public:
+ ebo_functor_holder_impl()
+ {}
+ ebo_functor_holder_impl(const T& t)
+ : t(t)
+ {}
+ template<class Arg1, class Arg2>
+ ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
+ : t(arg1, arg2)
+ {}
+
+ T& get(){return t;}
+ const T& get()const{return t;}
+
+ private:
+ T t;
+};
+
+template<typename T>
+class ebo_functor_holder_impl<T, false>
+ : public T
+{
+ public:
+ ebo_functor_holder_impl()
+ {}
+ ebo_functor_holder_impl(const T& t)
+ : T(t)
+ {}
+ template<class Arg1, class Arg2>
+ ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
+ : T(arg1, arg2)
+ {}
+
+ T& get(){return *this;}
+ const T& get()const{return *this;}
+};
+
+template<typename T>
+class ebo_functor_holder
+ : public ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value>
+{
+ private:
+ typedef ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> super;
+
+ public:
+ ebo_functor_holder(){}
+ ebo_functor_holder(const T& t)
+ : super(t)
+ {}
+
+ template<class Arg1, class Arg2>
+ ebo_functor_holder(const Arg1& arg1, const Arg2& arg2)
+ : super(arg1, arg2)
+ {}
+
+ ebo_functor_holder& operator=(const ebo_functor_holder& x)
+ {
+ this->get()=x.get();
+ return *this;
+ }
+};
+
+
+} //namespace detail {
+} //namespace intrusive {
+} //namespace boost {
+
+#endif //#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
Added: sandbox/boost/intrusive/detail/generic_hook.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/generic_hook.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,203 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_GENERIC_HOOK_HPP
+#define BOOST_INTRUSIVE_GENERIC_HOOK_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/pointer_to_other.hpp>
+#include <boost/intrusive/link_mode.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
+#include <boost/static_assert.hpp>
+
+namespace boost {
+namespace intrusive {
+namespace detail {
+
+/// @cond
+
+enum
+{ NoBaseHook
+, ListBaseHook
+, SlistBaseHook
+, SetBaseHook
+, UsetBaseHook
+, SplaySetBaseHook
+, AvlSetBaseHook
+, BsSetBaseHook
+, AnyBaseHook
+};
+
+struct no_default_definer{};
+
+template <class Hook, unsigned int>
+struct default_definer;
+
+template <class Hook>
+struct default_definer<Hook, ListBaseHook>
+{ typedef Hook default_list_hook; };
+
+template <class Hook>
+struct default_definer<Hook, SlistBaseHook>
+{ typedef Hook default_slist_hook; };
+
+template <class Hook>
+struct default_definer<Hook, SetBaseHook>
+{ typedef Hook default_set_hook; };
+
+template <class Hook>
+struct default_definer<Hook, UsetBaseHook>
+{ typedef Hook default_uset_hook; };
+
+template <class Hook>
+struct default_definer<Hook, SplaySetBaseHook>
+{ typedef Hook default_splay_set_hook; };
+
+template <class Hook>
+struct default_definer<Hook, AvlSetBaseHook>
+{ typedef Hook default_avl_set_hook; };
+
+template <class Hook>
+struct default_definer<Hook, BsSetBaseHook>
+{ typedef Hook default_bs_set_hook; };
+
+template <class Hook>
+struct default_definer<Hook, AnyBaseHook>
+{ typedef Hook default_any_hook; };
+
+template <class Hook, unsigned int BaseHookType>
+struct make_default_definer
+{
+ typedef typename detail::if_c
+ < BaseHookType != 0
+ , default_definer<Hook, BaseHookType>
+ , no_default_definer>::type type;
+};
+
+template
+ < class GetNodeAlgorithms
+ , class Tag
+ , link_mode_type LinkMode
+ , int HookType
+ >
+struct make_node_holder
+{
+ typedef typename detail::if_c
+ <!detail::is_same<Tag, member_tag>::value
+ , detail::node_holder
+ < typename GetNodeAlgorithms::type::node
+ , Tag
+ , LinkMode
+ , HookType>
+ , typename GetNodeAlgorithms::type::node
+ >::type type;
+};
+
+/// @endcond
+
+template
+ < class GetNodeAlgorithms
+ , class Tag
+ , link_mode_type LinkMode
+ , int HookType
+ >
+class generic_hook
+ /// @cond
+
+ //If the hook is a base hook, derive generic hook from detail::node_holder
+ //so that a unique base class is created to convert from the node
+ //to the type. This mechanism will be used by base_hook_traits.
+ //
+ //If the hook is a member hook, generic hook will directly derive
+ //from the hook.
+ : public make_default_definer
+ < generic_hook<GetNodeAlgorithms, Tag, LinkMode, HookType>
+ , detail::is_same<Tag, default_tag>::value*HookType
+ >::type
+ , public make_node_holder<GetNodeAlgorithms, Tag, LinkMode, HookType>::type
+ /// @endcond
+{
+ /// @cond
+ typedef typename GetNodeAlgorithms::type node_algorithms;
+ typedef typename node_algorithms::node node;
+ typedef typename node_algorithms::node_ptr node_ptr;
+ typedef typename node_algorithms::const_node_ptr const_node_ptr;
+
+ public:
+ struct boost_intrusive_tags
+ {
+ static const int hook_type = HookType;
+ static const link_mode_type link_mode = LinkMode;
+ typedef Tag tag;
+ typedef typename GetNodeAlgorithms::type::node_traits node_traits;
+ static const bool is_base_hook = !detail::is_same<Tag, member_tag>::value;
+ static const bool safemode_or_autounlink =
+ (int)link_mode == (int)auto_unlink || (int)link_mode == (int)safe_link;
+ };
+
+ public:
+ /// @endcond
+
+ generic_hook()
+ {
+ if(boost_intrusive_tags::safemode_or_autounlink){
+ node_algorithms::init(static_cast<node*>(this));
+ }
+ }
+
+ generic_hook(const generic_hook& )
+ {
+ if(boost_intrusive_tags::safemode_or_autounlink){
+ node_algorithms::init(static_cast<node*>(this));
+ }
+ }
+
+ generic_hook& operator=(const generic_hook& )
+ { return *this; }
+
+ ~generic_hook()
+ {
+ destructor_impl
+ (*this, detail::link_dispatch<boost_intrusive_tags::link_mode>());
+ }
+
+ void swap_nodes(generic_hook &other)
+ {
+ node_algorithms::swap_nodes
+ ( static_cast<node*>(this), static_cast<node*>(&other));
+ }
+
+ bool is_linked() const
+ {
+ //is_linked() can be only used in safe-mode or auto-unlink
+ BOOST_STATIC_ASSERT(( boost_intrusive_tags::safemode_or_autounlink ));
+ return !node_algorithms::unique
+ (static_cast<const node*>(this));
+ }
+
+ void unlink()
+ {
+ BOOST_STATIC_ASSERT(( (int)boost_intrusive_tags::link_mode == (int)auto_unlink ));
+ node_algorithms::unlink(static_cast<node*>(this));
+ node_algorithms::init(static_cast<node*>(this));
+ }
+};
+
+} //namespace detail
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_GENERIC_HOOK_HPP
Added: sandbox/boost/intrusive/detail/hashtable_node.hpp
==============================================================================
--- (empty file)
+++ sandbox/boost/intrusive/detail/hashtable_node.hpp 2009-02-17 13:14:07 EST (Tue, 17 Feb 2009)
@@ -0,0 +1,200 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2008
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_HASHTABLE_NODE_HPP
+#define BOOST_INTRUSIVE_HASHTABLE_NODE_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <iterator>
+#include <boost/intrusive/detail/assert.hpp>
+#include <boost/intrusive/detail/pointer_to_other.hpp>
+#include <boost/intrusive/circular_list_algorithms.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/slist_node.hpp> //remove-me
+#include <cstddef>
+
+namespace boost {
+namespace intrusive {
+namespace detail {
+
+template<int Dummy = 0>
+struct prime_list_holder
+{
+ static const std::size_t prime_list[];
+ static const std::size_t prime_list_size;
+};
+
+template<int Dummy>
+const std::size_t prime_list_holder<Dummy>::prime_list[] = {
+ 53ul, 97ul, 193ul, 389ul, 769ul,
+ 1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
+ 49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
+ 1572869ul, 3145739ul, 6291469ul, 12582917ul, 25165843ul,
+ 50331653ul, 100663319ul, 201326611ul, 402653189ul, 805306457ul,
+ 1610612741ul, 3221225473ul, 4294967291ul };
+
+template<int Dummy>
+const std::size_t prime_list_holder<Dummy>::prime_list_size
+ = sizeof(prime_list)/sizeof(std::size_t);
+
+template <class Slist>
+struct bucket_impl : public Slist
+{
+ typedef Slist slist_type;
+ bucket_impl()
+ {}
+
+ bucket_impl(const bucket_impl &)
+ {}
+
+ ~bucket_impl()
+ {
+ //This bucket is still being used!
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty());
+ }
+
+ bucket_impl &operator=(const bucket_impl&)
+ {
+ //This bucket is still in use!
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(Slist::empty());
+ //Slist::clear();
+ return *this;
+ }
+};
+
+template<class Slist>
+struct bucket_traits_impl
+{
+ /// @cond
+ typedef typename boost::pointer_to_other
+ < typename Slist::pointer, bucket_impl<Slist> >::type bucket_ptr;
+ typedef typename Slist::size_type size_type;
+ /// @endcond
+
+ bucket_traits_impl(bucket_ptr buckets, size_type len)
+ : buckets_(buckets), buckets_len_(len)
+ {}
+
+ bucket_ptr bucket_begin() const
+ { return buckets_; }
+
+ size_type bucket_count() const
+ { return buckets_len_; }
+
+ private:
+ bucket_ptr buckets_;
+ size_type buckets_len_;
+};
+
+template<class Container, bool IsConst>
+class hashtable_iterator
+ : public std::iterator
+ < std::forward_iterator_tag
+ , typename detail::add_const_if_c
+ <typename Container::value_type, IsConst>::type
+ >
+{
+ typedef typename Container::real_value_traits real_value_traits;
+ typedef typename Container::siterator siterator;
+ typedef typename Container::const_siterator const_siterator;
+ typedef typename Container::bucket_type bucket_type;
+ typedef typename boost::pointer_to_other
+ < typename Container::pointer, const Container>::type const_cont_ptr;
+ typedef typename Container::size_type size_type;
+
+ static typename Container::node_ptr downcast_bucket(typename bucket_type::node_ptr p)
+ { return typename Container::node_ptr(&static_cast<typename Container::node&>(*p)); }
+
+ public:
+ typedef typename detail::add_const_if_c
+ <typename Container::value_type, IsConst>::type value_type;
+
+ hashtable_iterator ()
+ {}
+
+ explicit hashtable_iterator(siterator ptr, const Container *cont)
+ : slist_it_ (ptr), cont_ (cont)
+ {}
+
+ hashtable_iterator(const hashtable_iterator<Container, false> &other)
+ : slist_it_(other.slist_it()), cont_(other.get_container())
+ {}
+
+ const siterator &slist_it() const
+ { return slist_it_; }
+
+ public:
+ hashtable_iterator& operator++()
+ { this->increment(); return *this; }
+
+ hashtable_iterator operator++(int)
+ {
+ hashtable_iterator result (*this);
+ this->increment();
+ return result;
+ }
+
+ friend bool operator== (const hashtable_iterator& i, const hashtable_iterator& i2)
+ { return i.slist_it_ == i2.slist_it_; }
+
+ friend bool operator!= (const hashtable_iterator& i, const hashtable_iterator& i2)
+ { return !(i == i2); }
+
+ value_type& operator*() const
+ { return *this->operator ->(); }
+
+ value_type* operator->() const
+ { return detail::get_pointer(this->get_real_value_traits()->to_value_ptr(downcast_bucket(slist_it_.pointed_node()))); }
+
+ const Container *get_container() const
+ { return detail::get_pointer(cont_); }
+
+ const real_value_traits *get_real_value_traits() const
+ { return &this->get_container()->get_real_value_traits(); }
+
+ private:
+ void increment()
+ {
+ const Container *cont = detail::get_pointer(cont_);
+ bucket_type* buckets = detail::get_pointer(cont->bucket_pointer());
+ size_type buckets_len = cont->bucket_count();
+
+ ++slist_it_;
+ if(buckets[0].cend().pointed_node() <= slist_it_.pointed_node() &&
+ slist_it_.pointed_node()<= buckets[buckets_len].cend().pointed_node() ){
+ //Now get the bucket_impl from the iterator
+ const bucket_type &b = static_cast<const bucket_type&>
+ (bucket_type::slist_type::container_from_end_iterator(slist_it_));
+
+ //Now just calculate the index b has in the bucket array
+ size_type n_bucket = static_cast<size_type>(&b - &buckets[0]);
+ do{
+ if (++n_bucket == buckets_len){
+ slist_it_ = (&buckets[0] + buckets_len)->end();
+ break;
+ }
+ slist_it_ = buckets[n_bucket].begin();
+ }
+ while (slist_it_ == buckets[n_bucket].end());
+ }
+ }
+
+ siterator slist_it_;
+ const_cont_ptr cont_;
+};
+
+} //namespace detail {
+} //namespace intrusive {
+} //namespace boost {
+
+#endif
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk