Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85445 - in branches/release: boost/intrusive boost/intrusive/detail libs/intrusive libs/intrusive/doc libs/intrusive/example libs/intrusive/perf libs/intrusive/proj/vc7ide libs/intrusive/proj/vc7ide/_intrusivelib libs/intrusive/proj/vc7ide/scary_iterators libs/intrusive/proj/vc7ide/tree_perf_test libs/intrusive/test
From: igaztanaga_at_[hidden]
Date: 2013-08-24 07:02:18


Author: igaztanaga
Date: 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013)
New Revision: 85445
URL: http://svn.boost.org/trac/boost/changeset/85445

Log:
Merged revision(s) 84342-85444 from trunk/libs/intrusive. Merged revision(s) 84341-85444 from trunk/boost/intrusive. First Intrusive merge for 1.55

Added:
   branches/release/boost/intrusive/bs_set.hpp
      - copied unchanged from r85444, trunk/boost/intrusive/bs_set.hpp
   branches/release/boost/intrusive/bstree.hpp
      - copied unchanged from r85444, trunk/boost/intrusive/bstree.hpp
   branches/release/boost/intrusive/bstree_algorithms.hpp
      - copied unchanged from r85444, trunk/boost/intrusive/bstree_algorithms.hpp
   branches/release/libs/intrusive/perf/tree_perf_test.cpp
      - copied unchanged from r85444, trunk/libs/intrusive/perf/tree_perf_test.cpp
   branches/release/libs/intrusive/proj/vc7ide/scary_iterators/
      - copied from r85444, trunk/libs/intrusive/proj/vc7ide/scary_iterators/
   branches/release/libs/intrusive/proj/vc7ide/tree_perf_test/
      - copied from r85444, trunk/libs/intrusive/proj/vc7ide/tree_perf_test/
   branches/release/libs/intrusive/test/scary_iterators_test.cpp
      - copied unchanged from r85444, trunk/libs/intrusive/test/scary_iterators_test.cpp
Deleted:
   branches/release/boost/intrusive/detail/tree_algorithms.hpp
Properties modified:
   branches/release/boost/intrusive/ (props changed)
   branches/release/libs/intrusive/ (props changed)
Text files modified:
   branches/release/boost/intrusive/any_hook.hpp | 27
   branches/release/boost/intrusive/avl_set.hpp | 2682 +++++++-----------------------------
   branches/release/boost/intrusive/avl_set_hook.hpp | 14
   branches/release/boost/intrusive/avltree.hpp | 1860 ++++---------------------
   branches/release/boost/intrusive/avltree_algorithms.hpp | 665 ++-------
   branches/release/boost/intrusive/bs_set.hpp | 922 ++++++++++++
   branches/release/boost/intrusive/bs_set_hook.hpp | 24
   branches/release/boost/intrusive/bstree.hpp | 2014 ++++++++++++++++++++++++++++
   branches/release/boost/intrusive/bstree_algorithms.hpp | 1988 +++++++++++++++++++++++++++
   branches/release/boost/intrusive/circular_list_algorithms.hpp | 13
   branches/release/boost/intrusive/circular_slist_algorithms.hpp | 13
   branches/release/boost/intrusive/derivation_value_traits.hpp | 2
   branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp | 2
   branches/release/boost/intrusive/detail/assert.hpp | 2
   branches/release/boost/intrusive/detail/avltree_node.hpp | 2
   branches/release/boost/intrusive/detail/clear_on_destructor_base.hpp | 8
   branches/release/boost/intrusive/detail/common_slist_algorithms.hpp | 2
   branches/release/boost/intrusive/detail/config_begin.hpp | 2
   branches/release/boost/intrusive/detail/config_end.hpp | 2
   branches/release/boost/intrusive/detail/ebo_functor_holder.hpp | 2
   branches/release/boost/intrusive/detail/function_detector.hpp | 2
   branches/release/boost/intrusive/detail/generic_hook.hpp | 167 +-
   branches/release/boost/intrusive/detail/has_member_function_callable_with.hpp | 2
   branches/release/boost/intrusive/detail/hashtable_node.hpp | 160 +
   branches/release/boost/intrusive/detail/is_stateful_value_traits.hpp | 2
   branches/release/boost/intrusive/detail/list_node.hpp | 92
   branches/release/boost/intrusive/detail/memory_util.hpp | 6
   branches/release/boost/intrusive/detail/mpl.hpp | 21
   branches/release/boost/intrusive/detail/parent_from_member.hpp | 28
   branches/release/boost/intrusive/detail/preprocessor.hpp | 2
   branches/release/boost/intrusive/detail/rbtree_node.hpp | 4
   branches/release/boost/intrusive/detail/slist_node.hpp | 88
   branches/release/boost/intrusive/detail/transform_iterator.hpp | 2
   /dev/null | 1742 ------------------------
   branches/release/boost/intrusive/detail/tree_node.hpp | 83
   branches/release/boost/intrusive/detail/utilities.hpp | 692 ++++++---
   branches/release/boost/intrusive/detail/workaround.hpp | 6
   branches/release/boost/intrusive/hashtable.hpp | 1839 +++++++++++++------------
   branches/release/boost/intrusive/intrusive_fwd.hpp | 360 ++--
   branches/release/boost/intrusive/linear_slist_algorithms.hpp | 13
   branches/release/boost/intrusive/link_mode.hpp | 2
   branches/release/boost/intrusive/list.hpp | 134 -
   branches/release/boost/intrusive/list_hook.hpp | 14
   branches/release/boost/intrusive/member_value_traits.hpp | 2
   branches/release/boost/intrusive/options.hpp | 144 +
   branches/release/boost/intrusive/parent_from_member.hpp | 2
   branches/release/boost/intrusive/pointer_plus_bits.hpp | 2
   branches/release/boost/intrusive/pointer_traits.hpp | 6
   branches/release/boost/intrusive/priority_compare.hpp | 17
   branches/release/boost/intrusive/rbtree.hpp | 1825 ++++---------------------
   branches/release/boost/intrusive/rbtree_algorithms.hpp | 721 ++-------
   branches/release/boost/intrusive/set.hpp | 2621 ++++++-----------------------------
   branches/release/boost/intrusive/set_hook.hpp | 14
   branches/release/boost/intrusive/sg_set.hpp | 2735 +++++++------------------------------
   branches/release/boost/intrusive/sgtree.hpp | 1783 +++++-------------------
   branches/release/boost/intrusive/sgtree_algorithms.hpp | 735 ++--------
   branches/release/boost/intrusive/slist.hpp | 188 +-
   branches/release/boost/intrusive/slist_hook.hpp | 14
   branches/release/boost/intrusive/splay_set.hpp | 2861 +++++++++------------------------------
   branches/release/boost/intrusive/splay_set_hook.hpp | 68
   branches/release/boost/intrusive/splaytree.hpp | 1867 +++++--------------------
   branches/release/boost/intrusive/splaytree_algorithms.hpp | 849 +++--------
   branches/release/boost/intrusive/treap.hpp | 1335 ++++--------------
   branches/release/boost/intrusive/treap_algorithms.hpp | 479 +-----
   branches/release/boost/intrusive/treap_set.hpp | 2626 +++++------------------------------
   branches/release/boost/intrusive/trivial_value_traits.hpp | 2
   branches/release/boost/intrusive/unordered_set.hpp | 383 ++--
   branches/release/boost/intrusive/unordered_set_hook.hpp | 20
   branches/release/libs/intrusive/doc/Jamfile.v2 | 50
   branches/release/libs/intrusive/doc/intrusive.qbk | 62
   branches/release/libs/intrusive/example/Jamfile.v2 | 2
   branches/release/libs/intrusive/example/doc_advanced_value_traits.cpp | 2
   branches/release/libs/intrusive/example/doc_advanced_value_traits2.cpp | 2
   branches/release/libs/intrusive/example/doc_any_hook.cpp | 2
   branches/release/libs/intrusive/example/doc_assoc_optimized_code.cpp | 2
   branches/release/libs/intrusive/example/doc_auto_unlink.cpp | 2
   branches/release/libs/intrusive/example/doc_avl_set.cpp | 3
   branches/release/libs/intrusive/example/doc_avltree_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_bucket_traits.cpp | 2
   branches/release/libs/intrusive/example/doc_clone_from.cpp | 2
   branches/release/libs/intrusive/example/doc_entity.cpp | 2
   branches/release/libs/intrusive/example/doc_erasing_and_disposing.cpp | 2
   branches/release/libs/intrusive/example/doc_external_value_traits.cpp | 2
   branches/release/libs/intrusive/example/doc_function_hooks.cpp | 2
   branches/release/libs/intrusive/example/doc_how_to_use.cpp | 2
   branches/release/libs/intrusive/example/doc_iterator_from_value.cpp | 2
   branches/release/libs/intrusive/example/doc_list.cpp | 3
   branches/release/libs/intrusive/example/doc_list_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_offset_ptr.cpp | 2
   branches/release/libs/intrusive/example/doc_positional_insertion.cpp | 2
   branches/release/libs/intrusive/example/doc_rbtree_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_recursive.cpp | 2
   branches/release/libs/intrusive/example/doc_recursive_member.cpp | 2
   branches/release/libs/intrusive/example/doc_set.cpp | 3
   branches/release/libs/intrusive/example/doc_sg_set.cpp | 3
   branches/release/libs/intrusive/example/doc_slist.cpp | 2
   branches/release/libs/intrusive/example/doc_slist_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_splay_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_splay_set.cpp | 12
   branches/release/libs/intrusive/example/doc_splaytree_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_stateful_value_traits.cpp | 2
   branches/release/libs/intrusive/example/doc_treap_algorithms.cpp | 2
   branches/release/libs/intrusive/example/doc_treap_set.cpp | 2
   branches/release/libs/intrusive/example/doc_unordered_set.cpp | 3
   branches/release/libs/intrusive/example/doc_value_traits.cpp | 2
   branches/release/libs/intrusive/example/doc_window.cpp | 2
   branches/release/libs/intrusive/perf/Jamfile.v2 | 2
   branches/release/libs/intrusive/perf/perf_list.cpp | 2
   branches/release/libs/intrusive/perf/tree_perf_test.cpp | 214 ++
   branches/release/libs/intrusive/proj/vc7ide/Intrusive.sln | 16
   branches/release/libs/intrusive/proj/vc7ide/_intrusivelib/_intrusivelib.vcproj | 24
   branches/release/libs/intrusive/proj/vc7ide/to-do.txt | 5
   branches/release/libs/intrusive/test/any_test.cpp | 3
   branches/release/libs/intrusive/test/avl_multiset_test.cpp | 8
   branches/release/libs/intrusive/test/avl_set_test.cpp | 8
   branches/release/libs/intrusive/test/common_functors.hpp | 2
   branches/release/libs/intrusive/test/custom_bucket_traits_test.cpp | 2
   branches/release/libs/intrusive/test/default_hook_test.cpp | 140 +
   branches/release/libs/intrusive/test/external_value_traits_test.cpp | 3
   branches/release/libs/intrusive/test/function_hook_test.cpp | 2
   branches/release/libs/intrusive/test/generic_assoc_test.hpp | 40
   branches/release/libs/intrusive/test/generic_multiset_test.hpp | 17
   branches/release/libs/intrusive/test/generic_set_test.hpp | 23
   branches/release/libs/intrusive/test/has_member_function_callable_with.cpp | 2
   branches/release/libs/intrusive/test/itestvalue.hpp | 2
   branches/release/libs/intrusive/test/list_test.cpp | 2
   branches/release/libs/intrusive/test/make_functions_test.cpp | 12
   branches/release/libs/intrusive/test/multiset_test.cpp | 8
   branches/release/libs/intrusive/test/pointer_traits_test.cpp | 2
   branches/release/libs/intrusive/test/recursive_test.cpp | 2
   branches/release/libs/intrusive/test/scary_iterators_test.cpp | 314 ++++
   branches/release/libs/intrusive/test/set_test.cpp | 8
   branches/release/libs/intrusive/test/sg_multiset_test.cpp | 14
   branches/release/libs/intrusive/test/sg_set_test.cpp | 14
   branches/release/libs/intrusive/test/slist_test.cpp | 206 ++
   branches/release/libs/intrusive/test/splay_multiset_test.cpp | 27
   branches/release/libs/intrusive/test/splay_set_test.cpp | 24
   branches/release/libs/intrusive/test/stateful_value_traits_test.cpp | 2
   branches/release/libs/intrusive/test/test_container.hpp | 56
   branches/release/libs/intrusive/test/test_macros.hpp | 2
   branches/release/libs/intrusive/test/treap_multiset_test.cpp | 8
   branches/release/libs/intrusive/test/treap_set_test.cpp | 8
   branches/release/libs/intrusive/test/unordered_multiset_test.cpp | 2
   branches/release/libs/intrusive/test/unordered_set_test.cpp | 2
   branches/release/libs/intrusive/test/virtual_base_test.cpp | 5
   145 files changed, 13739 insertions(+), 24699 deletions(-)

Modified: branches/release/boost/intrusive/any_hook.hpp
==============================================================================
--- branches/release/boost/intrusive/any_hook.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/any_hook.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -37,7 +37,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_any_base_hook
 {
@@ -51,11 +51,11 @@
       #endif
>::type packed_options;
 
- typedef detail::generic_hook
+ typedef generic_hook
    < get_any_node_algo<typename packed_options::void_pointer>
    , typename packed_options::tag
    , packed_options::link_mode
- , detail::AnyBaseHook
+ , AnyBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -142,7 +142,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_any_member_hook
 {
@@ -156,11 +156,11 @@
       #endif
>::type packed_options;
 
- typedef detail::generic_hook
+ typedef generic_hook
    < get_any_node_algo<typename packed_options::void_pointer>
    , member_tag
    , packed_options::link_mode
- , detail::NoBaseHook
+ , NoBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -244,7 +244,7 @@
 template<class ValueTraits>
 struct any_to_get_base_pointer_type
 {
- typedef typename pointer_traits<typename ValueTraits::boost_intrusive_tags::node_traits::node_ptr>::template
+ typedef typename pointer_traits<typename ValueTraits::hooktags::node_traits::node_ptr>::template
       rebind_pointer<void>::type type;
 };
 
@@ -260,17 +260,18 @@
 template<class BaseHook, template <class> class NodeTraits>
 struct any_to_some_hook
 {
- typedef typename BaseHook::template pack<none>::value_traits old_value_traits;
+ typedef typename BaseHook::template pack<empty>::proto_value_traits old_proto_value_traits;
+
    template<class Base>
    struct pack : public Base
    {
- struct value_traits : public old_value_traits
+ struct proto_value_traits : public old_proto_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>
+ < detail::internal_base_hook_bool_is_true<old_proto_value_traits>::value
+ , any_to_get_base_pointer_type<old_proto_value_traits>
+ , any_to_get_member_pointer_type<old_proto_value_traits>
>::type void_pointer;
          typedef NodeTraits<void_pointer> node_traits;
       };

Modified: branches/release/boost/intrusive/avl_set.hpp
==============================================================================
--- branches/release/boost/intrusive/avl_set.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/avl_set.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -36,14 +36,15 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
 #endif
 class avl_set_impl
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ : public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms>
+#endif
 {
    /// @cond
- typedef avltree_impl<Config> tree_type;
- //! This class is
- //! movable
+ typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms> tree_type;
    BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set_impl)
 
    typedef tree_type implementation_defined;
@@ -71,1208 +72,367 @@
    typedef typename implementation_defined::const_node_ptr const_node_ptr;
    typedef typename implementation_defined::node_algorithms node_algorithms;
 
- static const bool constant_time_size = Config::constant_time_size;
-
- /// @cond
- private:
- tree_type tree_;
- /// @endcond
+ static const bool constant_time_size = tree_type::constant_time_size;
 
    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.
+
+ //! @copydoc ::boost::intrusive::avltree::avltree(const value_compare &,const value_traits &)
    explicit avl_set_impl( const value_compare &cmp = value_compare()
- , const value_traits &v_traits = value_traits())
- : tree_(cmp, v_traits)
+ , const value_traits &v_traits = value_traits())
+ : tree_type(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.
+ //! @copydoc ::boost::intrusive::avltree::avltree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
    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)
+ : tree_type(true, b, e, cmp, v_traits)
    {}
 
- //! <b>Effects</b>: to-do
- //!
+ //! @copydoc ::boost::intrusive::avltree::avltree(avltree &&)
    avl_set_impl(BOOST_RV_REF(avl_set_impl) x)
- : tree_(::boost::move(x.tree_))
+ : tree_type(::boost::move(static_cast<tree_type&>(x)))
    {}
 
- //! <b>Effects</b>: to-do
- //!
+ //! @copydoc ::boost::intrusive::avltree::operator=(avltree &&)
    avl_set_impl& operator=(BOOST_RV_REF(avl_set_impl) x)
- { tree_ = ::boost::move(x.tree_); return *this; }
+ { return static_cast<avl_set_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }
 
- //! <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()
- {}
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! @copydoc ::boost::intrusive::avltree::~avltree()
+ ~avl_set_impl();
+
+ //! @copydoc ::boost::intrusive::avltree::begin()
+ iterator begin();
+
+ //! @copydoc ::boost::intrusive::avltree::begin()const
+ const_iterator begin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::cbegin()const
+ const_iterator cbegin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::end()
+ iterator end();
+
+ //! @copydoc ::boost::intrusive::avltree::end()const
+ const_iterator end() const;
+
+ //! @copydoc ::boost::intrusive::avltree::cend()const
+ const_iterator cend() const;
+
+ //! @copydoc ::boost::intrusive::avltree::begin()
+ reverse_iterator avlegin();
+
+ //! @copydoc ::boost::intrusive::avltree::begin()const
+ const_reverse_iterator avlegin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::crbegin()const
+ const_reverse_iterator crbegin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::rend()
+ reverse_iterator rend();
+
+ //! @copydoc ::boost::intrusive::avltree::rend()const
+ const_reverse_iterator rend() const;
+
+ //! @copydoc ::boost::intrusive::avltree::crend()const
+ const_reverse_iterator crend() const;
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(iterator)
+ static avl_set_impl &container_from_end_iterator(iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(const_iterator)
+ static const avl_set_impl &container_from_end_iterator(const_iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_iterator(iterator)
+ static avl_set_impl &container_from_iterator(iterator it);
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_iterator(const_iterator)
+ static const avl_set_impl &container_from_iterator(const_iterator it);
+
+ //! @copydoc ::boost::intrusive::avltree::key_comp()const
+ key_compare key_comp() const;
+
+ //! @copydoc ::boost::intrusive::avltree::value_comp()const
+ value_compare value_comp() const;
+
+ //! @copydoc ::boost::intrusive::avltree::empty()const
+ bool empty() const;
+
+ //! @copydoc ::boost::intrusive::avltree::size()const
+ size_type size() const;
+
+ //! @copydoc ::boost::intrusive::avltree::swap
+ void swap(avl_set_impl& other);
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::clone_from
    template <class Cloner, class Disposer>
- void clone_from(const avl_set_impl &src, Cloner cloner, Disposer disposer)
- { tree_.clone_from(src.tree_, cloner, disposer); }
+ void clone_from(const avl_set_impl &src, Cloner cloner, Disposer disposer);
+
+ #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::insert_unique(reference)
    std::pair<iterator, bool> insert(reference value)
- { return tree_.insert_unique(value); }
+ { return tree_type::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.
+ //! @copydoc ::boost::intrusive::avltree::insert_unique(const_iterator,reference)
    iterator insert(const_iterator hint, reference value)
- { return tree_.insert_unique(hint, value); }
+ { return tree_type::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.
+ //! @copydoc ::boost::intrusive::avltree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&)
    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); }
+ { return tree_type::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.
+ //! @copydoc ::boost::intrusive::avltree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&)
    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); }
+ { return tree_type::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.
+ //! @copydoc ::boost::intrusive::avltree::insert_unique(Iterator,Iterator)
    template<class Iterator>
    void insert(Iterator b, Iterator e)
- { tree_.insert_unique(b, e); }
+ { tree_type::insert_unique(b, e); }
 
- //! <b>Requires</b>: value must be an lvalue, "pos" must be
- //! a valid iterator (or end) and must be the succesor of value
- //! once inserted according to the predicate. "value" must not be equal to any
- //! inserted key according to the predicate.
- //!
- //! <b>Effects</b>: Inserts x into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if "pos" is not
- //! the successor of "value" or "value" is not unique tree ordering and uniqueness
- //! invariants will be broken respectively.
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- iterator insert_before(const_iterator pos, reference value)
- { return tree_.insert_before(pos, value); }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be greater than
- //! any inserted key according to the predicate.
- //!
- //! <b>Effects</b>: Inserts x into the tree in the last position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! less than or equal to the greatest inserted key tree ordering invariant will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_back(reference value)
- { tree_.push_back(value); }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be less
- //! than any inserted key according to the predicate.
- //!
- //! <b>Effects</b>: Inserts x into the tree in the first position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! greater than or equal to the the mimum inserted key tree ordering or uniqueness
- //! invariants will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_front(reference value)
- { tree_.push_front(value); }
-
- //! <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); }
+ //! @copydoc ::boost::intrusive::avltree::insert_unique_commit
+ iterator insert_commit(reference value, const insert_commit_data &commit_data)
+ { return tree_type::insert_unique_commit(value, commit_data); }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::avltree::insert_before
+ iterator insert_before(const_iterator pos, reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::push_back
+ void push_back(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::push_front
+ void push_front(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const_iterator)
+ iterator erase(const_iterator i);
 
- #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! @copydoc ::boost::intrusive::avltree::erase(const_iterator,const_iterator)
+ iterator erase(const_iterator b, const_iterator e);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const_reference)
+ size_type erase(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,Disposer)
    template<class Disposer>
- iterator erase_and_dispose(iterator i, Disposer disposer)
- { return this->erase_and_dispose(const_iterator(i), disposer); }
- #endif
+ iterator erase_and_dispose(const_iterator i, Disposer disposer);
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,const_iterator,Disposer)
    template<class Disposer>
- iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
- { return tree_.erase_and_dispose(b, e, disposer); }
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer 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.
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_reference, Disposer)
    template<class Disposer>
- size_type erase_and_dispose(const_reference value, Disposer disposer)
- { return tree_.erase_and_dispose(value, disposer); }
+ size_type erase_and_dispose(const_reference value, Disposer 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.
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
    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.
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::avltree::clear
+ void clear();
+
+ //! @copydoc ::boost::intrusive::avltree::clear_and_dispose
    template<class Disposer>
- void clear_and_dispose(Disposer disposer)
- { return tree_.clear_and_dispose(disposer); }
+ void clear_and_dispose(Disposer 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.
+ //! @copydoc ::boost::intrusive::avltree::count(const_reference)const
+ size_type count(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::count(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference)
+ iterator lower_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference)const
+ const_iterator lower_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference)
+ iterator upper_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference)const
+ const_iterator upper_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::find(const_reference)
+ iterator find(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::find(const_reference)const
+ const_iterator find(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const_reference)
+ std::pair<iterator,iterator> equal_range(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const_reference)const
    std::pair<const_iterator, const_iterator>
- equal_range(const_reference value) const
- { return tree_.equal_range(value); }
+ equal_range(const_reference value) const;
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const KeyType&,KeyValueCompare)const
    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); }
+ equal_range(const KeyType& key, KeyValueCompare comp) const;
 
- //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
- //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If the predicate throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_value and upper_value.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool)
    std::pair<iterator,iterator> bounded_range
- (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed)
- { return tree_.bounded_range(lower_value, upper_value, left_closed, right_closed); }
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
 
- //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
- //! ordering compatible with the strict weak ordering used to create the
- //! the tree.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
- //!
- //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)
    template<class KeyType, class KeyValueCompare>
    std::pair<iterator,iterator> bounded_range
- (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed)
- { return tree_.bounded_range(lower_key, upper_key, comp, left_closed, right_closed); }
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
 
- //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
- //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If the predicate throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_value and upper_value.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool)const
    std::pair<const_iterator, const_iterator>
- bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const
- { return tree_.bounded_range(lower_value, upper_value, left_closed, right_closed); }
+ bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
 
- //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
- //! ordering compatible with the strict weak ordering used to create the
- //! the tree.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
- //!
- //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const
    template<class KeyType, class KeyValueCompare>
- std::pair<const_iterator, const_iterator>
- bounded_range
- (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const
- { return tree_.bounded_range(lower_key, upper_key, comp, left_closed, right_closed); }
-
- //! <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); }
+ std::pair<const_iterator, const_iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
 
- /// @cond
- friend bool operator==(const avl_set_impl &x, const avl_set_impl &y)
- { return x.tree_ == y.tree_; }
+ //! @copydoc ::boost::intrusive::avltree::s_iterator_to(reference)
+ static iterator s_iterator_to(reference value);
 
- friend bool operator<(const avl_set_impl &x, const avl_set_impl &y)
- { return x.tree_ < y.tree_; }
- /// @endcond
+ //! @copydoc ::boost::intrusive::avltree::s_iterator_to(const_reference)
+ static const_iterator s_iterator_to(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::iterator_to(reference)
+ iterator iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::iterator_to(const_reference)const
+ const_iterator iterator_to(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::init_node(reference)
+ static void init_node(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::unlink_leftmost_without_rebalance
+ pointer unlink_leftmost_without_rebalance();
+
+ //! @copydoc ::boost::intrusive::avltree::replace_node
+ void replace_node(iterator replace_this, reference with_this);
+
+ //! @copydoc ::boost::intrusive::avltree::remove_node
+ void remove_node(reference value);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 };
 
 #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); }
+bool operator!= (const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &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; }
+bool operator>(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &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); }
+bool operator<=(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &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 !(x < y); }
+bool operator>=(const avl_set_impl<T, Options...> &x, const avl_set_impl<T, Options...> &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); }
+void swap(avl_set_impl<T, Options...> &x, avl_set_impl<T, Options...> &y);
+
+#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 
-//! Helper metafunction to define a \c avl_set that yields to the same type when the
+//! Helper metafunction to define a \c 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>
+template<class T, class O1 = void, class O2 = void
+ , class O3 = void, class O4 = void>
 #endif
 struct make_avl_set
 {
    /// @cond
- typedef avl_set_impl
- < typename make_avltree_opt
+ typedef typename pack_options
+ < avltree_defaults,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- <T, O1, O2, O3, O4>
+ O1, O2, O3, O4
       #else
- <T, Options...>
+ Options...
       #endif
- ::type
- > implementation_defined;
+ >::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::proto_value_traits>::type value_traits;
+
+ typedef avl_set_impl
+ < value_traits
+ , typename packed_options::compare
+ , typename packed_options::size_type
+ , packed_options::constant_time_size
+ > 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
+ : public make_avl_set<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
 {
    typedef typename make_avl_set
+ <T,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- <T, O1, O2, O3, O4>
+ O1, O2, O3, O4
       #else
- <T, Options...>
+ Options...
       #endif
- ::type Base;
+ >::type Base;
 
    BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_set)
    public:
@@ -1284,8 +444,8 @@
    //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())
+ explicit avl_set( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
       : Base(cmp, v_traits)
    {}
 
@@ -1301,7 +461,7 @@
    {}
 
    avl_set& operator=(BOOST_RV_REF(avl_set) x)
- { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
+ { return static_cast<avl_set &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
 
    static avl_set &container_from_end_iterator(iterator end_iterator)
    { return static_cast<avl_set &>(Base::container_from_end_iterator(end_iterator)); }
@@ -1309,17 +469,17 @@
    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 avl_set &container_from_iterator(iterator it)
+ { return static_cast<avl_set &>(Base::container_from_iterator(it)); }
 
- static const avl_set &container_from_iterator(const_iterator end_iterator)
- { return static_cast<const avl_set &>(Base::container_from_iterator(end_iterator)); }
+ static const avl_set &container_from_iterator(const_iterator it)
+ { return static_cast<const avl_set &>(Base::container_from_iterator(it)); }
 };
 
 #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 interface of std::_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
@@ -1332,14 +492,16 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template<class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
 #endif
 class avl_multiset_impl
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ : public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms>
+#endif
 {
    /// @cond
- typedef avltree_impl<Config> tree_type;
+ typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, AvlTreeAlgorithms> tree_type;
 
- //Movable
    BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset_impl)
    typedef tree_type implementation_defined;
    /// @endcond
@@ -1366,1088 +528,321 @@
    typedef typename implementation_defined::const_node_ptr const_node_ptr;
    typedef typename implementation_defined::node_algorithms node_algorithms;
 
- static const bool constant_time_size = Config::constant_time_size;
-
- /// @cond
- private:
- tree_type tree_;
- /// @endcond
+ static const bool constant_time_size = tree_type::constant_time_size;
 
    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.
+ //! @copydoc ::boost::intrusive::avltree::avltree(const value_compare &,const value_traits &)
    explicit avl_multiset_impl( const value_compare &cmp = value_compare()
- , const value_traits &v_traits = value_traits())
- : tree_(cmp, v_traits)
+ , const value_traits &v_traits = value_traits())
+ : tree_type(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.
+ //! @copydoc ::boost::intrusive::avltree::avltree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
    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)
+ : tree_type(false, b, e, cmp, v_traits)
    {}
 
- //! <b>Effects</b>: to-do
- //!
+ //! @copydoc ::boost::intrusive::avltree::avltree(avltree &&)
    avl_multiset_impl(BOOST_RV_REF(avl_multiset_impl) x)
- : tree_(::boost::move(x.tree_))
+ : tree_type(::boost::move(static_cast<tree_type&>(x)))
    {}
 
- //! <b>Effects</b>: to-do
- //!
+ //! @copydoc ::boost::intrusive::avltree::operator=(avltree &&)
    avl_multiset_impl& operator=(BOOST_RV_REF(avl_multiset_impl) x)
- { tree_ = ::boost::move(x.tree_); return *this; }
+ { return static_cast<avl_multiset_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }
 
- //! <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()
- {}
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::avltree::~avltree()
+ ~avl_multiset_impl();
+
+ //! @copydoc ::boost::intrusive::avltree::begin()
+ iterator begin();
+
+ //! @copydoc ::boost::intrusive::avltree::begin()const
+ const_iterator begin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::cbegin()const
+ const_iterator cbegin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::end()
+ iterator end();
+
+ //! @copydoc ::boost::intrusive::avltree::end()const
+ const_iterator end() const;
+
+ //! @copydoc ::boost::intrusive::avltree::cend()const
+ const_iterator cend() const;
+
+ //! @copydoc ::boost::intrusive::avltree::rbegin()
+ reverse_iterator rbegin();
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::rbegin()const
+ const_reverse_iterator rbegin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::crbegin()const
+ const_reverse_iterator crbegin() const;
+
+ //! @copydoc ::boost::intrusive::avltree::rend()
+ reverse_iterator rend();
+
+ //! @copydoc ::boost::intrusive::avltree::rend()const
+ const_reverse_iterator rend() const;
+
+ //! @copydoc ::boost::intrusive::avltree::crend()const
+ const_reverse_iterator crend() const;
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(iterator)
+ static avl_multiset_impl &container_from_end_iterator(iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_end_iterator(const_iterator)
+ static const avl_multiset_impl &container_from_end_iterator(const_iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_iterator(iterator)
+ static avl_multiset_impl &container_from_iterator(iterator it);
+
+ //! @copydoc ::boost::intrusive::avltree::container_from_iterator(const_iterator)
+ static const avl_multiset_impl &container_from_iterator(const_iterator it);
+
+ //! @copydoc ::boost::intrusive::avltree::key_comp()const
+ key_compare key_comp() const;
+
+ //! @copydoc ::boost::intrusive::avltree::value_comp()const
+ value_compare value_comp() const;
+
+ //! @copydoc ::boost::intrusive::avltree::empty()const
+ bool empty() const;
+
+ //! @copydoc ::boost::intrusive::avltree::size()const
+ size_type size() const;
+
+ //! @copydoc ::boost::intrusive::avltree::swap
+ void swap(avl_multiset_impl& other);
+
+ //! @copydoc ::boost::intrusive::avltree::clone_from
    template <class Cloner, class Disposer>
- void clone_from(const avl_multiset_impl &src, Cloner cloner, Disposer disposer)
- { tree_.clone_from(src.tree_, cloner, disposer); }
+ void clone_from(const avl_multiset_impl &src, Cloner cloner, Disposer disposer);
+
+ #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::insert_equal(reference)
    iterator insert(reference value)
- { return tree_.insert_equal(value); }
+ { return tree_type::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.
+ //! @copydoc ::boost::intrusive::avltree::insert_equal(const_iterator,reference)
    iterator insert(const_iterator hint, reference value)
- { return tree_.insert_equal(hint, value); }
+ { return tree_type::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.
+ //! @copydoc ::boost::intrusive::avltree::insert_equal(Iterator,Iterator)
    template<class Iterator>
    void insert(Iterator b, Iterator e)
- { tree_.insert_equal(b, e); }
+ { tree_type::insert_equal(b, e); }
 
- //! <b>Requires</b>: value must be an lvalue, "pos" must be
- //! a valid iterator (or end) and must be the succesor of value
- //! once inserted according to the predicate. "value" must not be equal to any
- //! inserted key according to the predicate.
- //!
- //! <b>Effects</b>: Inserts x into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if "pos" is not
- //! the successor of "value" or "value" is not unique tree ordering and uniqueness
- //! invariants will be broken respectively.
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- iterator insert_before(const_iterator pos, reference value)
- { return tree_.insert_before(pos, value); }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be greater than
- //! any inserted key according to the predicate.
- //!
- //! <b>Effects</b>: Inserts x into the tree in the last position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! less than or equal to the greatest inserted key tree ordering invariant will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_back(reference value)
- { tree_.push_back(value); }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be less
- //! than any inserted key according to the predicate.
- //!
- //! <b>Effects</b>: Inserts x into the tree in the first position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! greater than or equal to the the mimum inserted key tree ordering or uniqueness
- //! invariants will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_front(reference value)
- { tree_.push_front(value); }
-
- //! <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); }
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::avltree::insert_before
+ iterator insert_before(const_iterator pos, reference value);
 
- #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! @copydoc ::boost::intrusive::avltree::push_back
+ void push_back(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::push_front
+ void push_front(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const_iterator)
+ iterator erase(const_iterator i);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const_iterator,const_iterator)
+ iterator erase(const_iterator b, const_iterator e);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const_reference)
+ size_type erase(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::erase(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,Disposer)
    template<class Disposer>
- iterator erase_and_dispose(iterator i, Disposer disposer)
- { return this->erase_and_dispose(const_iterator(i), disposer); }
- #endif
+ iterator erase_and_dispose(const_iterator i, Disposer disposer);
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_iterator,const_iterator,Disposer)
    template<class Disposer>
- iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
- { return tree_.erase_and_dispose(b, e, disposer); }
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer 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.
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const_reference, Disposer)
    template<class Disposer>
- size_type erase_and_dispose(const_reference value, Disposer disposer)
- { return tree_.erase_and_dispose(value, disposer); }
+ size_type erase_and_dispose(const_reference value, Disposer 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.
+ //! @copydoc ::boost::intrusive::avltree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
    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.
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::avltree::clear
+ void clear();
+
+ //! @copydoc ::boost::intrusive::avltree::clear_and_dispose
    template<class Disposer>
- void clear_and_dispose(Disposer disposer)
- { return tree_.clear_and_dispose(disposer); }
+ void clear_and_dispose(Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::avltree::count(const_reference)const
+ size_type count(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::count(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference)
+ iterator lower_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const_reference)const
+ const_iterator lower_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::lower_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference)
+ iterator upper_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const_reference)const
+ const_iterator upper_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::upper_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::find(const_reference)
+ iterator find(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::find(const_reference)const
+ const_iterator find(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::find(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const_reference)
+ std::pair<iterator,iterator> equal_range(const_reference value);
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const_reference)const
    std::pair<const_iterator, const_iterator>
- equal_range(const_reference value) const
- { return tree_.equal_range(value); }
+ equal_range(const_reference value) const;
 
- //! <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.
+ //! @copydoc ::boost::intrusive::avltree::equal_range(const KeyType&,KeyValueCompare)const
    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); }
+ equal_range(const KeyType& key, KeyValueCompare comp) const;
 
- //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
- //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If the predicate throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_value and upper_value.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool)
    std::pair<iterator,iterator> bounded_range
- (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed)
- { return tree_.bounded_range(lower_value, upper_value, left_closed, right_closed); }
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
 
- //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
- //! ordering compatible with the strict weak ordering used to create the
- //! the tree.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
- //!
- //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)
    template<class KeyType, class KeyValueCompare>
    std::pair<iterator,iterator> bounded_range
- (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed)
- { return tree_.bounded_range(lower_key, upper_key, comp, left_closed, right_closed); }
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
 
- //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
- //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If the predicate throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_value and upper_value.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const_reference,const_reference,bool,bool)const
    std::pair<const_iterator, const_iterator>
- bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const
- { return tree_.bounded_range(lower_value, upper_value, left_closed, right_closed); }
+ bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
 
- //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
- //! ordering compatible with the strict weak ordering used to create the
- //! the tree.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
- //!
- //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ //! @copydoc ::boost::intrusive::avltree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const
    template<class KeyType, class KeyValueCompare>
- std::pair<const_iterator, const_iterator>
- bounded_range
- (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const
- { return tree_.bounded_range(lower_key, upper_key, comp, left_closed, right_closed); }
-
- //! <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); }
+ std::pair<const_iterator, const_iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
 
- /// @cond
- friend bool operator==(const avl_multiset_impl &x, const avl_multiset_impl &y)
- { return x.tree_ == y.tree_; }
+ //! @copydoc ::boost::intrusive::avltree::s_iterator_to(reference)
+ static iterator s_iterator_to(reference value);
 
- friend bool operator<(const avl_multiset_impl &x, const avl_multiset_impl &y)
- { return x.tree_ < y.tree_; }
- /// @endcond
+ //! @copydoc ::boost::intrusive::avltree::s_iterator_to(const_reference)
+ static const_iterator s_iterator_to(const_reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::iterator_to(reference)
+ iterator iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::iterator_to(const_reference)const
+ const_iterator iterator_to(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::avltree::init_node(reference)
+ static void init_node(reference value);
+
+ //! @copydoc ::boost::intrusive::avltree::unlink_leftmost_without_rebalance
+ pointer unlink_leftmost_without_rebalance();
+
+ //! @copydoc ::boost::intrusive::avltree::replace_node
+ void replace_node(iterator replace_this, reference with_this);
+
+ //! @copydoc ::boost::intrusive::avltree::remove_node
+ void remove_node(reference value);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 };
 
 #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); }
+bool operator!= (const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &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; }
+bool operator>(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &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); }
+bool operator<=(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &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 !(x < y); }
+bool operator>=(const avl_multiset_impl<T, Options...> &x, const avl_multiset_impl<T, Options...> &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); }
+void swap(avl_multiset_impl<T, Options...> &x, avl_multiset_impl<T, Options...> &y);
+
+#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 
 //! 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>
+template<class T, class O1 = void, class O2 = void
+ , class O3 = void, class O4 = void>
 #endif
 struct make_avl_multiset
 {
    /// @cond
+ typedef typename pack_options
+ < avltree_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::proto_value_traits>::type value_traits;
+
    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;
+ < value_traits
+ , typename packed_options::compare
+ , typename packed_options::size_type
+ , packed_options::constant_time_size
+ > implementation_defined;
    /// @endcond
    typedef implementation_defined type;
 };
@@ -2461,22 +856,23 @@
 #endif
 class avl_multiset
    : public make_avl_multiset<T,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4
- #else
- Options...
- #endif
- >::type
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
 {
- typedef typename make_avl_multiset
+ typedef typename make_avl_multiset<T,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- <T, O1, O2, O3, O4>
+ O1, O2, O3, O4
       #else
- <T, Options...>
+ Options...
       #endif
- ::type Base;
+ >::type Base;
 
    BOOST_MOVABLE_BUT_NOT_COPYABLE(avl_multiset)
+
    public:
    typedef typename Base::value_compare value_compare;
    typedef typename Base::value_traits value_traits;
@@ -2486,8 +882,8 @@
    //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())
+ explicit avl_multiset( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
       : Base(cmp, v_traits)
    {}
 
@@ -2503,7 +899,7 @@
    {}
 
    avl_multiset& operator=(BOOST_RV_REF(avl_multiset) x)
- { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
+ { return static_cast<avl_multiset &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
 
    static avl_multiset &container_from_end_iterator(iterator end_iterator)
    { return static_cast<avl_multiset &>(Base::container_from_end_iterator(end_iterator)); }
@@ -2511,11 +907,11 @@
    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 avl_multiset &container_from_iterator(iterator it)
+ { return static_cast<avl_multiset &>(Base::container_from_iterator(it)); }
 
- static const avl_multiset &container_from_iterator(const_iterator end_iterator)
- { return static_cast<const avl_multiset &>(Base::container_from_iterator(end_iterator)); }
+ static const avl_multiset &container_from_iterator(const_iterator it)
+ { return static_cast<const avl_multiset &>(Base::container_from_iterator(it)); }
 };
 
 #endif

Modified: branches/release/boost/intrusive/avl_set_hook.hpp
==============================================================================
--- branches/release/boost/intrusive/avl_set_hook.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/avl_set_hook.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -37,7 +37,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
 #endif
 struct make_avl_set_base_hook
 {
@@ -50,12 +50,12 @@
       #endif
       ::type packed_options;
 
- typedef detail::generic_hook
+ typedef 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
+ , AvlTreeBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -168,7 +168,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void, class O4 = void>
 #endif
 struct make_avl_set_member_hook
 {
@@ -181,12 +181,12 @@
       #endif
       ::type packed_options;
 
- typedef detail::generic_hook
+ typedef generic_hook
    < get_avl_set_node_algo<typename packed_options::void_pointer
                       ,packed_options::optimize_size>
    , member_tag
    , packed_options::link_mode
- , detail::NoBaseHook
+ , NoBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;

Modified: branches/release/boost/intrusive/avltree.hpp
==============================================================================
--- branches/release/boost/intrusive/avltree.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/avltree.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -24,12 +24,12 @@
 #include <boost/intrusive/intrusive_fwd.hpp>
 #include <boost/intrusive/avl_set_hook.hpp>
 #include <boost/intrusive/detail/avltree_node.hpp>
+#include <boost/intrusive/bstree.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/pointer_traits.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
-#include <boost/intrusive/detail/clear_on_destructor_base.hpp>
 #include <boost/intrusive/options.hpp>
 #include <boost/intrusive/detail/utilities.hpp>
 #include <boost/intrusive/avltree_algorithms.hpp>
@@ -41,26 +41,14 @@
 
 /// @cond
 
-template <class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
-struct avl_setopt
+struct avltree_defaults
 {
- typedef ValueTraits value_traits;
- typedef Compare compare;
- typedef SizeType size_type;
- static const bool constant_time_size = ConstantTimeSize;
+ typedef detail::default_avltree_hook proto_value_traits;
+ static const bool constant_time_size = true;
+ typedef std::size_t size_type;
+ typedef void compare;
 };
 
-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
@@ -79,1636 +67,397 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize>
 #endif
 class avltree_impl
- : private detail::clear_on_destructor_base<avltree_impl<Config> >
+ /// @cond
+ : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, AvlTreeAlgorithms>
+ /// @endcond
 {
- template<class C> friend class detail::clear_on_destructor_base;
    public:
- typedef typename Config::value_traits value_traits;
+ typedef ValueTraits value_traits;
    /// @cond
- static const bool external_value_traits =
- detail::external_value_traits_bool_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;
+ typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
+ , ConstantTimeSize, AvlTreeAlgorithms> tree_type;
+ typedef tree_type implementation_defined;
    /// @endcond
- typedef typename real_value_traits::pointer pointer;
- typedef typename real_value_traits::const_pointer const_pointer;
- typedef typename boost::intrusive::
- pointer_traits<pointer>::element_type value_type;
- typedef value_type key_type;
- typedef typename boost::intrusive::
- pointer_traits<pointer>::reference reference;
- typedef typename boost::intrusive::
- pointer_traits<const_pointer>::reference const_reference;
- typedef typename boost::intrusive::
- pointer_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 boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator;
- typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator;
- typedef typename real_value_traits::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename pointer_traits
- <pointer>::template rebind_pointer
- <node>::type node_ptr;
- typedef typename pointer_traits
- <pointer>::template rebind_pointer
- <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;
+ typedef typename implementation_defined::pointer pointer;
+ typedef typename implementation_defined::const_pointer const_pointer;
+ typedef typename implementation_defined::value_type value_type;
+ typedef typename implementation_defined::key_type key_type;
+ 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::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;
 
+ static const bool constant_time_size = implementation_defined::constant_time_size;
    /// @cond
    private:
- typedef detail::size_holder<constant_time_size, size_type> size_traits;
 
- //noncopyable, movable
+ //noncopyable
    BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree_impl)
 
- enum { safemode_or_autounlink =
- (int)real_value_traits::link_mode == (int)auto_unlink ||
- (int)real_value_traits::link_mode == (int)safe_link };
+ /// @endcond
 
- //Constant-time size is incompatible with auto-unlink hooks!
- BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+ public:
 
- struct header_plus_size : public size_traits
- { node header_; };
+ typedef typename implementation_defined::insert_commit_data insert_commit_data;
 
- 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_;
+ //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &)
+ explicit avltree_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(cmp, v_traits)
+ {}
 
- const value_compare &priv_comp() const
- { return data_.node_plus_pred_.get(); }
+ //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
+ template<class Iterator>
+ avltree_impl( bool unique, Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(unique, b, e, cmp, v_traits)
+ {}
 
- value_compare &priv_comp()
- { return data_.node_plus_pred_.get(); }
+ //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
+ avltree_impl(BOOST_RV_REF(avltree_impl) x)
+ : tree_type(::boost::move(static_cast<tree_type&>(x)))
+ {}
 
- const value_traits &priv_value_traits() const
- { return data_; }
+ //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
+ avltree_impl& operator=(BOOST_RV_REF(avltree_impl) x)
+ { return static_cast<avltree_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }
 
- value_traits &priv_value_traits()
- { return data_; }
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 
- node_ptr priv_header_ptr()
- { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); }
+ //! @copydoc ::boost::intrusive::bstree::~bstree()
+ ~avltree_impl();
 
- const_node_ptr priv_header_ptr() const
- { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); }
+ //! @copydoc ::boost::intrusive::bstree::begin()
+ iterator begin();
 
- static node_ptr uncast(const const_node_ptr & ptr)
- { return pointer_traits<node_ptr>::const_cast_from(ptr); }
+ //! @copydoc ::boost::intrusive::bstree::begin()const
+ const_iterator begin() const;
 
- size_traits &priv_size_traits()
- { return data_.node_plus_pred_.header_plus_size_; }
+ //! @copydoc ::boost::intrusive::bstree::cbegin()const
+ const_iterator cbegin() const;
 
- const size_traits &priv_size_traits() const
- { return data_.node_plus_pred_.header_plus_size_; }
+ //! @copydoc ::boost::intrusive::bstree::end()
+ iterator end();
 
- const real_value_traits &get_real_value_traits(detail::bool_<false>) const
- { return data_; }
+ //! @copydoc ::boost::intrusive::bstree::end()const
+ const_iterator end() const;
 
- const real_value_traits &get_real_value_traits(detail::bool_<true>) const
- { return data_.get_value_traits(*this); }
+ //! @copydoc ::boost::intrusive::bstree::cend()const
+ const_iterator cend() const;
 
- real_value_traits &get_real_value_traits(detail::bool_<false>)
- { return data_; }
+ //! @copydoc ::boost::intrusive::bstree::rbegin()
+ reverse_iterator rbegin();
 
- real_value_traits &get_real_value_traits(detail::bool_<true>)
- { return data_.get_value_traits(*this); }
+ //! @copydoc ::boost::intrusive::bstree::rbegin()const
+ const_reverse_iterator rbegin() const;
 
- /// @endcond
+ //! @copydoc ::boost::intrusive::bstree::crbegin()const
+ const_reverse_iterator crbegin() const;
 
- public:
+ //! @copydoc ::boost::intrusive::bstree::rend()
+ reverse_iterator rend();
 
- const real_value_traits &get_real_value_traits() const
- { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+ //! @copydoc ::boost::intrusive::bstree::rend()const
+ const_reverse_iterator rend() const;
 
- real_value_traits &get_real_value_traits()
- { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+ //! @copydoc ::boost::intrusive::bstree::crend()const
+ const_reverse_iterator crend() const;
 
- typedef typename node_algorithms::insert_commit_data insert_commit_data;
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
+ static avltree_impl &container_from_end_iterator(iterator end_iterator);
 
- //! <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.
- explicit avltree_impl( const value_compare &cmp = value_compare()
- , const value_traits &v_traits = value_traits())
- : data_(cmp, v_traits)
- {
- node_algorithms::init_header(this->priv_header_ptr());
- 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(this->priv_header_ptr());
- this->priv_size_traits().set_size(size_type(0));
- if(unique)
- this->insert_unique(b, e);
- else
- this->insert_equal(b, e);
- }
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
+ static const avltree_impl &container_from_end_iterator(const_iterator end_iterator);
 
- //! <b>Effects</b>: to-do
- //!
- avltree_impl(BOOST_RV_REF(avltree_impl) x)
- : data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits()))
- {
- node_algorithms::init_header(this->priv_header_ptr());
- this->priv_size_traits().set_size(size_type(0));
- this->swap(x);
- }
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
+ static avltree_impl &container_from_iterator(iterator it);
 
- //! <b>Effects</b>: to-do
- //!
- avltree_impl& operator=(BOOST_RV_REF(avltree_impl) x)
- { this->swap(x); return *this; }
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
+ static const avltree_impl &container_from_iterator(const_iterator it);
 
- //! <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()
- {}
+ //! @copydoc ::boost::intrusive::bstree::key_comp()const
+ key_compare key_comp() const;
 
- //! <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(this->priv_header_ptr()), 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(this->priv_header_ptr()), 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 (this->priv_header_ptr(), 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(this->priv_header_ptr()), 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(this->priv_header_ptr()); }
-
- //! <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(this->priv_header_ptr());
- }
- }
-
- //! <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(this->priv_header_ptr(), other.priv_header_ptr());
- 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));
- iterator ret(node_algorithms::insert_equal_upper_bound
- (this->priv_header_ptr(), to_insert, key_node_comp), this);
- this->priv_size_traits().increment();
- return ret;
- }
-
- //! <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));
- iterator ret(node_algorithms::insert_equal
- (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this);
- this->priv_size_traits().increment();
- return ret;
- }
-
- //! <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 iend(this->end());
- for (; b != e; ++b)
- this->insert_equal(iend, *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.
+ //! @copydoc ::boost::intrusive::bstree::value_comp()const
+ value_compare value_comp() const;
+
+ //! @copydoc ::boost::intrusive::bstree::empty()const
+ bool empty() const;
+
+ //! @copydoc ::boost::intrusive::bstree::size()const
+ size_type size() const;
+
+ //! @copydoc ::boost::intrusive::bstree::swap
+ void swap(avltree_impl& other);
+
+ //! @copydoc ::boost::intrusive::bstree::clone_from
+ template <class Cloner, class Disposer>
+ void clone_from(const avltree_impl &src, Cloner cloner, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
+ iterator insert_equal(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
+ iterator insert_equal(const_iterator hint, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
    template<class Iterator>
- void insert_unique(Iterator b, Iterator e)
- {
- if(this->empty()){
- iterator iend(this->end());
- for (; b != e; ++b)
- this->insert_unique(iend, *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.
+ void insert_equal(Iterator b, Iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
+ std::pair<iterator, bool> insert_unique(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
+ iterator insert_unique(const_iterator hint, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&)
    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
- (this->priv_header_ptr(), 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.
+ (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&)
    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
- (this->priv_header_ptr(), 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));
- node_algorithms::insert_unique_commit
- (this->priv_header_ptr(), to_insert, commit_data);
- this->priv_size_traits().increment();
- return iterator(to_insert, this);
- }
-
- //! <b>Requires</b>: value must be an lvalue, "pos" must be
- //! a valid iterator (or end) and must be the succesor of value
- //! once inserted according to the predicate
- //!
- //! <b>Effects</b>: Inserts x into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if "pos" is not
- //! the successor of "value" tree ordering invariant will be broken.
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- iterator insert_before(const_iterator pos, reference value)
- {
- 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));
- iterator ret(node_algorithms::insert_before
- (this->priv_header_ptr(), pos.pointed_node(), to_insert), this);
- this->priv_size_traits().increment();
- return ret;
- }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be no less
- //! than the greatest inserted key
- //!
- //! <b>Effects</b>: Inserts x into the tree in the last position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! less than the greatest inserted key tree ordering invariant will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_back(reference value)
- {
- 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));
- node_algorithms::push_back(this->priv_header_ptr(), to_insert);
- this->priv_size_traits().increment();
- }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be no greater
- //! than the minimum inserted key
- //!
- //! <b>Effects</b>: Inserts x into the tree in the first position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! greater than the minimum inserted key tree ordering invariant will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_front(reference value)
- {
- 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));
- node_algorithms::push_front(this->priv_header_ptr(), to_insert);
- this->priv_size_traits().increment();
- }
-
- //! <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(this->priv_header_ptr(), 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.
+ ,KeyValueCompare key_value_comp, insert_commit_data &commit_data);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
+ iterator insert_unique_commit(reference value, const insert_commit_data &commit_data);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
+ template<class Iterator>
+ void insert_unique(Iterator b, Iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_before
+ iterator insert_before(const_iterator pos, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_back
+ void push_back(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_front
+ void push_front(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
+ iterator erase(const_iterator i);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
+ iterator erase(const_iterator b, const_iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_reference)
+ size_type erase(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare)
    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;
- }
+ size_type erase(const KeyType& key, KeyValueCompare comp);
 
- #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
    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.
+ iterator erase_and_dispose(const_iterator i, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
    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); }
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer 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.
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer)
    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.
+ size_type erase_and_dispose(const_reference value, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
    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(this->priv_header_ptr());
- 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.
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::clear
+ void clear();
+
+ //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
    template<class Disposer>
- void clear_and_dispose(Disposer disposer)
- {
- node_algorithms::clear_and_dispose(this->priv_header_ptr()
- , detail::node_disposer<Disposer, avltree_impl>(disposer, this));
- node_algorithms::init_header(this->priv_header_ptr());
- 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.
+ void clear_and_dispose(Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
+ size_type count(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
    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.
+ size_type count(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)
+ iterator lower_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)
    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
- (this->priv_header_ptr(), 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.
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const
+ const_iterator lower_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const
    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
- (this->priv_header_ptr(), 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.
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)
+ iterator upper_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)
    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
- (this->priv_header_ptr(), 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.
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const
+ const_iterator upper_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const
    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
- (this->priv_header_ptr(), 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.
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::find(const_reference)
+ iterator find(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)
    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(this->priv_header_ptr(), 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.
+ iterator find(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::find(const_reference)const
+ const_iterator find(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const
    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(this->priv_header_ptr(), 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.
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)
+ std::pair<iterator,iterator> equal_range(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)
    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(this->priv_header_ptr(), 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<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const
    std::pair<const_iterator, const_iterator>
- equal_range(const_reference value) const
- { return this->equal_range(value, priv_comp()); }
+ equal_range(const_reference value) const;
 
- //! <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.
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const
    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(this->priv_header_ptr(), key, key_node_comp));
- return std::pair<const_iterator, const_iterator>(const_iterator(ret.first, this), const_iterator(ret.second, this));
- }
-
- //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
- //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If the predicate throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_value and upper_value.
+ equal_range(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)
    std::pair<iterator,iterator> bounded_range
- (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed)
- { return this->bounded_range(lower_value, upper_value, priv_comp(), left_closed, right_closed); }
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
 
- //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
- //! ordering compatible with the strict weak ordering used to create the
- //! the tree.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
- //!
- //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)
    template<class KeyType, class KeyValueCompare>
    std::pair<iterator,iterator> bounded_range
- (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed)
- {
- detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
- key_node_comp(comp, this);
- std::pair<node_ptr, node_ptr> ret
- (node_algorithms::bounded_range
- (this->priv_header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed));
- return std::pair<iterator, iterator>(iterator(ret.first, this), iterator(ret.second, this));
- }
-
- //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
- //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If the predicate throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_value and upper_value.
- std::pair<const_iterator,const_iterator> bounded_range
- (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const
- { return this->bounded_range(lower_value, upper_value, priv_comp(), left_closed, right_closed); }
-
- //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
- //! ordering compatible with the strict weak ordering used to create the
- //! the tree.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
- //!
- //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const
+ std::pair<const_iterator, const_iterator>
+ bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const
    template<class KeyType, class KeyValueCompare>
- std::pair<const_iterator,const_iterator> bounded_range
- (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const
- {
- detail::key_nodeptr_comp<KeyValueCompare, avltree_impl>
- key_node_comp(comp, this);
- std::pair<node_ptr, node_ptr> ret
- (node_algorithms::bounded_range
- (this->priv_header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed));
- 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
- (src.priv_header_ptr()
- ,this->priv_header_ptr()
- ,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
- (this->priv_header_ptr()));
- 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)
- , this->priv_header_ptr()
- , get_real_value_traits().to_node_ptr(with_this));
- if(safemode_or_autounlink)
- node_algorithms::init(replace_this.pointed_node());
- }
-
- //! <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);
- }
-*/
+ std::pair<const_iterator, const_iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
 
- /// @cond
+ //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
+ static iterator s_iterator_to(reference value);
 
- 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
+ //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
+ static const_iterator s_iterator_to(const_reference value);
 
- 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>
- ( boost::intrusive::detail::to_raw_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;
- }
+ //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
+ iterator iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
+ const_iterator iterator_to(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::init_node(reference)
+ static void init_node(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
+ pointer unlink_leftmost_without_rebalance();
 
- static avltree_impl &priv_container_from_iterator(const const_iterator &it)
- { return priv_container_from_end_iterator(it.end_iterator_from_it()); }
+ //! @copydoc ::boost::intrusive::bstree::replace_node
+ void replace_node(iterator replace_this, reference with_this);
+
+ //! @copydoc ::boost::intrusive::bstree::remove_node
+ void remove_node(reference value);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 };
 
 #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;
+bool operator< (const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &y);
 
- 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;
- }
-}
+template<class T, class ...Options>
+bool operator==(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &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 !(x == y); }
+bool operator!= (const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &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; }
+bool operator>(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &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); }
+bool operator<=(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &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 !(x < y); }
+bool operator>=(const avltree_impl<T, Options...> &x, const avltree_impl<T, Options...> &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); }
+void swap(avltree_impl<T, Options...> &x, avltree_impl<T, Options...> &y);
 
-/// @cond
+#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 
-#if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
-template<class T, class O1 = none, class O2 = none
- , class O3 = none, class O4 = none
- >
-#else
+//! 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 = void, class O2 = void
+ , class O3 = void, class O4 = void>
 #endif
-struct make_avltree_opt
+struct make_avltree
 {
+ /// @cond
    typedef typename pack_options
+ < avltree_defaults,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- < avl_set_defaults<T>, O1, O2, O3, O4>
+ O1, O2, O3, O4
       #else
- < avl_set_defaults<T>, Options...>
+ Options...
       #endif
- ::type packed_options;
+ >::type packed_options;
 
    typedef typename detail::get_value_traits
- <T, typename packed_options::value_traits>::type value_traits;
+ <T, typename packed_options::proto_value_traits>::type value_traits;
 
- typedef avl_setopt
+ typedef avltree_impl
          < 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;
+ > implementation_defined;
    /// @endcond
    typedef implementation_defined type;
 };
 
+
 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 
 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
@@ -1717,20 +466,22 @@
 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
+ : public make_avltree<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
 {
    typedef typename make_avltree
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- <T, O1, O2, O3, O4>
- #else
- <T, Options...>
- #endif
- ::type Base;
-
+ <T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type Base;
    BOOST_MOVABLE_BUT_NOT_COPYABLE(avltree)
 
    public:
@@ -1739,12 +490,14 @@
    typedef typename Base::real_value_traits real_value_traits;
    typedef typename Base::iterator iterator;
    typedef typename Base::const_iterator const_iterator;
+ typedef typename Base::reverse_iterator reverse_iterator;
+ typedef typename Base::const_reverse_iterator const_reverse_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())
+ explicit avltree( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
       : Base(cmp, v_traits)
    {}
 
@@ -1760,7 +513,7 @@
    {}
 
    avltree& operator=(BOOST_RV_REF(avltree) x)
- { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
+ { return static_cast<avltree &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
 
    static avltree &container_from_end_iterator(iterator end_iterator)
    { return static_cast<avltree &>(Base::container_from_end_iterator(end_iterator)); }
@@ -1777,7 +530,6 @@
 
 #endif
 
-
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/avltree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/avltree_algorithms.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/avltree_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Daniel K. O. 2005.
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -21,20 +21,52 @@
 
 #include <boost/intrusive/detail/assert.hpp>
 #include <boost/intrusive/detail/utilities.hpp>
-#include <boost/intrusive/detail/tree_algorithms.hpp>
+#include <boost/intrusive/bstree_algorithms.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
 
 
 namespace boost {
 namespace intrusive {
 
+/// @cond
+
+template<class NodeTraits, class F>
+struct avltree_node_cloner
+ : private detail::ebo_functor_holder<F>
+{
+ typedef typename NodeTraits::node_ptr node_ptr;
+ typedef detail::ebo_functor_holder<F> base_t;
+
+ avltree_node_cloner(F f)
+ : base_t(f)
+ {}
+
+ node_ptr operator()(const node_ptr & p)
+ {
+ node_ptr n = base_t::get()(p);
+ NodeTraits::set_balance(n, NodeTraits::get_balance(p));
+ return n;
+ }
+};
+
+template<class NodeTraits>
+struct avltree_erase_fixup
+{
+ typedef typename NodeTraits::node_ptr node_ptr;
+
+ void operator()(const node_ptr & to_erase, const node_ptr & successor)
+ { NodeTraits::set_balance(successor, NodeTraits::get_balance(to_erase)); }
+};
+
+/// @endcond
+
 //! 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</tt>: The type of the node that forms the binary search tree
 //!
 //! <tt>node_ptr</tt>: A pointer to a node
 //!
@@ -67,6 +99,9 @@
 //! <tt>static balance positive();</tt>
 template<class NodeTraits>
 class avltree_algorithms
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ : public bstree_algorithms<NodeTraits>
+ #endif
 {
    public:
    typedef typename NodeTraits::node node;
@@ -77,161 +112,69 @@
 
    /// @cond
    private:
- typedef detail::tree_algorithms<NodeTraits> tree_algorithms;
+ typedef bstree_algorithms<NodeTraits> bstree_algo;
 
- 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()(const 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()(const node_ptr &to_erase, const node_ptr &successor)
- { NodeTraits::set_balance(successor, NodeTraits::get_balance(to_erase)); }
- };
-
- static node_ptr uncast(const const_node_ptr & ptr)
- { return pointer_traits<node_ptr>::const_cast_from(ptr); }
    /// @endcond
 
    public:
- static node_ptr begin_node(const const_node_ptr & header)
- { return tree_algorithms::begin_node(header); }
-
- static node_ptr end_node(const 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;
+ typedef typename bstree_algo::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(const node_ptr & header1, const node_ptr & header2)
- { return tree_algorithms::swap_tree(header1, header2); }
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 
- //! <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
+ //! @copydoc ::boost::intrusive::bstree_algorithms::get_header(const const_node_ptr&)
+ static node_ptr get_header(const const_node_ptr & n);
+
+ //! @copydoc ::boost::intrusive::bstree_algorithms::begin_node
+ static node_ptr begin_node(const const_node_ptr & header);
+
+ //! @copydoc ::boost::intrusive::bstree_algorithms::end_node
+ static node_ptr end_node(const const_node_ptr & header);
+
+ //! @copydoc ::boost::intrusive::bstree_algorithms::swap_tree
+ static void swap_tree(const node_ptr & header1, const node_ptr & header2);
+
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! @copydoc ::boost::intrusive::bstree_algorithms::swap_nodes(const node_ptr&,const node_ptr&)
    static void swap_nodes(const node_ptr & node1, const node_ptr & node2)
    {
       if(node1 == node2)
          return;
 
- node_ptr header1(tree_algorithms::get_header(node1)), header2(tree_algorithms::get_header(node2));
+ node_ptr header1(bstree_algo::get_header(node1)), header2(bstree_algo::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
+ //! @copydoc ::boost::intrusive::bstree_algorithms::swap_nodes(const node_ptr&,const node_ptr&,const node_ptr&,const node_ptr&)
    static void swap_nodes(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2)
    {
       if(node1 == node2) return;
 
- tree_algorithms::swap_nodes(node1, header1, node2, header2);
+ bstree_algo::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
+ //! @copydoc ::boost::intrusive::bstree_algorithms::replace_node(const node_ptr&,const node_ptr&)
    static void replace_node(const node_ptr & node_to_be_replaced, const 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);
+ replace_node(node_to_be_replaced, bstree_algo::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
+ //! @copydoc ::boost::intrusive::bstree_algorithms::replace_node(const node_ptr&,const node_ptr&,const node_ptr&)
    static void replace_node(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node)
    {
- tree_algorithms::replace_node(node_to_be_replaced, header, new_node);
+ bstree_algo::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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::unlink(const node_ptr&)
    static void unlink(const node_ptr & node)
    {
       node_ptr x = NodeTraits::get_parent(node);
@@ -242,84 +185,25 @@
       }
    }
 
- //! <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(const node_ptr & header)
- { return tree_algorithms::unlink_leftmost_without_rebalance(header); }
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree_algorithms::unlink_leftmost_without_rebalance
+ static node_ptr unlink_leftmost_without_rebalance(const node_ptr & 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 const_node_ptr & node)
- { return tree_algorithms::unique(node); }
+ //! @copydoc ::boost::intrusive::bstree_algorithms::unique(const const_node_ptr&)
+ static bool unique(const const_node_ptr & 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 const_node_ptr & node)
- { return tree_algorithms::count(node); }
+ //! @copydoc ::boost::intrusive::bstree_algorithms::size(const const_node_ptr&)
+ static std::size_t size(const const_node_ptr & header);
 
- //! <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 const_node_ptr & header)
- { return tree_algorithms::size(header); }
+ //! @copydoc ::boost::intrusive::bstree_algorithms::next_node(const node_ptr&)
+ static node_ptr next_node(const node_ptr & node);
 
- //! <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(const node_ptr & p)
- { return tree_algorithms::next_node(p); }
+ //! @copydoc ::boost::intrusive::bstree_algorithms::prev_node(const node_ptr&)
+ static node_ptr prev_node(const node_ptr & node);
 
- //! <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(const 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(const node_ptr & node)
- { tree_algorithms::init(node); }
+ //! @copydoc ::boost::intrusive::bstree_algorithms::init(const node_ptr&)
+ static void init(const node_ptr & node);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 
    //! <b>Requires</b>: node must not be part of any tree.
    //!
@@ -333,419 +217,148 @@
    //! <b>Nodes</b>: If node is inserted in a tree, this function corrupts the tree.
    static void init_header(const node_ptr & header)
    {
- tree_algorithms::init_header(header);
+ bstree_algo::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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::erase(const node_ptr&,const node_ptr&)
    static node_ptr erase(const node_ptr & header, const 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;
-
+ typename bstree_algo::data_for_rebalance info;
+ bstree_algo::erase(header, z, avltree_erase_fixup<NodeTraits>(), info);
       //Rebalance avltree
- rebalance_after_erasure(header, x, x_parent);
+ rebalance_after_erasure(header, info.x, info.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()(const 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()(const node_ptr &)</tt> to obtain
- //! the nodes of the target tree. If "cloner" throws, the cloned target nodes
- //! are disposed using <tt>void disposer(const 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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::clone(const const_node_ptr&,const node_ptr&,Cloner,Disposer)
    template <class Cloner, class Disposer>
    static void clone
       (const const_node_ptr & source_header, const 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);
+ avltree_node_cloner<NodeTraits, Cloner> new_cloner(cloner);
+ bstree_algo::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()(const 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.
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree_algorithms::clear_and_dispose(const node_ptr&,Disposer)
    template<class Disposer>
- static void clear_and_dispose(const node_ptr & header, Disposer disposer)
- { tree_algorithms::clear_and_dispose(header, disposer); }
+ static void clear_and_dispose(const node_ptr & header, Disposer 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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::lower_bound(const const_node_ptr&,const KeyType&,KeyNodePtrCompare)
    template<class KeyType, class KeyNodePtrCompare>
    static node_ptr lower_bound
- (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- { return tree_algorithms::lower_bound(header, key, comp); }
+ (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare 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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::upper_bound(const const_node_ptr&,const KeyType&,KeyNodePtrCompare)
    template<class KeyType, class KeyNodePtrCompare>
    static node_ptr upper_bound
- (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- { return tree_algorithms::upper_bound(header, key, comp); }
+ (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare 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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::find(const const_node_ptr&,const KeyType&,KeyNodePtrCompare)
    template<class KeyType, class KeyNodePtrCompare>
    static node_ptr find
- (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- { return tree_algorithms::find(header, key, comp); }
+ (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare 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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::equal_range(const const_node_ptr&,const KeyType&,KeyNodePtrCompare)
    template<class KeyType, class KeyNodePtrCompare>
    static std::pair<node_ptr, node_ptr> equal_range
- (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- { return tree_algorithms::equal_range(header, key, comp); }
+ (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare 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.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::bounded_range(const const_node_ptr&,const KeyType&,const KeyType&,KeyNodePtrCompare,bool,bool)
    template<class KeyType, class KeyNodePtrCompare>
    static std::pair<node_ptr, node_ptr> bounded_range
       (const const_node_ptr & header, const KeyType &lower_key, const KeyType &upper_key, KeyNodePtrCompare comp
- , bool left_closed, bool right_closed)
- { return tree_algorithms::bounded_range(header, lower_key, upper_key, comp, left_closed, right_closed); }
+ , bool left_closed, bool right_closed);
 
- //! <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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::count(const const_node_ptr&,const KeyType&,KeyNodePtrCompare)
+ template<class KeyType, class KeyNodePtrCompare>
+ static std::size_t count(const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_equal_upper_bound(const node_ptr&,const node_ptr&,NodePtrCompare)
    template<class NodePtrCompare>
    static node_ptr insert_equal_upper_bound
       (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp)
    {
- tree_algorithms::insert_equal_upper_bound(h, new_node, comp);
+ bstree_algo::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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_equal_lower_bound(const node_ptr&,const node_ptr&,NodePtrCompare)
    template<class NodePtrCompare>
    static node_ptr insert_equal_lower_bound
       (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp)
    {
- tree_algorithms::insert_equal_lower_bound(h, new_node, comp);
+ bstree_algo::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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_equal(const node_ptr&,const node_ptr&,const node_ptr&,NodePtrCompare)
    template<class NodePtrCompare>
    static node_ptr insert_equal
       (const node_ptr & header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp)
    {
- tree_algorithms::insert_equal(header, hint, new_node, comp);
+ bstree_algo::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.
- //! "pos" must be a valid iterator or header (end) node.
- //! "pos" must be an iterator pointing to the successor to "new_node"
- //! once inserted according to the order of already inserted nodes. This function does not
- //! check "pos" and this precondition must be guaranteed by the caller.
- //!
- //! <b>Effects</b>: Inserts new_node into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant-time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node"
- //! tree invariants might be broken.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_before(const node_ptr&,const node_ptr&,const node_ptr&)
    static node_ptr insert_before
       (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node)
    {
- tree_algorithms::insert_before(header, pos, new_node);
+ bstree_algo::insert_before(header, pos, new_node);
       rebalance_after_insertion(header, new_node);
       return new_node;
    }
 
- //! <b>Requires</b>: "header" must be the header node of a tree.
- //! "new_node" must be, according to the used ordering no less than the
- //! greatest inserted key.
- //!
- //! <b>Effects</b>: Inserts new_node into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant-time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: If "new_node" is less than the greatest inserted key
- //! tree invariants are broken. This function is slightly faster than
- //! using "insert_before".
+ //! @copydoc ::boost::intrusive::bstree_algorithms::push_back(const node_ptr&,const node_ptr&)
    static void push_back(const node_ptr & header, const node_ptr & new_node)
    {
- tree_algorithms::push_back(header, new_node);
+ bstree_algo::push_back(header, new_node);
       rebalance_after_insertion(header, new_node);
    }
 
- //! <b>Requires</b>: "header" must be the header node of a tree.
- //! "new_node" must be, according to the used ordering, no greater than the
- //! lowest inserted key.
- //!
- //! <b>Effects</b>: Inserts new_node into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant-time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: If "new_node" is greater than the lowest inserted key
- //! tree invariants are broken. This function is slightly faster than
- //! using "insert_before".
+ //! @copydoc ::boost::intrusive::bstree_algorithms::push_front(const node_ptr&,const node_ptr&)
    static void push_front(const node_ptr & header, const node_ptr & new_node)
    {
- tree_algorithms::push_front(header, new_node);
+ bstree_algo::push_front(header, new_node);
       rebalance_after_insertion(header, 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.
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_unique_check(const const_node_ptr&,const KeyType&,KeyNodePtrCompare,insert_commit_data&)
    template<class KeyType, class KeyNodePtrCompare>
    static std::pair<node_ptr, bool> insert_unique_check
       (const 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); }
+ ,KeyNodePtrCompare comp, insert_commit_data &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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_unique_check(const const_node_ptr&,const node_ptr&,const KeyType&,KeyNodePtrCompare,insert_commit_data&)
    template<class KeyType, class KeyNodePtrCompare>
    static std::pair<node_ptr, bool> insert_unique_check
       (const const_node_ptr & header, const 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); }
+ ,KeyNodePtrCompare comp, insert_commit_data &commit_data);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 
- //! <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.
+ //! @copydoc ::boost::intrusive::bstree_algorithms::insert_unique_commit(const node_ptr&,const node_ptr&,const insert_commit_data &)
    static void insert_unique_commit
       (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data)
    {
- tree_algorithms::insert_unique_commit(header, new_value, commit_data);
+ bstree_algo::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(const node_ptr & n)
- { return tree_algorithms::get_header(n); }
+ //! @copydoc ::boost::intrusive::bstree_algorithms::is_header
+ static bool is_header(const const_node_ptr & p)
+ { return NodeTraits::get_balance(p) == NodeTraits::zero() && bstree_algo::is_header(p); }
+
 
    /// @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 const_node_ptr & p)
- { return NodeTraits::get_balance(p) == NodeTraits::zero() && tree_algorithms::is_header(p); }
-
    static void rebalance_after_erasure(const node_ptr & header, const node_ptr & xnode, const node_ptr & xnode_parent)
    {
       node_ptr x(xnode), x_parent(xnode_parent);
@@ -903,8 +516,8 @@
       // / \ //
       // e f //
       node_ptr b = NodeTraits::get_left(a), c = NodeTraits::get_right(b);
- tree_algorithms::rotate_left(b, hdr);
- tree_algorithms::rotate_right(a, hdr);
+ bstree_algo::rotate_left(b, hdr);
+ bstree_algo::rotate_right(a, hdr);
       left_right_balancing(a, b, c);
    }
 
@@ -920,15 +533,15 @@
       // / \ //
       // e f //
       node_ptr b = NodeTraits::get_right(a), c = NodeTraits::get_left(b);
- tree_algorithms::rotate_right(b, hdr);
- tree_algorithms::rotate_left(a, hdr);
+ bstree_algo::rotate_right(b, hdr);
+ bstree_algo::rotate_left(a, hdr);
       left_right_balancing(b, a, c);
    }
 
    static void rotate_left(const node_ptr x, const node_ptr & hdr)
    {
       const node_ptr y = NodeTraits::get_right(x);
- tree_algorithms::rotate_left(x, hdr);
+ bstree_algo::rotate_left(x, hdr);
 
       // reset the balancing factor
       if (NodeTraits::get_balance(y) == NodeTraits::positive()) {
@@ -944,7 +557,7 @@
    static void rotate_right(const node_ptr x, const node_ptr & hdr)
    {
       const node_ptr y = NodeTraits::get_left(x);
- tree_algorithms::rotate_right(x, hdr);
+ bstree_algo::rotate_right(x, hdr);
 
       // reset the balancing factor
       if (NodeTraits::get_balance(y) == NodeTraits::negative()) {
@@ -960,6 +573,16 @@
    /// @endcond
 };
 
+/// @cond
+
+template<class NodeTraits>
+struct get_algo<AvlTreeAlgorithms, NodeTraits>
+{
+ typedef avltree_algorithms<NodeTraits> type;
+};
+
+/// @endcond
+
 } //namespace intrusive
 } //namespace boost
 

Copied: branches/release/boost/intrusive/bs_set.hpp (from r85444, trunk/boost/intrusive/bs_set.hpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/boost/intrusive/bs_set.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445, copy of r85444, trunk/boost/intrusive/bs_set.hpp)
@@ -0,0 +1,922 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2013-2013
+//
+// 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_HPP
+#define BOOST_INTRUSIVE_BS_SET_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/mpl.hpp>
+#include <boost/intrusive/bstree.hpp>
+#include <iterator>
+#include <boost/move/move.hpp>
+
+namespace boost {
+namespace intrusive {
+
+//! The class template bs_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 ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
+#endif
+class bs_set_impl
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ : public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms>
+#endif
+{
+ /// @cond
+ typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, BsTreeAlgorithms> tree_type;
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_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;
+
+ static const bool constant_time_size = tree_type::constant_time_size;
+
+ public:
+ //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &)
+ explicit bs_set_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(cmp, v_traits)
+ {}
+
+ //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
+ template<class Iterator>
+ bs_set_impl( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(true, b, e, cmp, v_traits)
+ {}
+
+ //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
+ bs_set_impl(BOOST_RV_REF(bs_set_impl) x)
+ : tree_type(::boost::move(static_cast<tree_type&>(x)))
+ {}
+
+ //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
+ bs_set_impl& operator=(BOOST_RV_REF(bs_set_impl) x)
+ { return static_cast<bs_set_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree::~bstree()
+ ~bs_set_impl();
+
+ //! @copydoc ::boost::intrusive::bstree::begin()
+ iterator begin();
+
+ //! @copydoc ::boost::intrusive::bstree::begin()const
+ const_iterator begin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::cbegin()const
+ const_iterator cbegin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::end()
+ iterator end();
+
+ //! @copydoc ::boost::intrusive::bstree::end()const
+ const_iterator end() const;
+
+ //! @copydoc ::boost::intrusive::bstree::cend()const
+ const_iterator cend() const;
+
+ //! @copydoc ::boost::intrusive::bstree::rbegin()
+ reverse_iterator rbegin();
+
+ //! @copydoc ::boost::intrusive::bstree::rbegin()const
+ const_reverse_iterator rbegin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::crbegin()const
+ const_reverse_iterator crbegin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::rend()
+ reverse_iterator rend();
+
+ //! @copydoc ::boost::intrusive::bstree::rend()const
+ const_reverse_iterator rend() const;
+
+ //! @copydoc ::boost::intrusive::bstree::crend()const
+ const_reverse_iterator crend() const;
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
+ static bs_set_impl &container_from_end_iterator(iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
+ static const bs_set_impl &container_from_end_iterator(const_iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
+ static bs_set_impl &container_from_iterator(iterator it);
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
+ static const bs_set_impl &container_from_iterator(const_iterator it);
+
+ //! @copydoc ::boost::intrusive::bstree::key_comp()const
+ key_compare key_comp() const;
+
+ //! @copydoc ::boost::intrusive::bstree::value_comp()const
+ value_compare value_comp() const;
+
+ //! @copydoc ::boost::intrusive::bstree::empty()const
+ bool empty() const;
+
+ //! @copydoc ::boost::intrusive::bstree::size()const
+ size_type size() const;
+
+ //! @copydoc ::boost::intrusive::bstree::swap
+ void swap(bs_set_impl& other);
+
+ //! @copydoc ::boost::intrusive::bstree::clone_from
+ template <class Cloner, class Disposer>
+ void clone_from(const bs_set_impl &src, Cloner cloner, Disposer disposer);
+
+ #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
+ std::pair<iterator, bool> insert(reference value)
+ { return tree_type::insert_unique(value); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
+ iterator insert(const_iterator hint, reference value)
+ { return tree_type::insert_unique(hint, value); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&)
+ 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_type::insert_unique_check(key, key_value_comp, commit_data); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&)
+ 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_type::insert_unique_check(hint, key, key_value_comp, commit_data); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
+ template<class Iterator>
+ void insert(Iterator b, Iterator e)
+ { tree_type::insert_unique(b, e); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
+ iterator insert_commit(reference value, const insert_commit_data &commit_data)
+ { return tree_type::insert_unique_commit(value, commit_data); }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree::insert_before
+ iterator insert_before(const_iterator pos, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_back
+ void push_back(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_front
+ void push_front(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
+ iterator erase(const_iterator i);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
+ iterator erase(const_iterator b, const_iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_reference)
+ size_type erase(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator i, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer)
+ template<class Disposer>
+ size_type erase_and_dispose(const_reference value, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
+ template<class KeyType, class KeyValueCompare, class Disposer>
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::clear
+ void clear();
+
+ //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
+ template<class Disposer>
+ void clear_and_dispose(Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
+ size_type count(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)
+ iterator lower_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const
+ const_iterator lower_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)
+ iterator upper_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const
+ const_iterator upper_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::find(const_reference)
+ iterator find(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::find(const_reference)const
+ const_iterator find(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)
+ std::pair<iterator,iterator> equal_range(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const
+ std::pair<const_iterator, const_iterator>
+ equal_range(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator>
+ equal_range(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)
+ std::pair<iterator,iterator> bounded_range
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const
+ std::pair<const_iterator, const_iterator>
+ bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
+
+ //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
+ static iterator s_iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
+ static const_iterator s_iterator_to(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
+ iterator iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
+ const_iterator iterator_to(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::init_node(reference)
+ static void init_node(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
+ pointer unlink_leftmost_without_rebalance();
+
+ //! @copydoc ::boost::intrusive::bstree::replace_node
+ void replace_node(iterator replace_this, reference with_this);
+
+ //! @copydoc ::boost::intrusive::bstree::remove_node
+ void remove_node(reference value);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+};
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+template<class T, class ...Options>
+bool operator!= (const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+bool operator>(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+bool operator<=(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+bool operator>=(const bs_set_impl<T, Options...> &x, const bs_set_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+void swap(bs_set_impl<T, Options...> &x, bs_set_impl<T, Options...> &y);
+
+#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+//! Helper metafunction to define a \c bs_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 = void, class O2 = void
+ , class O3 = void, class O4 = void>
+#endif
+struct make_bs_set
+{
+ /// @cond
+ typedef typename pack_options
+ < bstree_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::proto_value_traits>::type value_traits;
+
+ typedef bs_set_impl
+ < value_traits
+ , typename packed_options::compare
+ , typename packed_options::size_type
+ , packed_options::constant_time_size
+ > 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 bs_set
+ : public make_bs_set<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
+{
+ typedef typename make_bs_set
+ <T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type Base;
+
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_set)
+ 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));
+
+ explicit bs_set( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(cmp, v_traits)
+ {}
+
+ template<class Iterator>
+ bs_set( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(b, e, cmp, v_traits)
+ {}
+
+ bs_set(BOOST_RV_REF(bs_set) x)
+ : Base(::boost::move(static_cast<Base&>(x)))
+ {}
+
+ bs_set& operator=(BOOST_RV_REF(bs_set) x)
+ { return static_cast<bs_set &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
+
+ static bs_set &container_from_end_iterator(iterator end_iterator)
+ { return static_cast<bs_set &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static const bs_set &container_from_end_iterator(const_iterator end_iterator)
+ { return static_cast<const bs_set &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static bs_set &container_from_iterator(iterator it)
+ { return static_cast<bs_set &>(Base::container_from_iterator(it)); }
+
+ static const bs_set &container_from_iterator(const_iterator it)
+ { return static_cast<const bs_set &>(Base::container_from_iterator(it)); }
+};
+
+#endif
+
+//! The class template bs_multiset is an intrusive container, that mimics most of
+//! the interface of std::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 ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
+#endif
+class bs_multiset_impl
+#ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ : public bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms>
+#endif
+{
+ /// @cond
+ typedef bstree_impl<ValueTraits, Compare, SizeType, ConstantTimeSize, RbTreeAlgorithms> tree_type;
+
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_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;
+
+ static const bool constant_time_size = tree_type::constant_time_size;
+
+ public:
+ //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &)
+ explicit bs_multiset_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(cmp, v_traits)
+ {}
+
+ //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
+ template<class Iterator>
+ bs_multiset_impl( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(false, b, e, cmp, v_traits)
+ {}
+
+ //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
+ bs_multiset_impl(BOOST_RV_REF(bs_multiset_impl) x)
+ : tree_type(::boost::move(static_cast<tree_type&>(x)))
+ {}
+
+ //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
+ bs_multiset_impl& operator=(BOOST_RV_REF(bs_multiset_impl) x)
+ { return static_cast<bs_multiset_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree::~bstree()
+ ~bs_multiset_impl();
+
+ //! @copydoc ::boost::intrusive::bstree::begin()
+ iterator begin();
+
+ //! @copydoc ::boost::intrusive::bstree::begin()const
+ const_iterator begin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::cbegin()const
+ const_iterator cbegin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::end()
+ iterator end();
+
+ //! @copydoc ::boost::intrusive::bstree::end()const
+ const_iterator end() const;
+
+ //! @copydoc ::boost::intrusive::bstree::cend()const
+ const_iterator cend() const;
+
+ //! @copydoc ::boost::intrusive::bstree::rbegin()
+ reverse_iterator rbegin();
+
+ //! @copydoc ::boost::intrusive::bstree::rbegin()const
+ const_reverse_iterator rbegin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::crbegin()const
+ const_reverse_iterator crbegin() const;
+
+ //! @copydoc ::boost::intrusive::bstree::rend()
+ reverse_iterator rend();
+
+ //! @copydoc ::boost::intrusive::bstree::rend()const
+ const_reverse_iterator rend() const;
+
+ //! @copydoc ::boost::intrusive::bstree::crend()const
+ const_reverse_iterator crend() const;
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
+ static bs_multiset_impl &container_from_end_iterator(iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
+ static const bs_multiset_impl &container_from_end_iterator(const_iterator end_iterator);
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
+ static bs_multiset_impl &container_from_iterator(iterator it);
+
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
+ static const bs_multiset_impl &container_from_iterator(const_iterator it);
+
+ //! @copydoc ::boost::intrusive::bstree::key_comp()const
+ key_compare key_comp() const;
+
+ //! @copydoc ::boost::intrusive::bstree::value_comp()const
+ value_compare value_comp() const;
+
+ //! @copydoc ::boost::intrusive::bstree::empty()const
+ bool empty() const;
+
+ //! @copydoc ::boost::intrusive::bstree::size()const
+ size_type size() const;
+
+ //! @copydoc ::boost::intrusive::bstree::swap
+ void swap(bs_multiset_impl& other);
+
+ //! @copydoc ::boost::intrusive::bstree::clone_from
+ template <class Cloner, class Disposer>
+ void clone_from(const bs_multiset_impl &src, Cloner cloner, Disposer disposer);
+
+ #endif //#ifdef BOOST_iNTRUSIVE_DOXYGEN_INVOKED
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
+ iterator insert(reference value)
+ { return tree_type::insert_equal(value); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
+ iterator insert(const_iterator hint, reference value)
+ { return tree_type::insert_equal(hint, value); }
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
+ template<class Iterator>
+ void insert(Iterator b, Iterator e)
+ { tree_type::insert_equal(b, e); }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree::insert_before
+ iterator insert_before(const_iterator pos, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_back
+ void push_back(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_front
+ void push_front(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
+ iterator erase(const_iterator i);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
+ iterator erase(const_iterator b, const_iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_reference)
+ size_type erase(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ size_type erase(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator i, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
+ template<class Disposer>
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer)
+ template<class Disposer>
+ size_type erase_and_dispose(const_reference value, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
+ template<class KeyType, class KeyValueCompare, class Disposer>
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::clear
+ void clear();
+
+ //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
+ template<class Disposer>
+ void clear_and_dispose(Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
+ size_type count(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ size_type count(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)
+ iterator lower_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)const
+ const_iterator lower_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)
+ iterator upper_bound(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const_reference)const
+ const_iterator upper_bound(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::upper_bound(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::find(const_reference)
+ iterator find(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::find(const_reference)const
+ const_iterator find(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::find(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)
+ std::pair<iterator,iterator> equal_range(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType& key, KeyValueCompare comp);
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const_reference)const
+ std::pair<const_iterator, const_iterator>
+ equal_range(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::equal_range(const KeyType&,KeyValueCompare)const
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator>
+ equal_range(const KeyType& key, KeyValueCompare comp) const;
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)
+ std::pair<iterator,iterator> bounded_range
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const_reference,const_reference,bool,bool)const
+ std::pair<const_iterator, const_iterator>
+ bounded_range(const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
+
+ //! @copydoc ::boost::intrusive::bstree::bounded_range(const KeyType&,const KeyType&,KeyValueCompare,bool,bool)const
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator> bounded_range
+ (const KeyType& lower_key, const KeyType& upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
+
+ //! @copydoc ::boost::intrusive::bstree::s_iterator_to(reference)
+ static iterator s_iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::s_iterator_to(const_reference)
+ static const_iterator s_iterator_to(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::iterator_to(reference)
+ iterator iterator_to(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::iterator_to(const_reference)const
+ const_iterator iterator_to(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::init_node(reference)
+ static void init_node(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::unlink_leftmost_without_rebalance
+ pointer unlink_leftmost_without_rebalance();
+
+ //! @copydoc ::boost::intrusive::bstree::replace_node
+ void replace_node(iterator replace_this, reference with_this);
+
+ //! @copydoc ::boost::intrusive::bstree::remove_node
+ void remove_node(reference value);
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+};
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+template<class T, class ...Options>
+bool operator!= (const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+bool operator>(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+bool operator<=(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+bool operator>=(const bs_multiset_impl<T, Options...> &x, const bs_multiset_impl<T, Options...> &y);
+
+template<class T, class ...Options>
+void swap(bs_multiset_impl<T, Options...> &x, bs_multiset_impl<T, Options...> &y);
+
+#endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+//! Helper metafunction to define a \c bs_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 = void, class O2 = void
+ , class O3 = void, class O4 = void>
+#endif
+struct make_bs_multiset
+{
+ /// @cond
+ typedef typename pack_options
+ < bstree_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::proto_value_traits>::type value_traits;
+
+ typedef bs_multiset_impl
+ < value_traits
+ , typename packed_options::compare
+ , typename packed_options::size_type
+ , packed_options::constant_time_size
+ > 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 bs_multiset
+ : public make_bs_multiset<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
+{
+ typedef typename make_bs_multiset<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type Base;
+
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(bs_multiset)
+
+ 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));
+
+ explicit bs_multiset( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(cmp, v_traits)
+ {}
+
+ template<class Iterator>
+ bs_multiset( Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(b, e, cmp, v_traits)
+ {}
+
+ bs_multiset(BOOST_RV_REF(bs_multiset) x)
+ : Base(::boost::move(static_cast<Base&>(x)))
+ {}
+
+ bs_multiset& operator=(BOOST_RV_REF(bs_multiset) x)
+ { return static_cast<bs_multiset &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
+
+ static bs_multiset &container_from_end_iterator(iterator end_iterator)
+ { return static_cast<bs_multiset &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static const bs_multiset &container_from_end_iterator(const_iterator end_iterator)
+ { return static_cast<const bs_multiset &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static bs_multiset &container_from_iterator(iterator it)
+ { return static_cast<bs_multiset &>(Base::container_from_iterator(it)); }
+
+ static const bs_multiset &container_from_iterator(const_iterator it)
+ { return static_cast<const bs_multiset &>(Base::container_from_iterator(it)); }
+};
+
+#endif
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_BS_SET_HPP

Modified: branches/release/boost/intrusive/bs_set_hook.hpp
==============================================================================
--- branches/release/boost/intrusive/bs_set_hook.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/bs_set_hook.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +17,7 @@
 #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/bstree_algorithms.hpp>
 #include <boost/intrusive/options.hpp>
 #include <boost/intrusive/detail/generic_hook.hpp>
 
@@ -28,7 +28,7 @@
 template<class VoidPointer>
 struct get_bs_set_node_algo
 {
- typedef detail::tree_algorithms<tree_node_traits<VoidPointer> > type;
+ typedef bstree_algorithms<tree_node_traits<VoidPointer> > type;
 };
 /// @endcond
 
@@ -37,7 +37,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_bs_set_base_hook
 {
@@ -50,14 +50,11 @@
    #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
+ typedef generic_hook
    < get_bs_set_node_algo<typename packed_options::void_pointer>
    , typename packed_options::tag
    , packed_options::link_mode
- , detail::BsSetBaseHook
+ , BsTreeBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -168,7 +165,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_bs_set_member_hook
 {
@@ -182,14 +179,11 @@
 
    ::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
+ typedef generic_hook
    < get_bs_set_node_algo<typename packed_options::void_pointer>
    , member_tag
    , packed_options::link_mode
- , detail::NoBaseHook
+ , NoBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;

Copied: branches/release/boost/intrusive/bstree.hpp (from r85444, trunk/boost/intrusive/bstree.hpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/boost/intrusive/bstree.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445, copy of r85444, trunk/boost/intrusive/bstree.hpp)
@@ -0,0 +1,2014 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2013-2013
+//
+// 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_BSTREE_HPP
+#define BOOST_INTRUSIVE_BSTREE_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/set_hook.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/pointer_traits.hpp>
+#include <boost/intrusive/detail/clear_on_destructor_base.hpp>
+#include <boost/intrusive/detail/function_detector.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/bstree_algorithms.hpp>
+#include <boost/intrusive/link_mode.hpp>
+#include <boost/move/move.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/// @cond
+
+struct bstree_defaults
+{
+ typedef detail::default_bstree_hook proto_value_traits;
+ static const bool constant_time_size = true;
+ typedef std::size_t size_type;
+ typedef void compare;
+ static const bool floating_point = true; //For sgtree
+ typedef void priority; //For treap
+};
+
+template<class ValueTraits, algo_types AlgoType>
+struct bstbase3
+ : public detail::get_real_value_traits<ValueTraits>::type::node_traits::node
+ , public ValueTraits
+{
+ typedef ValueTraits value_traits;
+ typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename node_traits::node node_type;
+ typedef typename get_algo<AlgoType, node_traits>::type node_algorithms;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::const_node_ptr const_node_ptr;
+
+ bstbase3(const ValueTraits &vtraits)
+ : ValueTraits(vtraits)
+ {}
+
+ static const bool external_value_traits =
+ detail::external_value_traits_bool_is_true<ValueTraits>::value;
+
+ node_ptr header_ptr()
+ { return pointer_traits<node_ptr>::pointer_to(static_cast<node_type&>(*this)); }
+
+ const_node_ptr header_ptr() const
+ { return pointer_traits<const_node_ptr>::pointer_to(static_cast<const node_type&>(*this)); }
+
+ const value_traits &val_traits() const
+ { return *this; }
+
+ value_traits &val_traits()
+ { return *this; }
+
+ const real_value_traits &get_real_value_traits(detail::bool_<false>) const
+ { return *this; }
+
+ const real_value_traits &get_real_value_traits(detail::bool_<true>) const
+ { return this->val_traits().get_value_traits(*this); }
+
+ real_value_traits &get_real_value_traits(detail::bool_<false>)
+ { return *this; }
+
+ real_value_traits &get_real_value_traits(detail::bool_<true>)
+ { return this->val_traits().get_value_traits(*this); }
+
+ 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 pointer_traits<node_ptr>::template rebind_pointer<const real_value_traits>::type const_real_value_traits_ptr;
+
+ const_real_value_traits_ptr real_value_traits_ptr() const
+ { return pointer_traits<const_real_value_traits_ptr>::pointer_to(this->get_real_value_traits()); }
+
+
+ typedef tree_iterator<real_value_traits, false> iterator;
+ typedef tree_iterator<real_value_traits, true> const_iterator;
+ typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator;
+ typedef boost::intrusive::detail::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::pointer) pointer;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::const_pointer) const_pointer;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
+ static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value;
+ static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
+
+ iterator begin()
+ { return iterator (node_traits::get_left(this->header_ptr()), this->real_value_traits_ptr()); }
+
+ const_iterator begin() const
+ { return cbegin(); }
+
+ const_iterator cbegin() const
+ { return const_iterator (node_traits::get_left(this->header_ptr()), this->real_value_traits_ptr()); }
+
+ iterator end()
+ { return iterator (this->header_ptr(), this->real_value_traits_ptr()); }
+
+ const_iterator end() const
+ { return cend(); }
+
+ const_iterator cend() const
+ { return const_iterator (detail::uncast(this->header_ptr()), this->real_value_traits_ptr()); }
+
+ reverse_iterator rbegin()
+ { return reverse_iterator(end()); }
+
+ const_reverse_iterator rbegin() const
+ { return const_reverse_iterator(end()); }
+
+ const_reverse_iterator crbegin() const
+ { return const_reverse_iterator(end()); }
+
+ reverse_iterator rend()
+ { return reverse_iterator(begin()); }
+
+ const_reverse_iterator rend() const
+ { return const_reverse_iterator(begin()); }
+
+ const_reverse_iterator crend() const
+ { return const_reverse_iterator(begin()); }
+
+ void replace_node(iterator replace_this, reference with_this)
+ {
+ node_algorithms::replace_node( get_real_value_traits().to_node_ptr(*replace_this)
+ , this->header_ptr()
+ , get_real_value_traits().to_node_ptr(with_this));
+ if(safemode_or_autounlink)
+ node_algorithms::init(replace_this.pointed_node());
+ }
+
+ void rebalance()
+ { node_algorithms::rebalance(this->header_ptr()); }
+
+ iterator rebalance_subtree(iterator root)
+ { return iterator(node_algorithms::rebalance_subtree(root.pointed_node()), this->real_value_traits_ptr()); }
+
+ static iterator s_iterator_to(reference value)
+ {
+ BOOST_STATIC_ASSERT((!stateful_value_traits));
+ return iterator (value_traits::to_node_ptr(value), const_real_value_traits_ptr());
+ }
+
+ 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)), const_real_value_traits_ptr());
+ }
+
+ iterator iterator_to(reference value)
+ { return iterator (value_traits::to_node_ptr(value), this->real_value_traits_ptr()); }
+
+ const_iterator iterator_to(const_reference value) const
+ { return const_iterator (value_traits::to_node_ptr(const_cast<reference> (value)), this->real_value_traits_ptr()); }
+
+ static void init_node(reference value)
+ { node_algorithms::init(value_traits::to_node_ptr(value)); }
+
+};
+
+template<class ValueTraits, class VoidOrKeyComp, algo_types AlgoType>
+struct bstbase2
+ : public bstbase3<ValueTraits, AlgoType>
+ , public detail::ebo_functor_holder<typename get_less< VoidOrKeyComp
+ , typename detail::get_real_value_traits<ValueTraits>::type::value_type
+ >::type>
+{
+ typedef bstbase3<ValueTraits, AlgoType> treeheader_t;
+ typedef typename treeheader_t::real_value_traits real_value_traits;
+ typedef typename treeheader_t::node_algorithms node_algorithms;
+ typedef typename get_less
+ < VoidOrKeyComp, typename real_value_traits::value_type>::type value_compare;
+ typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare;
+ typedef typename treeheader_t::iterator iterator;
+ typedef typename treeheader_t::const_iterator const_iterator;
+ typedef typename treeheader_t::node_ptr node_ptr;
+ typedef typename treeheader_t::const_node_ptr const_node_ptr;
+
+ bstbase2(const value_compare &comp, const ValueTraits &vtraits)
+ : treeheader_t(vtraits), detail::ebo_functor_holder<value_compare>(comp)
+ {}
+
+ const value_compare &comp() const
+ { return this->get(); }
+
+ value_compare &comp()
+ { return this->get(); }
+
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::pointer) pointer;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::const_pointer) const_pointer;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
+ typedef typename node_algorithms::insert_commit_data insert_commit_data;
+
+ value_compare value_comp() const
+ { return this->comp(); }
+
+ key_compare key_comp() const
+ { return this->comp(); }
+
+ iterator lower_bound(const_reference value)
+ { return this->lower_bound(value, this->comp()); }
+
+ const_iterator lower_bound(const_reference value) const
+ { return this->lower_bound(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ iterator lower_bound(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ return iterator(node_algorithms::lower_bound
+ (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr());
+ }
+
+ template<class KeyType, class KeyValueCompare>
+ const_iterator lower_bound(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ return const_iterator(node_algorithms::lower_bound
+ (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr());
+ }
+
+ iterator upper_bound(const_reference value)
+ { return this->upper_bound(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ iterator upper_bound(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ return iterator(node_algorithms::upper_bound
+ (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr());
+ }
+
+ const_iterator upper_bound(const_reference value) const
+ { return this->upper_bound(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ const_iterator upper_bound(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ return const_iterator(node_algorithms::upper_bound
+ (this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr());
+ }
+
+ iterator find(const_reference value)
+ { return this->find(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ iterator find(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ return iterator
+ (node_algorithms::find(this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr());
+ }
+
+ const_iterator find(const_reference value) const
+ { return this->find(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ const_iterator find(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ return const_iterator
+ (node_algorithms::find(this->header_ptr(), key, key_node_comp), this->real_value_traits_ptr());
+ }
+
+ std::pair<iterator,iterator> equal_range(const_reference value)
+ { return this->equal_range(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> equal_range(const KeyType &key, KeyValueCompare comp)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ std::pair<node_ptr, node_ptr> ret
+ (node_algorithms::equal_range(this->header_ptr(), key, key_node_comp));
+ return std::pair<iterator, iterator>( iterator(ret.first, this->real_value_traits_ptr())
+ , iterator(ret.second, this->real_value_traits_ptr()));
+ }
+
+ std::pair<const_iterator, const_iterator>
+ equal_range(const_reference value) const
+ { return this->equal_range(value, this->comp()); }
+
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator, const_iterator>
+ equal_range(const KeyType &key, KeyValueCompare comp) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ std::pair<node_ptr, node_ptr> ret
+ (node_algorithms::equal_range(this->header_ptr(), key, key_node_comp));
+ return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->real_value_traits_ptr())
+ , const_iterator(ret.second, this->real_value_traits_ptr()));
+ }
+
+ std::pair<iterator,iterator> bounded_range
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed)
+ { return this->bounded_range(lower_value, upper_value, this->comp(), left_closed, right_closed); }
+
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> bounded_range
+ (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed)
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ std::pair<node_ptr, node_ptr> ret
+ (node_algorithms::bounded_range
+ (this->header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed));
+ return std::pair<iterator, iterator>( iterator(ret.first, this->real_value_traits_ptr())
+ , iterator(ret.second, this->real_value_traits_ptr()));
+ }
+
+ std::pair<const_iterator,const_iterator> bounded_range
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const
+ { return this->bounded_range(lower_value, upper_value, this->comp(), left_closed, right_closed); }
+
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator,const_iterator> bounded_range
+ (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const
+ {
+ detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
+ key_node_comp(comp, &this->get_real_value_traits());
+ std::pair<node_ptr, node_ptr> ret
+ (node_algorithms::bounded_range
+ (this->header_ptr(), lower_key, upper_key, key_node_comp, left_closed, right_closed));
+ return std::pair<const_iterator, const_iterator>( const_iterator(ret.first, this->real_value_traits_ptr())
+ , const_iterator(ret.second, this->real_value_traits_ptr()));
+ }
+
+ 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, real_value_traits>
+ ocomp(key_value_comp, &this->get_real_value_traits());
+ std::pair<node_ptr, bool> ret =
+ (node_algorithms::insert_unique_check
+ (this->header_ptr(), key, ocomp, commit_data));
+ return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second);
+ }
+
+ 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, real_value_traits>
+ ocomp(key_value_comp, &this->get_real_value_traits());
+ std::pair<node_ptr, bool> ret =
+ (node_algorithms::insert_unique_check
+ (this->header_ptr(), hint.pointed_node(), key, ocomp, commit_data));
+ return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second);
+ }
+};
+
+template<class ValueTraits, class VoidOrKeyComp, bool ConstantTimeSize, class SizeType, algo_types AlgoType>
+struct bstbase
+ : public detail::size_holder<ConstantTimeSize, SizeType>
+ , public bstbase2 < ValueTraits, VoidOrKeyComp, AlgoType>
+{
+ typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits;
+ typedef bstbase2< ValueTraits, VoidOrKeyComp, AlgoType> base_type;
+ typedef typename base_type::value_compare value_compare;
+ typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare;
+ typedef typename base_type::const_reference const_reference;
+ typedef typename base_type::reference reference;
+ typedef typename base_type::iterator iterator;
+ typedef typename base_type::const_iterator const_iterator;
+ typedef typename base_type::node_traits node_traits;
+ typedef typename get_algo
+ <AlgoType, node_traits>::type algo_type;
+ typedef SizeType size_type;
+
+ bstbase(const value_compare & comp, const ValueTraits &vtraits)
+ : base_type(comp, vtraits)
+ {}
+
+ public:
+ typedef detail::size_holder<ConstantTimeSize, SizeType> size_traits;
+
+ size_traits &sz_traits()
+ { return *this; }
+
+ const size_traits &sz_traits() const
+ { return *this; }
+
+ size_type count(const_reference value) const
+ { return size_type(this->count(value, this->comp())); }
+
+ 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 size_type(std::distance(ret.first, ret.second));
+ }
+
+ bool empty() const
+ {
+ if(ConstantTimeSize){
+ return !this->sz_traits().get_size();
+ }
+ else{
+ return algo_type::unique(this->header_ptr());
+ }
+ }
+};
+
+
+/// @endcond
+
+//! The class template bstree is an unbalanced intrusive binary search tree
+//! container. The no-throw guarantee holds only, if the value_compare object
+//! doesn't throw.
+//!
+//! The complexity guarantees only hold if the tree is balanced, logarithmic
+//! complexity would increase to linear if the tree is totally unbalanced.
+//!
+//! 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 ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+class bstree_impl
+ : public bstbase<ValueTraits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType>
+ , private detail::clear_on_destructor_base
+ < bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType>
+ , is_safe_autounlink<detail::get_real_value_traits<ValueTraits>::type::link_mode>::value
+ >
+{
+ template<class C, bool> friend class detail::clear_on_destructor_base;
+ public:
+ typedef ValueTraits value_traits;
+ /// @cond
+ static const bool external_value_traits =
+ detail::external_value_traits_bool_is_true<value_traits>::value;
+ typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits;
+ typedef bstbase<value_traits, VoidKeyComp, ConstantTimeSize, SizeType, AlgoType> data_type;
+ typedef tree_iterator<real_value_traits, false> iterator_type;
+ typedef tree_iterator<real_value_traits, true> const_iterator_type;
+ /// @endcond
+
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::pointer) pointer;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::const_pointer) const_pointer;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::element_type) value_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(value_type) key_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<pointer>::reference) reference;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::reference) const_reference;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename pointer_traits<const_pointer>::difference_type) difference_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(SizeType) size_type;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename data_type::value_compare) value_compare;
+ typedef BOOST_INTRUSIVE_IMPDEF(value_compare) key_compare;
+ typedef BOOST_INTRUSIVE_IMPDEF(iterator_type) iterator;
+ typedef BOOST_INTRUSIVE_IMPDEF(const_iterator_type) const_iterator;
+ typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_INTRUSIVE_IMPDEF(boost::intrusive::detail::reverse_iterator<const_iterator>) const_reverse_iterator;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename real_value_traits::node_traits) node_traits;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node) node;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::node_ptr) node_ptr;
+ typedef BOOST_INTRUSIVE_IMPDEF(typename node_traits::const_node_ptr) const_node_ptr;
+ /// @cond
+ typedef typename get_algo<AlgoType, node_traits>::type algo_type;
+ /// @endcond
+ typedef BOOST_INTRUSIVE_IMPDEF(algo_type) node_algorithms;
+
+ static const bool constant_time_size = ConstantTimeSize;
+ static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
+ /// @cond
+ private:
+
+ //noncopyable
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree_impl)
+
+ static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value;
+
+ //Constant-time size is incompatible with auto-unlink hooks!
+ BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+
+
+ protected:
+
+
+ /// @endcond
+
+ public:
+
+ typedef typename node_algorithms::insert_commit_data insert_commit_data;
+
+ //! <b>Effects</b>: Constructs an empty container.
+ //!
+ //! <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 constructorof the value_compare object throws. Basic guarantee.
+ explicit bstree_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : data_type(cmp, v_traits)
+ {
+ node_algorithms::init_header(this->header_ptr());
+ this->sz_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 container 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>
+ bstree_impl( bool unique, Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : data_type(cmp, v_traits)
+ {
+ node_algorithms::init_header(this->header_ptr());
+ this->sz_traits().set_size(size_type(0));
+ if(unique)
+ this->insert_unique(b, e);
+ else
+ this->insert_equal(b, e);
+ }
+
+ //! <b>Effects</b>: to-do
+ //!
+ bstree_impl(BOOST_RV_REF(bstree_impl) x)
+ : data_type(::boost::move(x.comp()), ::boost::move(x.val_traits()))
+ {
+ node_algorithms::init_header(this->header_ptr());
+ this->sz_traits().set_size(size_type(0));
+ this->swap(x);
+ }
+
+ //! <b>Effects</b>: to-do
+ //!
+ bstree_impl& operator=(BOOST_RV_REF(bstree_impl) x)
+ { this->swap(x); return *this; }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! <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.
+ ~bstree_impl()
+ {}
+
+ //! <b>Effects</b>: Returns an iterator pointing to the beginning of the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator begin();
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator begin() const;
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the beginning of the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cbegin() const;
+
+ //! <b>Effects</b>: Returns an iterator pointing to the end of the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ iterator end();
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator end() const;
+
+ //! <b>Effects</b>: Returns a const_iterator pointing to the end of the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_iterator cend() const;
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning of the
+ //! reversed container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rbegin();
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rbegin() const;
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crbegin() const;
+
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ reverse_iterator rend();
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator rend() const;
+
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
+ //! of the reversed container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ const_reverse_iterator crend() const;
+
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! <b>Precondition</b>: end_iterator must be a valid end iterator
+ //! of the container.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the container associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static bstree_impl &container_from_end_iterator(iterator end_iterator)
+ {
+ return *static_cast<bstree_impl*>
+ (boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()));
+ }
+
+ //! <b>Precondition</b>: end_iterator must be a valid end const_iterator
+ //! of the container.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the container associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ static const bstree_impl &container_from_end_iterator(const_iterator end_iterator)
+ {
+ return *static_cast<const bstree_impl*>
+ (boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()));
+ }
+
+ //! <b>Precondition</b>: it must be a valid iterator
+ //! of the container.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the container associated to the iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static bstree_impl &container_from_iterator(iterator it)
+ { return container_from_end_iterator(it.end_iterator_from_it()); }
+
+ //! <b>Precondition</b>: it must be a valid end const_iterator
+ //! of container.
+ //!
+ //! <b>Effects</b>: Returns a const reference to the container associated to the end iterator
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ static const bstree_impl &container_from_iterator(const_iterator it)
+ { return container_from_end_iterator(it.end_iterator_from_it()); }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! <b>Effects</b>: Returns the key_compare object used by the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_compare copy-constructor throws.
+ key_compare key_comp() const;
+
+ //! <b>Effects</b>: Returns the value_compare object used by the container.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If value_compare copy-constructor throws.
+ value_compare value_comp() const;
+
+ //! <b>Effects</b>: Returns true if the container is empty.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ bool empty() const;
+
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! <b>Effects</b>: Returns the number of elements stored in the container.
+ //!
+ //! <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->sz_traits().get_size();
+ else{
+ return (size_type)node_algorithms::size(this->header_ptr());
+ }
+ }
+
+ //! <b>Effects</b>: Swaps the contents of two containers.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: If the comparison functor's swap call throws.
+ void swap(bstree_impl& other)
+ {
+ //This can throw
+ using std::swap;
+ swap(this->comp(), this->comp());
+ //These can't throw
+ node_algorithms::swap_tree(this->header_ptr(), node_ptr(other.header_ptr()));
+ if(constant_time_size){
+ size_type backup = this->sz_traits().get_size();
+ this->sz_traits().set_size(other.sz_traits().get_size());
+ other.sz_traits().set_size(backup);
+ }
+ }
+
+ //! <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 bstree_impl &src, Cloner cloner, Disposer disposer)
+ {
+ this->clear_and_dispose(disposer);
+ if(!src.empty()){
+ detail::exception_disposer<bstree_impl, Disposer>
+ rollback(*this, disposer);
+ node_algorithms::clone
+ (const_node_ptr(src.header_ptr())
+ ,node_ptr(this->header_ptr())
+ ,detail::node_cloner <Cloner, real_value_traits, AlgoType>(cloner, &this->get_real_value_traits())
+ ,detail::node_disposer<Disposer, real_value_traits, AlgoType>(disposer, &this->get_real_value_traits()));
+ this->sz_traits().set_size(src.sz_traits().get_size());
+ this->comp() = src.comp();
+ rollback.release();
+ }
+ }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Inserts value into the container 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, real_value_traits>
+ key_node_comp(this->comp(), &this->get_real_value_traits());
+ node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ iterator ret(node_algorithms::insert_equal_upper_bound
+ (this->header_ptr(), to_insert, key_node_comp), this->real_value_traits_ptr());
+ this->sz_traits().increment();
+ return ret;
+ }
+
+ //! <b>Requires</b>: value must be an lvalue, and "hint" must be
+ //! a valid iterator.
+ //!
+ //! <b>Effects</b>: Inserts x into the container, 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, real_value_traits>
+ key_node_comp(this->comp(), &this->get_real_value_traits());
+ node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ iterator ret(node_algorithms::insert_equal
+ (this->header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this->real_value_traits_ptr());
+ this->sz_traits().increment();
+ return ret;
+ }
+
+ //! <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 container
+ //! 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 iend(this->end());
+ for (; b != e; ++b)
+ this->insert_equal(iend, *b);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue
+ //!
+ //! <b>Effects</b>: Inserts value into the container 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 = this->insert_unique_check(value, this->comp(), commit_data);
+ if(!ret.second)
+ return ret;
+ return std::pair<iterator, bool> (this->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 container, 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 = this->insert_unique_check(hint, value, this->comp(), commit_data);
+ if(!ret.second)
+ return ret.first;
+ return this->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 container.
+ //!
+ //! <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 iend(this->end());
+ for (; b != e; ++b)
+ this->insert_unique(iend, *b);
+ }
+ else{
+ for (; b != e; ++b)
+ this->insert_unique(*b);
+ }
+ }
+
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! <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);
+
+ //! <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);
+
+ #endif //#ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+
+ //! <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 container 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(this->get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ node_algorithms::insert_unique_commit
+ (this->header_ptr(), to_insert, commit_data);
+ this->sz_traits().increment();
+ return iterator(to_insert, this->real_value_traits_ptr());
+ }
+
+ //! <b>Requires</b>: value must be an lvalue, "pos" must be
+ //! a valid iterator (or end) and must be the succesor of value
+ //! once inserted according to the predicate
+ //!
+ //! <b>Effects</b>: Inserts x into the container before "pos".
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function does not check preconditions so if "pos" is not
+ //! the successor of "value" container ordering invariant will be broken.
+ //! This is a low-level function to be used only for performance reasons
+ //! by advanced users.
+ iterator insert_before(const_iterator pos, reference value)
+ {
+ node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ this->sz_traits().increment();
+ return iterator(node_algorithms::insert_before
+ (this->header_ptr(), pos.pointed_node(), to_insert), this->real_value_traits_ptr());
+ }
+
+ //! <b>Requires</b>: value must be an lvalue, and it must be no less
+ //! than the greatest inserted key
+ //!
+ //! <b>Effects</b>: Inserts x into the container in the last position.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function does not check preconditions so if value is
+ //! less than the greatest inserted key container ordering invariant will be broken.
+ //! This function is slightly more efficient than using "insert_before".
+ //! This is a low-level function to be used only for performance reasons
+ //! by advanced users.
+ void push_back(reference value)
+ {
+ node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ this->sz_traits().increment();
+ node_algorithms::push_back(this->header_ptr(), to_insert);
+ }
+
+ //! <b>Requires</b>: value must be an lvalue, and it must be no greater
+ //! than the minimum inserted key
+ //!
+ //! <b>Effects</b>: Inserts x into the container in the first position.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: This function does not check preconditions so if value is
+ //! greater than the minimum inserted key container ordering invariant will be broken.
+ //! This function is slightly more efficient than using "insert_before".
+ //! This is a low-level function to be used only for performance reasons
+ //! by advanced users.
+ void push_front(reference value)
+ {
+ node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+ if(safemode_or_autounlink)
+ BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
+ this->sz_traits().increment();
+ node_algorithms::push_front(this->header_ptr(), to_insert);
+ }
+
+ //! <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(this->header_ptr(), to_erase);
+ this->sz_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 this->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, this->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;
+ this->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(this->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 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;
+ this->private_erase(p.first, p.second, n, disposer);
+ return n;
+ }
+
+ //! <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 this->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 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;
+ this->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(this->header_ptr());
+ this->sz_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(this->header_ptr()
+ , detail::node_disposer<Disposer, real_value_traits, AlgoType>(disposer, &this->get_real_value_traits()));
+ node_algorithms::init_header(this->header_ptr());
+ this->sz_traits().set_size(0);
+ }
+
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+ //! <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;
+
+ //! <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;
+
+ //! <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);
+
+ //! <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;
+
+ //! <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);
+
+ //! <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;
+
+ //! <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);
+
+ //! <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);
+
+ //! <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;
+
+ //! <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;
+
+ //! <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);
+
+ //! <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);
+
+ //! <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;
+
+ //! <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;
+
+ //! <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);
+
+ //! <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);
+
+ //! <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;
+
+ //! <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;
+
+ //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
+ //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
+ //!
+ //! <b>Effects</b>: Returns an a pair with the following criteria:
+ //!
+ //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
+ //!
+ //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the predicate throws.
+ //!
+ //! <b>Note</b>: This function can be more efficient than calling upper_bound
+ //! and lower_bound for lower_value and upper_value.
+ //!
+ //! <b>Note</b>: Experimental function, the interface might change in future releases.
+ std::pair<iterator,iterator> bounded_range
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed);
+
+ //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the container.
+ //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
+ //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
+ //!
+ //! <b>Effects</b>: Returns an a pair with the following criteria:
+ //!
+ //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
+ //!
+ //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ //!
+ //! <b>Note</b>: This function can be more efficient than calling upper_bound
+ //! and lower_bound for lower_key and upper_key.
+ //!
+ //! <b>Note</b>: Experimental function, the interface might change in future releases.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<iterator,iterator> bounded_range
+ (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed);
+
+ //! <b>Requires</b>: 'lower_value' must not be greater than 'upper_value'. If
+ //! 'lower_value' == 'upper_value', ('left_closed' || 'right_closed') must be false.
+ //!
+ //! <b>Effects</b>: Returns an a pair with the following criteria:
+ //!
+ //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
+ //!
+ //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If the predicate throws.
+ //!
+ //! <b>Note</b>: This function can be more efficient than calling upper_bound
+ //! and lower_bound for lower_value and upper_value.
+ //!
+ //! <b>Note</b>: Experimental function, the interface might change in future releases.
+ std::pair<const_iterator,const_iterator> bounded_range
+ (const_reference lower_value, const_reference upper_value, bool left_closed, bool right_closed) const;
+
+ //! <b>Requires</b>: KeyValueCompare is a function object that induces a strict weak
+ //! ordering compatible with the strict weak ordering used to create the
+ //! the container.
+ //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
+ //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
+ //!
+ //! <b>Effects</b>: Returns an a pair with the following criteria:
+ //!
+ //! first = lower_bound(lower_key, comp) if left_closed, upper_bound(lower_key, comp) otherwise
+ //!
+ //! second = upper_bound(upper_key, comp) if right_closed, lower_bound(upper_key, comp) otherwise
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ //!
+ //! <b>Note</b>: This function can be more efficient than calling upper_bound
+ //! and lower_bound for lower_key and upper_key.
+ //!
+ //! <b>Note</b>: Experimental function, the interface might change in future releases.
+ template<class KeyType, class KeyValueCompare>
+ std::pair<const_iterator,const_iterator> bounded_range
+ (const KeyType &lower_key, const KeyType &upper_key, KeyValueCompare comp, bool left_closed, bool right_closed) const;
+
+ //! <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);
+
+ //! <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);
+
+ //! <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);
+
+ //! <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;
+
+ //! <b>Requires</b>: value shall not be in a container.
+ //!
+ //! <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);
+
+ #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: Unlinks the leftmost node from the container.
+ //!
+ //! <b>Complexity</b>: Average complexity is constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Notes</b>: This function breaks the container and the container 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 container.
+ pointer unlink_leftmost_without_rebalance()
+ {
+ node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance
+ (this->header_ptr()));
+ if(!to_be_disposed)
+ return 0;
+ this->sz_traits().decrement();
+ if(safemode_or_autounlink)//If this is commented does not work with normal_link
+ node_algorithms::init(to_be_disposed);
+ return this->get_real_value_traits().to_value_ptr(to_be_disposed);
+ }
+
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+ //! <b>Requires</b>: replace_this must be a valid iterator of *this
+ //! and with_this must not be inserted in any container.
+ //!
+ //! <b>Effects</b>: Replaces replace_this in its position in the
+ //! container with with_this. The container 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);
+
+ //! <b>Effects</b>: Rebalances the tree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear.
+ void rebalance();
+
+ //! <b>Requires</b>: old_root is a node of a tree.
+ //!
+ //! <b>Effects</b>: Rebalances the subtree rooted at old_root.
+ //!
+ //! <b>Returns</b>: The new root of the subtree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear to the elements in the subtree.
+ iterator rebalance_subtree(iterator root);
+
+ #endif //#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+
+ //! <b>Effects</b>: removes "value" from the container.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Logarithmic time.
+ //!
+ //! <b>Note</b>: This static function is only usable with non-constant
+ //! time size containers that have stateless comparison functors.
+ //!
+ //! If the user calls
+ //! this function with a constant time size container or stateful comparison
+ //! functor a compilation error will be issued.
+ static void remove_node(reference value)
+ {
+ BOOST_STATIC_ASSERT((!constant_time_size));
+ node_ptr to_remove(value_traits::to_node_ptr(value));
+ node_algorithms::unlink(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 bstree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
+ {
+ return *static_cast<bstree_impl*>
+ (boost::intrusive::detail::to_raw_pointer(end_iterator.pointed_node()));
+ }
+};
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+inline bool operator<
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
+#else
+( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &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 ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+bool operator==
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
+#else
+( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
+#endif
+{
+ typedef bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> 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 ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+inline bool operator!=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
+#else
+( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
+#endif
+{ return !(x == y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+inline bool operator>
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
+#else
+( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
+#endif
+{ return y < x; }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+inline bool operator<=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
+#else
+( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
+#endif
+{ return !(y < x); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+inline bool operator>=
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(const bstree_impl<T, Options...> &x, const bstree_impl<T, Options...> &y)
+#else
+( const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, const bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
+#endif
+{ return !(x < y); }
+
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class ValueTraits, class VoidKeyComp, class SizeType, bool ConstantTimeSize, algo_types AlgoType>
+#endif
+inline void swap
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+(bstree_impl<T, Options...> &x, bstree_impl<T, Options...> &y)
+#else
+( bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &x
+, bstree_impl<ValueTraits, VoidKeyComp, SizeType, ConstantTimeSize, AlgoType> &y)
+#endif
+{ x.swap(y); }
+
+//! Helper metafunction to define a \c bstree 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 = void, class O2 = void
+ , class O3 = void, class O4 = void>
+#endif
+struct make_bstree
+{
+ /// @cond
+ typedef typename pack_options
+ < bstree_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::proto_value_traits>::type value_traits;
+
+ typedef bstree_impl
+ < value_traits
+ , typename packed_options::compare
+ , typename packed_options::size_type
+ , packed_options::constant_time_size
+ , BsTreeAlgorithms
+ > 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 bstree
+ : public make_bstree<T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type
+{
+ typedef typename make_bstree
+ <T,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4
+ #else
+ Options...
+ #endif
+ >::type Base;
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(bstree)
+
+ 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));
+
+ bstree( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : Base(cmp, v_traits)
+ {}
+
+ template<class Iterator>
+ bstree( 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)
+ {}
+
+ bstree(BOOST_RV_REF(bstree) x)
+ : Base(::boost::move(static_cast<Base&>(x)))
+ {}
+
+ bstree& operator=(BOOST_RV_REF(bstree) x)
+ { return static_cast<bstree &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
+
+ static bstree &container_from_end_iterator(iterator end_iterator)
+ { return static_cast<bstree &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static const bstree &container_from_end_iterator(const_iterator end_iterator)
+ { return static_cast<const bstree &>(Base::container_from_end_iterator(end_iterator)); }
+
+ static bstree &container_from_iterator(iterator it)
+ { return static_cast<bstree &>(Base::container_from_iterator(it)); }
+
+ static const bstree &container_from_iterator(const_iterator it)
+ { return static_cast<const bstree &>(Base::container_from_iterator(it)); }
+};
+
+#endif
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_BSTREE_HPP

Copied: branches/release/boost/intrusive/bstree_algorithms.hpp (from r85444, trunk/boost/intrusive/bstree_algorithms.hpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/boost/intrusive/bstree_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445, copy of r85444, trunk/boost/intrusive/bstree_algorithms.hpp)
@@ -0,0 +1,1988 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2007-2013
+//
+// 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_BSTREE_ALGORITHMS_HPP
+#define BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/detail/assert.hpp>
+#include <boost/intrusive/intrusive_fwd.hpp>
+#include <cstddef>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/pointer_traits.hpp>
+
+namespace boost {
+namespace intrusive {
+
+/// @cond
+
+//! This type is the information that will be filled by insert_unique_check
+template <class NodePtr>
+struct insert_commit_data_t
+{
+ insert_commit_data_t()
+ : link_left(false)
+ , node()
+ {}
+ bool link_left;
+ NodePtr node;
+};
+
+template <class NodePtr>
+struct data_for_rebalance_t
+{
+ NodePtr x;
+ NodePtr x_parent;
+ NodePtr y;
+};
+
+/// @endcond
+
+
+
+//! This is an implementation of a binary search tree.
+//! A node in the search tree has references to its children and its parent. This
+//! is to allow traversal of the whole tree from a given node making the
+//! implementation of iterator a pointer to a node.
+//! At the top of the tree a node is used specially. This node's parent pointer
+//! is pointing to the root of the tree. Its left pointer points to the
+//! leftmost node in the tree and the right pointer to the rightmost one.
+//! This node is used to represent the end-iterator.
+//!
+//! +---------+
+//! header------------------------------>| |
+//! | |
+//! +----------(left)--------| |--------(right)---------+
+//! | +---------+ |
+//! | | |
+//! | | (parent) |
+//! | | |
+//! | | |
+//! | +---------+ |
+//! root of tree ..|......................> | | |
+//! | | D | |
+//! | | | |
+//! | +-------+---------+-------+ |
+//! | | | |
+//! | | | |
+//! | | | |
+//! | | | |
+//! | | | |
+//! | +---------+ +---------+ |
+//! | | | | | |
+//! | | B | | F | |
+//! | | | | | |
+//! | +--+---------+--+ +--+---------+--+ |
+//! | | | | | |
+//! | | | | | |
+//! | | | | | |
+//! | +---+-----+ +-----+---+ +---+-----+ +-----+---+ |
+//! +-->| | | | | | | |<--+
+//! | A | | C | | E | | G |
+//! | | | | | | | |
+//! +---------+ +---------+ +---------+ +---------+
+//!
+//! bstree_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 binary search tree
+//!
+//! <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_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>
+template<class NodeTraits>
+class bstree_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 insert_commit_data_t<node_ptr> insert_commit_data;
+ typedef data_for_rebalance_t<node_ptr> data_for_rebalance;
+
+ /// @cond
+
+ private:
+ template<class Disposer>
+ struct dispose_subtree_disposer
+ {
+ dispose_subtree_disposer(Disposer &disp, const node_ptr & subtree)
+ : disposer_(&disp), subtree_(subtree)
+ {}
+
+ void release()
+ { disposer_ = 0; }
+
+ ~dispose_subtree_disposer()
+ {
+ if(disposer_){
+ dispose_subtree(subtree_, *disposer_);
+ }
+ }
+ Disposer *disposer_;
+ const node_ptr subtree_;
+ };
+
+ /// @endcond
+
+ public:
+ //! <b>Requires</b>: 'header' is the header node of a tree.
+ //!
+ //! <b>Effects</b>: Returns the first node of the tree, the header if the tree is empty.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr begin_node(const const_node_ptr & header)
+ { return node_traits::get_left(header); }
+
+ //! <b>Requires</b>: 'header' is the header node of a tree.
+ //!
+ //! <b>Effects</b>: Returns the header of the tree.
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr end_node(const const_node_ptr & header)
+ { return detail::uncast(header); }
+
+ //! <b>Requires</b>: 'node' is a node of the tree or an node initialized
+ //! by init(...) or init_node.
+ //!
+ //! <b>Effects</b>: Returns true if the node is initialized by init() or init_node().
+ //!
+ //! <b>Complexity</b>: Constant time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool unique(const const_node_ptr & node)
+ { return !NodeTraits::get_parent(node); }
+
+ //! <b>Requires</b>: 'node' is a node of the tree or a header node.
+ //!
+ //! <b>Effects</b>: Returns the header of the tree.
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr get_header(const const_node_ptr & node)
+ {
+ node_ptr n(detail::uncast(node));
+ node_ptr p(NodeTraits::get_parent(node));
+ //If p is null, then n is the header of an empty tree
+ if(p){
+ //Non-empty tree, check if n is neither root nor header
+ node_ptr pp(NodeTraits::get_parent(p));
+ //If granparent is not equal to n, then n is neither root nor header,
+ //the try the fast path
+ if(n != pp){
+ do{
+ n = p;
+ p = pp;
+ pp = NodeTraits::get_parent(pp);
+ }while(n != pp);
+ n = p;
+ }
+ //Check if n is root or header when size() > 0
+ else if(!is_header(n)){
+ n = p;
+ }
+ }
+ return n;
+ /*
+ node_ptr h = detail::uncast(node);
+ node_ptr p = NodeTraits::get_parent(node);
+ if(p){
+ while(!is_header(p))
+ p = NodeTraits::get_parent(p);
+ return p;
+ }
+ else{
+ return h;
+ }*/
+ }
+
+ //! <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(const node_ptr & node1, const node_ptr & node2)
+ {
+ if(node1 == node2)
+ return;
+
+ node_ptr header1(get_header(node1)), header2(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(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2)
+ {
+ if(node1 == node2)
+ return;
+
+ //node1 and node2 must not be header nodes
+ //BOOST_INTRUSIVE_INVARIANT_ASSERT((header1 != node1 && header2 != node2));
+ if(header1 != header2){
+ //Update header1 if necessary
+ if(node1 == NodeTraits::get_left(header1)){
+ NodeTraits::set_left(header1, node2);
+ }
+
+ if(node1 == NodeTraits::get_right(header1)){
+ NodeTraits::set_right(header1, node2);
+ }
+
+ if(node1 == NodeTraits::get_parent(header1)){
+ NodeTraits::set_parent(header1, node2);
+ }
+
+ //Update header2 if necessary
+ if(node2 == NodeTraits::get_left(header2)){
+ NodeTraits::set_left(header2, node1);
+ }
+
+ if(node2 == NodeTraits::get_right(header2)){
+ NodeTraits::set_right(header2, node1);
+ }
+
+ if(node2 == NodeTraits::get_parent(header2)){
+ NodeTraits::set_parent(header2, node1);
+ }
+ }
+ else{
+ //If both nodes are from the same tree
+ //Update header if necessary
+ if(node1 == NodeTraits::get_left(header1)){
+ NodeTraits::set_left(header1, node2);
+ }
+ else if(node2 == NodeTraits::get_left(header2)){
+ NodeTraits::set_left(header2, node1);
+ }
+
+ if(node1 == NodeTraits::get_right(header1)){
+ NodeTraits::set_right(header1, node2);
+ }
+ else if(node2 == NodeTraits::get_right(header2)){
+ NodeTraits::set_right(header2, node1);
+ }
+
+ if(node1 == NodeTraits::get_parent(header1)){
+ NodeTraits::set_parent(header1, node2);
+ }
+ else if(node2 == NodeTraits::get_parent(header2)){
+ NodeTraits::set_parent(header2, node1);
+ }
+
+ //Adjust data in nodes to be swapped
+ //so that final link swap works as expected
+ if(node1 == NodeTraits::get_parent(node2)){
+ NodeTraits::set_parent(node2, node2);
+
+ if(node2 == NodeTraits::get_right(node1)){
+ NodeTraits::set_right(node1, node1);
+ }
+ else{
+ NodeTraits::set_left(node1, node1);
+ }
+ }
+ else if(node2 == NodeTraits::get_parent(node1)){
+ NodeTraits::set_parent(node1, node1);
+
+ if(node1 == NodeTraits::get_right(node2)){
+ NodeTraits::set_right(node2, node2);
+ }
+ else{
+ NodeTraits::set_left(node2, node2);
+ }
+ }
+ }
+
+ //Now swap all the links
+ node_ptr temp;
+ //swap left link
+ temp = NodeTraits::get_left(node1);
+ NodeTraits::set_left(node1, NodeTraits::get_left(node2));
+ NodeTraits::set_left(node2, temp);
+ //swap right link
+ temp = NodeTraits::get_right(node1);
+ NodeTraits::set_right(node1, NodeTraits::get_right(node2));
+ NodeTraits::set_right(node2, temp);
+ //swap parent link
+ temp = NodeTraits::get_parent(node1);
+ NodeTraits::set_parent(node1, NodeTraits::get_parent(node2));
+ NodeTraits::set_parent(node2, temp);
+
+ //Now adjust adjacent nodes for newly inserted node 1
+ if((temp = NodeTraits::get_left(node1))){
+ NodeTraits::set_parent(temp, node1);
+ }
+ if((temp = NodeTraits::get_right(node1))){
+ NodeTraits::set_parent(temp, node1);
+ }
+ if((temp = NodeTraits::get_parent(node1)) &&
+ //The header has been already updated so avoid it
+ temp != header2){
+ if(NodeTraits::get_left(temp) == node2){
+ NodeTraits::set_left(temp, node1);
+ }
+ if(NodeTraits::get_right(temp) == node2){
+ NodeTraits::set_right(temp, node1);
+ }
+ }
+ //Now adjust adjacent nodes for newly inserted node 2
+ if((temp = NodeTraits::get_left(node2))){
+ NodeTraits::set_parent(temp, node2);
+ }
+ if((temp = NodeTraits::get_right(node2))){
+ NodeTraits::set_parent(temp, node2);
+ }
+ if((temp = NodeTraits::get_parent(node2)) &&
+ //The header has been already updated so avoid it
+ temp != header1){
+ if(NodeTraits::get_left(temp) == node1){
+ NodeTraits::set_left(temp, node2);
+ }
+ if(NodeTraits::get_right(temp) == node1){
+ NodeTraits::set_right(temp, node2);
+ }
+ }
+ }
+
+ //! <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(const node_ptr & node_to_be_replaced, const node_ptr & new_node)
+ {
+ if(node_to_be_replaced == new_node)
+ return;
+ replace_node(node_to_be_replaced, 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(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node)
+ {
+ if(node_to_be_replaced == new_node)
+ return;
+
+ //Update header if necessary
+ if(node_to_be_replaced == NodeTraits::get_left(header)){
+ NodeTraits::set_left(header, new_node);
+ }
+
+ if(node_to_be_replaced == NodeTraits::get_right(header)){
+ NodeTraits::set_right(header, new_node);
+ }
+
+ if(node_to_be_replaced == NodeTraits::get_parent(header)){
+ NodeTraits::set_parent(header, new_node);
+ }
+
+ //Now set data from the original node
+ node_ptr temp;
+ NodeTraits::set_left(new_node, NodeTraits::get_left(node_to_be_replaced));
+ NodeTraits::set_right(new_node, NodeTraits::get_right(node_to_be_replaced));
+ NodeTraits::set_parent(new_node, NodeTraits::get_parent(node_to_be_replaced));
+
+ //Now adjust adjacent nodes for newly inserted node
+ if((temp = NodeTraits::get_left(new_node))){
+ NodeTraits::set_parent(temp, new_node);
+ }
+ if((temp = NodeTraits::get_right(new_node))){
+ NodeTraits::set_parent(temp, new_node);
+ }
+ if((temp = NodeTraits::get_parent(new_node)) &&
+ //The header has been already updated so avoid it
+ temp != header){
+ if(NodeTraits::get_left(temp) == node_to_be_replaced){
+ NodeTraits::set_left(temp, new_node);
+ }
+ if(NodeTraits::get_right(temp) == node_to_be_replaced){
+ NodeTraits::set_right(temp, new_node);
+ }
+ }
+ }
+
+ //! <b>Requires</b>: 'node' 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(const node_ptr & node)
+ {
+ node_ptr p_right(NodeTraits::get_right(node));
+ if(p_right){
+ return minimum(p_right);
+ }
+ else {
+ node_ptr p(node);
+ node_ptr x = NodeTraits::get_parent(p);
+ while(p == NodeTraits::get_right(x)){
+ p = x;
+ x = NodeTraits::get_parent(x);
+ }
+ return NodeTraits::get_right(p) != x ? x : detail::uncast(p);
+ }
+ }
+
+ //! <b>Requires</b>: 'node' 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(const node_ptr & node)
+ {
+ if(is_header(node)){
+ return NodeTraits::get_right(node);
+ //return maximum(NodeTraits::get_parent(node));
+ }
+ else if(NodeTraits::get_left(node)){
+ return maximum(NodeTraits::get_left(node));
+ }
+ else {
+ node_ptr p(node);
+ node_ptr x = NodeTraits::get_parent(p);
+ while(p == NodeTraits::get_left(x)){
+ p = x;
+ x = NodeTraits::get_parent(x);
+ }
+ return x;
+ }
+ }
+
+ //! <b>Requires</b>: 'node' is a node of a tree but not the header.
+ //!
+ //! <b>Effects</b>: Returns the minimum node of the subtree starting at p.
+ //!
+ //! <b>Complexity</b>: Logarithmic to the size of the subtree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr minimum (node_ptr node)
+ {
+ for(node_ptr p_left = NodeTraits::get_left(node)
+ ;p_left
+ ;p_left = NodeTraits::get_left(node)){
+ node = p_left;
+ }
+ return node;
+ }
+
+ //! <b>Requires</b>: 'node' is a node of a tree but not the header.
+ //!
+ //! <b>Effects</b>: Returns the maximum node of the subtree starting at p.
+ //!
+ //! <b>Complexity</b>: Logarithmic to the size of the subtree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static node_ptr maximum(node_ptr node)
+ {
+ for(node_ptr p_right = NodeTraits::get_right(node)
+ ;p_right
+ ;p_right = NodeTraits::get_right(node)){
+ node = p_right;
+ }
+ return node;
+ }
+
+ //! <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(const node_ptr & node)
+ {
+ NodeTraits::set_parent(node, node_ptr());
+ NodeTraits::set_left(node, node_ptr());
+ NodeTraits::set_right(node, node_ptr());
+ };
+
+ //! <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 const_node_ptr & node)
+ {
+ return !NodeTraits::get_parent(node) &&
+ !NodeTraits::get_left(node) &&
+ !NodeTraits::get_right(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(const node_ptr & header)
+ {
+ NodeTraits::set_parent(header, node_ptr());
+ NodeTraits::set_left(header, header);
+ NodeTraits::set_right(header, header);
+ }
+
+ //! <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()(const 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(const node_ptr & header, Disposer disposer)
+ {
+ node_ptr source_root = NodeTraits::get_parent(header);
+ if(!source_root)
+ return;
+ dispose_subtree(source_root, disposer);
+ init_header(header);
+ }
+
+ //! <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(const node_ptr & header)
+ {
+ node_ptr leftmost = NodeTraits::get_left(header);
+ if (leftmost == header)
+ return node_ptr();
+ node_ptr leftmost_parent(NodeTraits::get_parent(leftmost));
+ node_ptr leftmost_right (NodeTraits::get_right(leftmost));
+ bool is_root = leftmost_parent == header;
+
+ if (leftmost_right){
+ NodeTraits::set_parent(leftmost_right, leftmost_parent);
+ NodeTraits::set_left(header, bstree_algorithms::minimum(leftmost_right));
+
+ if (is_root)
+ NodeTraits::set_parent(header, leftmost_right);
+ else
+ NodeTraits::set_left(NodeTraits::get_parent(header), leftmost_right);
+ }
+ else if (is_root){
+ NodeTraits::set_parent(header, node_ptr());
+ NodeTraits::set_left(header, header);
+ NodeTraits::set_right(header, header);
+ }
+ else{
+ NodeTraits::set_left(leftmost_parent, node_ptr());
+ NodeTraits::set_left(header, leftmost_parent);
+ }
+ return leftmost;
+ }
+
+ //! <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 size(const const_node_ptr & header)
+ {
+ node_ptr beg(begin_node(header));
+ node_ptr end(end_node(header));
+ std::size_t i = 0;
+ for(;beg != end; beg = next_node(beg)) ++i;
+ return i;
+ }
+
+ //! <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(const node_ptr & header1, const node_ptr & header2)
+ {
+ if(header1 == header2)
+ return;
+
+ node_ptr tmp;
+
+ //Parent swap
+ tmp = NodeTraits::get_parent(header1);
+ NodeTraits::set_parent(header1, NodeTraits::get_parent(header2));
+ NodeTraits::set_parent(header2, tmp);
+ //Left swap
+ tmp = NodeTraits::get_left(header1);
+ NodeTraits::set_left(header1, NodeTraits::get_left(header2));
+ NodeTraits::set_left(header2, tmp);
+ //Right swap
+ tmp = NodeTraits::get_right(header1);
+ NodeTraits::set_right(header1, NodeTraits::get_right(header2));
+ NodeTraits::set_right(header2, tmp);
+
+ //Now test parent
+ node_ptr h1_parent(NodeTraits::get_parent(header1));
+ if(h1_parent){
+ NodeTraits::set_parent(h1_parent, header1);
+ }
+ else{
+ NodeTraits::set_left(header1, header1);
+ NodeTraits::set_right(header1, header1);
+ }
+
+ node_ptr h2_parent(NodeTraits::get_parent(header2));
+ if(h2_parent){
+ NodeTraits::set_parent(h2_parent, header2);
+ }
+ else{
+ NodeTraits::set_left(header2, header2);
+ NodeTraits::set_right(header2, header2);
+ }
+ }
+
+ //! <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 const_node_ptr & p)
+ {
+ node_ptr p_left (NodeTraits::get_left(p));
+ node_ptr p_right(NodeTraits::get_right(p));
+ if(!NodeTraits::get_parent(p) || //Header condition when empty tree
+ (p_left && p_right && //Header always has leftmost and rightmost
+ (p_left == p_right || //Header condition when only node
+ (NodeTraits::get_parent(p_left) != p ||
+ NodeTraits::get_parent(p_right) != p ))
+ //When tree size > 1 headers can't be leftmost's
+ //and rightmost's parent
+ )){
+ return true;
+ }
+ return false;
+ }
+
+ //! <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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ node_ptr end = detail::uncast(header);
+ node_ptr y = lower_bound(header, key, comp);
+ return (y == end || comp(key, y)) ? end : y;
+ }
+
+ //! <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.
+ //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
+ //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
+ //!
+ //! <b>Effects</b>: Returns an a pair with the following criteria:
+ //!
+ //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
+ //!
+ //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ //!
+ //! <b>Note</b>: This function can be more efficient than calling upper_bound
+ //! and lower_bound for lower_key and upper_key.
+ //!
+ //! <b>Note</b>: Experimental function, the interface might change.
+ template< class KeyType, class KeyNodePtrCompare>
+ static std::pair<node_ptr, node_ptr> bounded_range
+ ( const const_node_ptr & header
+ , const KeyType &lower_key
+ , const KeyType &upper_key
+ , KeyNodePtrCompare comp
+ , bool left_closed
+ , bool right_closed)
+ {
+ node_ptr y = detail::uncast(header);
+ node_ptr x = NodeTraits::get_parent(header);
+
+ while(x){
+ //If x is less than lower_key the target
+ //range is on the right part
+ if(comp(x, lower_key)){
+ //Check for invalid input range
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(comp(x, upper_key));
+ x = NodeTraits::get_right(x);
+ }
+ //If the upper_key is less than x, the target
+ //range is on the left part
+ else if(comp(upper_key, x)){
+ //y > upper_key
+ y = x;
+ x = NodeTraits::get_left(x);
+ }
+ else{
+ //x is inside the bounded range( x >= lower_key && x <= upper_key),
+ //so we must split lower and upper searches
+ //
+ //Sanity check: if lower_key and upper_key are equal, then both left_closed and right_closed can't be false
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(left_closed || right_closed || comp(lower_key, x) || comp(x, upper_key));
+ return std::pair<node_ptr,node_ptr>(
+ left_closed
+ //If left_closed, then comp(x, lower_key) is already the lower_bound
+ //condition so we save one comparison and go to the next level
+ //following traditional lower_bound algo
+ ? lower_bound_loop(NodeTraits::get_left(x), x, lower_key, comp)
+ //If left-open, comp(x, lower_key) is not the upper_bound algo
+ //condition so we must recheck current 'x' node with upper_bound algo
+ : upper_bound_loop(x, y, lower_key, comp)
+ ,
+ right_closed
+ //If right_closed, then comp(upper_key, x) is already the upper_bound
+ //condition so we can save one comparison and go to the next level
+ //following lower_bound algo
+ ? upper_bound_loop(NodeTraits::get_right(x), y, upper_key, comp)
+ //If right-open, comp(upper_key, x) is not the lower_bound algo
+ //condition so we must recheck current 'x' node with lower_bound algo
+ : lower_bound_loop(x, y, upper_key, comp)
+ );
+ }
+ }
+ return std::pair<node_ptr,node_ptr> (y, y);
+ }
+
+ //! <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 the number of elements with a key equivalent to "key"pair of node_ptr delimiting a range containing
+ //! according to "comp".
+ //!
+ //! <b>Complexity</b>: Logarithmic.
+ //!
+ //! <b>Throws</b>: If "comp" throws.
+ template<class KeyType, class KeyNodePtrCompare>
+ static std::size_t count
+ (const const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ std::pair<node_ptr, node_ptr> ret = equal_range(header, key, comp);
+ std::size_t n = 0;
+ while(ret.first != ret.second){
+ ++n;
+ ret.first = next_node(ret.first);
+ }
+ return n;
+ }
+
+ //! <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 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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ return bounded_range(header, key, key, comp, true, true);
+ }
+
+ //! <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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ return lower_bound_loop(NodeTraits::get_parent(header), detail::uncast(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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ return upper_bound_loop(NodeTraits::get_parent(header), detail::uncast(header), key, comp);
+ }
+
+ //! <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
+ (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data)
+ { return insert_commit(header, new_value, 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.
+ //!
+ //! <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 const_node_ptr & header, const KeyType &key
+ ,KeyNodePtrCompare comp, insert_commit_data &commit_data
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ std::size_t depth = 0;
+ node_ptr h(detail::uncast(header));
+ node_ptr y(h);
+ node_ptr x(NodeTraits::get_parent(y));
+ node_ptr prev = node_ptr();
+
+ //Find the upper bound, cache the previous value and if we should
+ //store it in the left or right node
+ bool left_child = true;
+ while(x){
+ ++depth;
+ y = x;
+ x = (left_child = comp(key, x)) ?
+ NodeTraits::get_left(x) : (prev = y, NodeTraits::get_right(x));
+ }
+
+ if(pdepth) *pdepth = depth;
+
+ //Since we've found the upper bound there is no other value with the same key if:
+ // - There is no previous node
+ // - The previous node is less than the key
+ if(!prev || comp(prev, key)){
+ commit_data.link_left = left_child;
+ commit_data.node = y;
+ return std::pair<node_ptr, bool>(node_ptr(), true);
+ }
+ //If the previous value was not less than key, it means that it's equal
+ //(because we've checked the upper bound)
+ else{
+ return std::pair<node_ptr, bool>(prev, false);
+ }
+ }
+
+ //! <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 const_node_ptr & header, const node_ptr &hint, const KeyType &key
+ ,KeyNodePtrCompare comp, insert_commit_data &commit_data
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ //hint must be bigger than the key
+ if(hint == header || comp(key, hint)){
+ node_ptr prev(hint);
+ //Previous value should be less than the key
+ if(hint == begin_node(header) || comp((prev = prev_node(hint)), key)){
+ commit_data.link_left = unique(header) || !NodeTraits::get_left(hint);
+ commit_data.node = commit_data.link_left ? hint : prev;
+ if(pdepth){
+ *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1;
+ }
+ return std::pair<node_ptr, bool>(node_ptr(), true);
+ }
+ }
+ //Hint was wrong, use hintless insertion
+ return insert_unique_check(header, key, comp, commit_data, pdepth);
+ }
+
+ //! <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
+ (const node_ptr & h, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ insert_commit_data commit_data;
+ insert_equal_check(h, hint, new_node, comp, commit_data, pdepth);
+ insert_commit(h, new_node, commit_data);
+ 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 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
+ (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ insert_commit_data commit_data;
+ insert_equal_upper_bound_check(h, new_node, comp, commit_data, pdepth);
+ insert_commit(h, new_node, commit_data);
+ 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
+ (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ insert_commit_data commit_data;
+ insert_equal_lower_bound_check(h, new_node, comp, commit_data, pdepth);
+ insert_commit(h, new_node, commit_data);
+ return new_node;
+ }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! "pos" must be a valid iterator or header (end) node.
+ //! "pos" must be an iterator pointing to the successor to "new_node"
+ //! once inserted according to the order of already inserted nodes. This function does not
+ //! check "pos" and this precondition must be guaranteed by the caller.
+ //!
+ //! <b>Effects</b>: Inserts new_node into the tree before "pos".
+ //!
+ //! <b>Complexity</b>: Constant-time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: If "pos" is not the successor of the newly inserted "new_node"
+ //! tree invariants might be broken.
+ static node_ptr insert_before
+ (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ insert_commit_data commit_data;
+ insert_before_check(header, pos, commit_data, pdepth);
+ insert_commit(header, new_node, commit_data);
+ return new_node;
+ }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! "new_node" must be, according to the used ordering no less than the
+ //! greatest inserted key.
+ //!
+ //! <b>Effects</b>: Inserts new_node into the tree before "pos".
+ //!
+ //! <b>Complexity</b>: Constant-time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: If "new_node" is less than the greatest inserted key
+ //! tree invariants are broken. This function is slightly faster than
+ //! using "insert_before".
+ static void push_back
+ (const node_ptr & header, const node_ptr & new_node
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ insert_commit_data commit_data;
+ push_back_check(header, commit_data, pdepth);
+ insert_commit(header, new_node, commit_data);
+ }
+
+ //! <b>Requires</b>: "header" must be the header node of a tree.
+ //! "new_node" must be, according to the used ordering, no greater than the
+ //! lowest inserted key.
+ //!
+ //! <b>Effects</b>: Inserts new_node into the tree before "pos".
+ //!
+ //! <b>Complexity</b>: Constant-time.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Note</b>: If "new_node" is greater than the lowest inserted key
+ //! tree invariants are broken. This function is slightly faster than
+ //! using "insert_before".
+ static void push_front
+ (const node_ptr & header, const node_ptr & new_node
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ insert_commit_data commit_data;
+ push_front_check(header, commit_data, pdepth);
+ insert_commit(header, new_node, commit_data);
+ }
+
+ //! <b>Requires</b>: 'node' can't be a header node.
+ //!
+ //! <b>Effects</b>: Calculates the depth of a node: the depth of a
+ //! node is the length (number of edges) of the path from the root
+ //! to that node. (The root node is at depth 0.)
+ //!
+ //! <b>Complexity</b>: Logarithmic to the number of nodes in the tree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static std::size_t depth(const_node_ptr node)
+ {
+ std::size_t depth = 0;
+ node_ptr p_parent;
+ while(node != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(node))){
+ ++depth;
+ node = p_parent;
+ }
+ return depth;
+ }
+
+ //! <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()(const 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()(const node_ptr &)</tt> to obtain
+ //! the nodes of the target tree. If "cloner" throws, the cloned target nodes
+ //! are disposed using <tt>void disposer(const 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 const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer)
+ {
+ if(!unique(target_header)){
+ clear_and_dispose(target_header, disposer);
+ }
+
+ node_ptr leftmost, rightmost;
+ node_ptr new_root = clone_subtree
+ (source_header, target_header, cloner, disposer, leftmost, rightmost);
+
+ //Now update header node
+ NodeTraits::set_parent(target_header, new_root);
+ NodeTraits::set_left (target_header, leftmost);
+ NodeTraits::set_right (target_header, rightmost);
+ }
+
+ //! <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 void erase(const node_ptr & header, const node_ptr & z)
+ {
+ data_for_rebalance ignored;
+ erase_impl(header, z, ignored);
+ }
+
+ //! <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(const 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 must be the header of a tree.
+ //!
+ //! <b>Effects</b>: Rebalances the tree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear.
+ static void rebalance(const node_ptr & header)
+ {
+ node_ptr root = NodeTraits::get_parent(header);
+ if(root){
+ rebalance_subtree(root);
+ }
+ }
+
+ //! <b>Requires</b>: old_root is a node of a tree. It shall not be null.
+ //!
+ //! <b>Effects</b>: Rebalances the subtree rooted at old_root.
+ //!
+ //! <b>Returns</b>: The new root of the subtree.
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Linear.
+ static node_ptr rebalance_subtree(const node_ptr & old_root)
+ {
+ //Taken from:
+ //"Tree rebalancing in optimal time and space"
+ //Quentin F. Stout and Bette L. Warren
+
+ //To avoid irregularities in the algorithm (old_root can be a
+ //left or right child or even the root of the tree) just put the
+ //root as the right child of its parent. Before doing this backup
+ //information to restore the original relationship after
+ //the algorithm is applied.
+ node_ptr super_root = NodeTraits::get_parent(old_root);
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(super_root);
+
+ //Get root info
+ node_ptr super_root_right_backup = NodeTraits::get_right(super_root);
+ bool super_root_is_header = NodeTraits::get_parent(super_root) == old_root;
+ bool old_root_is_right = is_right_child(old_root);
+ NodeTraits::set_right(super_root, old_root);
+
+ std::size_t size;
+ subtree_to_vine(super_root, size);
+ vine_to_subtree(super_root, size);
+ node_ptr new_root = NodeTraits::get_right(super_root);
+
+ //Recover root
+ if(super_root_is_header){
+ NodeTraits::set_right(super_root, super_root_right_backup);
+ NodeTraits::set_parent(super_root, new_root);
+ }
+ else if(old_root_is_right){
+ NodeTraits::set_right(super_root, new_root);
+ }
+ else{
+ NodeTraits::set_right(super_root, super_root_right_backup);
+ NodeTraits::set_left(super_root, new_root);
+ }
+ return new_root;
+ }
+
+ protected:
+ //! <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 subtree_size(const const_node_ptr & subtree)
+ {
+ std::size_t count = 0;
+ if (subtree){
+ node_ptr n = detail::uncast(subtree);
+ node_ptr m = NodeTraits::get_left(n);
+ while(m){
+ n = m;
+ m = NodeTraits::get_left(n);
+ }
+
+ while(1){
+ ++count;
+ node_ptr n_right(NodeTraits::get_right(n));
+ if(n_right){
+ n = n_right;
+ m = NodeTraits::get_left(n);
+ while(m){
+ n = m;
+ m = NodeTraits::get_left(n);
+ }
+ }
+ else {
+ do{
+ if (n == subtree){
+ return count;
+ }
+ m = n;
+ n = NodeTraits::get_parent(n);
+ }while(NodeTraits::get_left(n) != m);
+ }
+ }
+ }
+ return count;
+ }
+
+ //! <b>Requires</b>: p is a node of a tree.
+ //!
+ //! <b>Effects</b>: Returns true if p is a left child.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool is_left_child(const node_ptr & p)
+ { return NodeTraits::get_left(NodeTraits::get_parent(p)) == p; }
+
+ //! <b>Requires</b>: p is a node of a tree.
+ //!
+ //! <b>Effects</b>: Returns true if p is a right child.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Throws</b>: Nothing.
+ static bool is_right_child(const node_ptr & p)
+ { return NodeTraits::get_right(NodeTraits::get_parent(p)) == p; }
+
+ template<class F>
+ static void erase(const node_ptr & header, const node_ptr & z, F z_and_successor_fixup, data_for_rebalance &info)
+ {
+ erase_impl(header, z, info);
+ if(info.y != z){
+ z_and_successor_fixup(z, info.y);
+ }
+ }
+
+ //Fix header and own's parent data when replacing x with own, providing own's old data with parent
+ static void replace_own_impl(const node_ptr & own, const node_ptr & x, const node_ptr & header, const node_ptr & own_parent, bool own_was_left)
+ {
+ if(NodeTraits::get_parent(header) == own)
+ NodeTraits::set_parent(header, x);
+ else if(own_was_left)
+ NodeTraits::set_left(own_parent, x);
+ else
+ NodeTraits::set_right(own_parent, x);
+ }
+
+ //Fix header and own's parent data when replacing x with own, supposing own
+ //links with its parent are still ok
+ static void replace_own(const node_ptr & own, const node_ptr & x, const node_ptr & header)
+ {
+ node_ptr own_parent(NodeTraits::get_parent(own));
+ bool own_is_left(NodeTraits::get_left(own_parent) == own);
+ replace_own_impl(own, x, header, own_parent, own_is_left);
+ }
+
+ // rotate parent p to left (no header and p's parent fixup)
+ static node_ptr rotate_left(const node_ptr & p)
+ {
+ node_ptr x(NodeTraits::get_right(p));
+ node_ptr x_left(NodeTraits::get_left(x));
+ NodeTraits::set_right(p, x_left);
+ if(x_left){
+ NodeTraits::set_parent(x_left, p);
+ }
+ NodeTraits::set_left(x, p);
+ NodeTraits::set_parent(p, x);
+ return x;
+ }
+
+ // rotate parent p to left (with header and p's parent fixup)
+ static void rotate_left(const node_ptr & p, const node_ptr & header)
+ {
+ bool p_was_left(is_left_child(p));
+ node_ptr p_old_parent(NodeTraits::get_parent(p));
+ node_ptr x(rotate_left(p));
+ NodeTraits::set_parent(x, p_old_parent);
+ replace_own_impl(p, x, header, p_old_parent, p_was_left);
+ }
+
+ // rotate parent p to right (no header and p's parent fixup)
+ static node_ptr rotate_right(const node_ptr & p)
+ {
+ node_ptr x(NodeTraits::get_left(p));
+ node_ptr x_right(NodeTraits::get_right(x));
+ NodeTraits::set_left(p, x_right);
+ if(x_right){
+ NodeTraits::set_parent(x_right, p);
+ }
+ NodeTraits::set_right(x, p);
+ NodeTraits::set_parent(p, x);
+ return x;
+ }
+
+ // rotate parent p to right (with header and p's parent fixup)
+ static void rotate_right(const node_ptr & p, const node_ptr & header)
+ {
+ bool p_was_left(is_left_child(p));
+ node_ptr p_old_parent(NodeTraits::get_parent(p));
+ node_ptr x(rotate_right(p));
+ NodeTraits::set_parent(x, p_old_parent);
+ replace_own_impl(p, x, header, p_old_parent, p_was_left);
+ }
+
+ static void insert_before_check
+ (const node_ptr &header, const node_ptr & pos
+ , insert_commit_data &commit_data
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ node_ptr prev(pos);
+ if(pos != NodeTraits::get_left(header))
+ prev = prev_node(pos);
+ bool link_left = unique(header) || !NodeTraits::get_left(pos);
+ commit_data.link_left = link_left;
+ commit_data.node = link_left ? pos : prev;
+ if(pdepth){
+ *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1;
+ }
+ }
+
+ static void push_back_check
+ (const node_ptr & header, insert_commit_data &commit_data
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ node_ptr prev(NodeTraits::get_right(header));
+ if(pdepth){
+ *pdepth = prev == header ? 0 : depth(prev) + 1;
+ }
+ commit_data.link_left = false;
+ commit_data.node = prev;
+ }
+
+ static void push_front_check
+ (const node_ptr & header, insert_commit_data &commit_data
+ #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ , std::size_t *pdepth = 0
+ #endif
+ )
+ {
+ node_ptr pos(NodeTraits::get_left(header));
+ if(pdepth){
+ *pdepth = pos == header ? 0 : depth(pos) + 1;
+ }
+ commit_data.link_left = true;
+ commit_data.node = pos;
+ }
+
+ template<class NodePtrCompare>
+ static void insert_equal_check
+ (const node_ptr &header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp
+ , insert_commit_data &commit_data
+ /// @cond
+ , std::size_t *pdepth = 0
+ /// @endcond
+ )
+ {
+ if(hint == header || !comp(hint, new_node)){
+ node_ptr prev(hint);
+ if(hint == NodeTraits::get_left(header) ||
+ !comp(new_node, (prev = prev_node(hint)))){
+ bool link_left = unique(header) || !NodeTraits::get_left(hint);
+ commit_data.link_left = link_left;
+ commit_data.node = link_left ? hint : prev;
+ if(pdepth){
+ *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1;
+ }
+ }
+ else{
+ insert_equal_upper_bound_check(header, new_node, comp, commit_data, pdepth);
+ }
+ }
+ else{
+ insert_equal_lower_bound_check(header, new_node, comp, commit_data, pdepth);
+ }
+ }
+
+ template<class NodePtrCompare>
+ static void insert_equal_upper_bound_check
+ (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0)
+ { insert_equal_check_impl(true, h, new_node, comp, commit_data, pdepth); }
+
+ template<class NodePtrCompare>
+ static void insert_equal_lower_bound_check
+ (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0)
+ { insert_equal_check_impl(false, h, new_node, comp, commit_data, pdepth); }
+
+ static void insert_commit
+ (const node_ptr & header, const node_ptr & new_node, const insert_commit_data &commit_data)
+ {
+ //Check if commit_data has not been initialized by a insert_unique_check call.
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != node_ptr());
+ node_ptr parent_node(commit_data.node);
+ if(parent_node == header){
+ NodeTraits::set_parent(header, new_node);
+ NodeTraits::set_right(header, new_node);
+ NodeTraits::set_left(header, new_node);
+ }
+ else if(commit_data.link_left){
+ NodeTraits::set_left(parent_node, new_node);
+ if(parent_node == NodeTraits::get_left(header))
+ NodeTraits::set_left(header, new_node);
+ }
+ else{
+ NodeTraits::set_right(parent_node, new_node);
+ if(parent_node == NodeTraits::get_right(header))
+ NodeTraits::set_right(header, new_node);
+ }
+ NodeTraits::set_parent(new_node, parent_node);
+ NodeTraits::set_right(new_node, node_ptr());
+ NodeTraits::set_left(new_node, node_ptr());
+ }
+
+ private:
+ static void subtree_to_vine(node_ptr vine_tail, std::size_t &size)
+ {
+ //Inspired by LibAVL:
+ //It uses a clever optimization for trees with parent pointers.
+ //No parent pointer is updated when transforming a tree to a vine as
+ //most of them will be overriten during compression rotations.
+ //A final pass must be made after the rebalancing to updated those
+ //pointers not updated by tree_to_vine + compression calls
+ std::size_t len = 0;
+ node_ptr remainder = NodeTraits::get_right(vine_tail);
+ while(remainder){
+ node_ptr tempptr = NodeTraits::get_left(remainder);
+ if(!tempptr){ //move vine-tail down one
+ vine_tail = remainder;
+ remainder = NodeTraits::get_right(remainder);
+ ++len;
+ }
+ else{ //rotate
+ NodeTraits::set_left(remainder, NodeTraits::get_right(tempptr));
+ NodeTraits::set_right(tempptr, remainder);
+ remainder = tempptr;
+ NodeTraits::set_right(vine_tail, tempptr);
+ }
+ }
+ size = len;
+ }
+
+ static void compress_subtree(node_ptr scanner, std::size_t count)
+ {
+ while(count--){ //compress "count" spine nodes in the tree with pseudo-root scanner
+ node_ptr child = NodeTraits::get_right(scanner);
+ node_ptr child_right = NodeTraits::get_right(child);
+ NodeTraits::set_right(scanner, child_right);
+ //Avoid setting the parent of child_right
+ scanner = child_right;
+ node_ptr scanner_left = NodeTraits::get_left(scanner);
+ NodeTraits::set_right(child, scanner_left);
+ if(scanner_left)
+ NodeTraits::set_parent(scanner_left, child);
+ NodeTraits::set_left(scanner, child);
+ NodeTraits::set_parent(child, scanner);
+ }
+ }
+
+ static void vine_to_subtree(const node_ptr & super_root, std::size_t count)
+ {
+ std::size_t leaf_nodes = count + 1 - ((std::size_t) 1 << detail::floor_log2(count + 1));
+ compress_subtree(super_root, leaf_nodes); //create deepest leaves
+ std::size_t vine_nodes = count - leaf_nodes;
+ while(vine_nodes > 1){
+ vine_nodes /= 2;
+ compress_subtree(super_root, vine_nodes);
+ }
+
+ //Update parents of nodes still in the in the original vine line
+ //as those have not been updated by subtree_to_vine or compress_subtree
+ for ( node_ptr q = super_root, p = NodeTraits::get_right(super_root)
+ ; p
+ ; q = p, p = NodeTraits::get_right(p)){
+ NodeTraits::set_parent(p, q);
+ }
+ }
+
+ //! <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_root(const node_ptr & node)
+ {
+ BOOST_INTRUSIVE_INVARIANT_ASSERT((!inited(node)));
+ node_ptr x = NodeTraits::get_parent(node);
+ if(x){
+ while(!is_header(x)){
+ x = NodeTraits::get_parent(x);
+ }
+ return x;
+ }
+ else{
+ return node;
+ }
+ }
+
+ template <class Cloner, class Disposer>
+ static node_ptr clone_subtree
+ (const const_node_ptr &source_parent, const node_ptr &target_parent
+ , Cloner cloner, Disposer disposer
+ , node_ptr &leftmost_out, node_ptr &rightmost_out
+ )
+ {
+ node_ptr target_sub_root = target_parent;
+ node_ptr source_root = NodeTraits::get_parent(source_parent);
+ if(!source_root){
+ leftmost_out = rightmost_out = source_root;
+ }
+ else{
+ //We'll calculate leftmost and rightmost nodes while iterating
+ node_ptr current = source_root;
+ node_ptr insertion_point = target_sub_root = cloner(current);
+
+ //We'll calculate leftmost and rightmost nodes while iterating
+ node_ptr leftmost = target_sub_root;
+ node_ptr rightmost = target_sub_root;
+
+ //First set the subroot
+ NodeTraits::set_left(target_sub_root, node_ptr());
+ NodeTraits::set_right(target_sub_root, node_ptr());
+ NodeTraits::set_parent(target_sub_root, target_parent);
+
+ dispose_subtree_disposer<Disposer> rollback(disposer, target_sub_root);
+ while(true) {
+ //First clone left nodes
+ if( NodeTraits::get_left(current) &&
+ !NodeTraits::get_left(insertion_point)) {
+ current = NodeTraits::get_left(current);
+ node_ptr temp = insertion_point;
+ //Clone and mark as leaf
+ insertion_point = cloner(current);
+ NodeTraits::set_left (insertion_point, node_ptr());
+ NodeTraits::set_right (insertion_point, node_ptr());
+ //Insert left
+ NodeTraits::set_parent(insertion_point, temp);
+ NodeTraits::set_left (temp, insertion_point);
+ //Update leftmost
+ if(rightmost == target_sub_root)
+ leftmost = insertion_point;
+ }
+ //Then clone right nodes
+ else if( NodeTraits::get_right(current) &&
+ !NodeTraits::get_right(insertion_point)){
+ current = NodeTraits::get_right(current);
+ node_ptr temp = insertion_point;
+ //Clone and mark as leaf
+ insertion_point = cloner(current);
+ NodeTraits::set_left (insertion_point, node_ptr());
+ NodeTraits::set_right (insertion_point, node_ptr());
+ //Insert right
+ NodeTraits::set_parent(insertion_point, temp);
+ NodeTraits::set_right (temp, insertion_point);
+ //Update rightmost
+ rightmost = insertion_point;
+ }
+ //If not, go up
+ else if(current == source_root){
+ break;
+ }
+ else{
+ //Branch completed, go up searching more nodes to clone
+ current = NodeTraits::get_parent(current);
+ insertion_point = NodeTraits::get_parent(insertion_point);
+ }
+ }
+ rollback.release();
+ leftmost_out = leftmost;
+ rightmost_out = rightmost;
+ }
+ return target_sub_root;
+ }
+
+ template<class Disposer>
+ static void dispose_subtree(node_ptr x, Disposer disposer)
+ {
+ while (x){
+ node_ptr save(NodeTraits::get_left(x));
+ if (save) {
+ // Right rotation
+ NodeTraits::set_left(x, NodeTraits::get_right(save));
+ NodeTraits::set_right(save, x);
+ }
+ else {
+ save = NodeTraits::get_right(x);
+ init(x);
+ disposer(x);
+ }
+ x = save;
+ }
+ }
+
+ template<class KeyType, class KeyNodePtrCompare>
+ static node_ptr lower_bound_loop
+ (node_ptr x, node_ptr y, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ while(x){
+ if(comp(x, key)){
+ x = NodeTraits::get_right(x);
+ }
+ else{
+ y = x;
+ x = NodeTraits::get_left(x);
+ }
+ }
+ return y;
+ }
+
+ template<class KeyType, class KeyNodePtrCompare>
+ static node_ptr upper_bound_loop
+ (node_ptr x, node_ptr y, const KeyType &key, KeyNodePtrCompare comp)
+ {
+ while(x){
+ if(comp(key, x)){
+ y = x;
+ x = NodeTraits::get_left(x);
+ }
+ else{
+ x = NodeTraits::get_right(x);
+ }
+ }
+ return y;
+ }
+
+
+ template<class NodePtrCompare>
+ static void insert_equal_check_impl
+ (bool upper, const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0)
+ {
+ std::size_t depth = 0;
+ node_ptr y(h);
+ node_ptr x(NodeTraits::get_parent(y));
+ bool link_left;
+
+ if(upper){
+ while(x){
+ ++depth;
+ y = x;
+ x = comp(new_node, x) ?
+ NodeTraits::get_left(x) : NodeTraits::get_right(x);
+ }
+ link_left = (y == h) || comp(new_node, y);
+ }
+ else{
+ while(x){
+ ++depth;
+ y = x;
+ x = !comp(x, new_node) ?
+ NodeTraits::get_left(x) : NodeTraits::get_right(x);
+ }
+ link_left = (y == h) || !comp(y, new_node);
+ }
+
+ commit_data.link_left = link_left;
+ commit_data.node = y;
+ if(pdepth) *pdepth = depth;
+ }
+
+ static void erase_impl(const node_ptr & header, const node_ptr & z, data_for_rebalance &info)
+ {
+ node_ptr y(z);
+ node_ptr x;
+ node_ptr x_parent = node_ptr();
+ node_ptr z_left(NodeTraits::get_left(z));
+ node_ptr z_right(NodeTraits::get_right(z));
+ if(!z_left){
+ x = z_right; // x might be null.
+ }
+ else if(!z_right){ // z has exactly one non-null child. y == z.
+ x = z_left; // x is not null.
+ }
+ else{
+ // find z's successor
+ y = bstree_algorithms::minimum (z_right);
+ x = NodeTraits::get_right(y); // x might be null.
+ }
+
+ if(y != z){
+ // relink y in place of z. y is z's successor
+ NodeTraits::set_parent(NodeTraits::get_left(z), y);
+ NodeTraits::set_left(y, NodeTraits::get_left(z));
+ if(y != NodeTraits::get_right(z)){
+ x_parent = NodeTraits::get_parent(y);
+ if(x)
+ NodeTraits::set_parent(x, x_parent);
+ NodeTraits::set_left(x_parent, x); // y must be a child of left_
+ NodeTraits::set_right(y, NodeTraits::get_right(z));
+ NodeTraits::set_parent(NodeTraits::get_right(z), y);
+ }
+ else
+ x_parent = y;
+ bstree_algorithms::replace_own (z, y, header);
+ NodeTraits::set_parent(y, NodeTraits::get_parent(z));
+ }
+ else { // y == z --> z has only one child, or void
+ x_parent = NodeTraits::get_parent(z);
+ if(x)
+ NodeTraits::set_parent(x, x_parent);
+ bstree_algorithms::replace_own (z, x, header);
+ if(NodeTraits::get_left(header) == z){
+ NodeTraits::set_left(header, !NodeTraits::get_right(z) ? // z->get_left() must be null also
+ NodeTraits::get_parent(z) : // makes leftmost == header if z == root
+ bstree_algorithms::minimum (x));
+ }
+ if(NodeTraits::get_right(header) == z){
+ NodeTraits::set_right(header, !NodeTraits::get_left(z) ? // z->get_right() must be null also
+ NodeTraits::get_parent(z) : // makes rightmost == header if z == root
+ bstree_algorithms::maximum(x));
+ }
+ }
+
+ info.x = x;
+ info.x_parent = x_parent;
+ info.y = y;
+ }
+};
+
+/// @cond
+
+template<class NodeTraits>
+struct get_algo<BsTreeAlgorithms, NodeTraits>
+{
+ typedef bstree_algorithms<NodeTraits> type;
+};
+
+/// @endcond
+
+} //namespace intrusive
+} //namespace boost
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //BOOST_INTRUSIVE_BSTREE_ALGORITHMS_HPP

Modified: branches/release/boost/intrusive/circular_list_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/circular_list_algorithms.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/circular_list_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -16,6 +16,7 @@
 
 #include <boost/intrusive/detail/config_begin.hpp>
 #include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
 #include <cstddef>
 
 namespace boost {
@@ -405,6 +406,16 @@
    }
 };
 
+/// @cond
+
+template<class NodeTraits>
+struct get_algo<CircularListAlgorithms, NodeTraits>
+{
+ typedef circular_list_algorithms<NodeTraits> type;
+};
+
+/// @endcond
+
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/circular_slist_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/circular_slist_algorithms.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/circular_slist_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -18,6 +18,7 @@
 #include <boost/intrusive/intrusive_fwd.hpp>
 #include <boost/intrusive/detail/common_slist_algorithms.hpp>
 #include <boost/intrusive/detail/assert.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
 #include <cstddef>
 
 namespace boost {
@@ -396,6 +397,16 @@
    }
 };
 
+/// @cond
+
+template<class NodeTraits>
+struct get_algo<CircularSListAlgorithms, NodeTraits>
+{
+ typedef circular_slist_algorithms<NodeTraits> type;
+};
+
+/// @endcond
+
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/derivation_value_traits.hpp
==============================================================================
--- branches/release/boost/intrusive/derivation_value_traits.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/derivation_value_traits.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/assert.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/assert.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/assert.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/avltree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/avltree_node.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/avltree_node.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/clear_on_destructor_base.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/clear_on_destructor_base.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/clear_on_destructor_base.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 //////} // ///////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2013. 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)
 //
@@ -17,7 +17,7 @@
 namespace intrusive {
 namespace detail {
 
-template<class Derived>
+template<class Derived, bool DoClear = true>
 class clear_on_destructor_base
 {
    protected:
@@ -27,6 +27,10 @@
    }
 };
 
+template<class Derived>
+class clear_on_destructor_base<Derived, false>
+{};
+
 } // namespace detail {
 } // namespace intrusive {
 } // namespace boost {

Modified: branches/release/boost/intrusive/detail/common_slist_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/common_slist_algorithms.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/common_slist_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/config_begin.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/config_begin.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/config_begin.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/config_end.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/config_end.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/config_end.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/ebo_functor_holder.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/ebo_functor_holder.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/ebo_functor_holder.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Joaquin M Lopez Munoz 2006-2012
+// (C) Copyright Joaquin M Lopez Munoz 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/function_detector.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/function_detector.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/function_detector.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2012.
+// (C) Copyright Ion Gaztanaga 2009-2013.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/generic_hook.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/generic_hook.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/generic_hook.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -24,85 +24,71 @@
 
 namespace boost {
 namespace intrusive {
-namespace detail {
 
 /// @cond
 
-enum
-{ NoBaseHook
-, ListBaseHook
-, SlistBaseHook
-, SetBaseHook
-, UsetBaseHook
-, SplaySetBaseHook
-, AvlSetBaseHook
-, BsSetBaseHook
-, AnyBaseHook
+enum base_hook_type
+{ NoBaseHookId
+, ListBaseHookId
+, SlistBaseHookId
+, RbTreeBaseHookId
+, HashBaseHookId
+, SplayTreeBaseHookId
+, AvlTreeBaseHookId
+, BsTreeBaseHookId
+, AnyBaseHookId
 };
 
-struct no_default_definer{};
 
-template <class Hook, unsigned int>
-struct default_definer;
+template <class HookTags, unsigned int>
+struct hook_tags_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 HookTags>
+struct hook_tags_definer<HookTags, ListBaseHookId>
+{ typedef HookTags default_list_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, SlistBaseHookId>
+{ typedef HookTags default_slist_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, RbTreeBaseHookId>
+{ typedef HookTags default_rbtree_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, HashBaseHookId>
+{ typedef HookTags default_hashtable_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, SplayTreeBaseHookId>
+{ typedef HookTags default_splaytree_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, AvlTreeBaseHookId>
+{ typedef HookTags default_avltree_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, BsTreeBaseHookId>
+{ typedef HookTags default_bstree_hook; };
+
+template <class HookTags>
+struct hook_tags_definer<HookTags, AnyBaseHookId>
+{ typedef HookTags default_any_hook; };
 
 template
- < class GetNodeAlgorithms
+ < class NodeTraits
    , class Tag
    , link_mode_type LinkMode
- , int HookType
+ , base_hook_type BaseHookType
>
-struct make_node_holder
+struct hooktags_impl
 {
- 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;
+ static const link_mode_type link_mode = LinkMode;
+ typedef Tag tag;
+ typedef NodeTraits node_traits;
+ static const bool is_base_hook = !detail::is_same<Tag, member_tag>::value;
+ static const bool safemode_or_autounlink = is_safe_autounlink<link_mode>::value;
+ static const unsigned int type = BaseHookType;
 };
 
 /// @endcond
@@ -111,22 +97,28 @@
    < class GetNodeAlgorithms
    , class Tag
    , link_mode_type LinkMode
- , int HookType
+ , base_hook_type BaseHookType
>
 class generic_hook
    /// @cond
-
- //If the hook is a base hook, derive generic hook from detail::node_holder
+ //If the hook is a base hook, derive generic hook from 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.
+ //to the type. This mechanism will be used by bhtraits.
    //
    //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
+ : public detail::if_c
+ < detail::is_same<Tag, member_tag>::value
+ , typename GetNodeAlgorithms::type::node
+ , node_holder<typename GetNodeAlgorithms::type::node, Tag, BaseHookType>
>::type
- , public make_node_holder<GetNodeAlgorithms, Tag, LinkMode, HookType>::type
+ //If this is the a default-tagged base hook derive from a class that
+ //will define an special internal typedef. Containers will be able to detect this
+ //special typedef and obtain generic_hook's internal types in order to deduce
+ //value_traits for this hook.
+ , public hook_tags_definer
+ < generic_hook<GetNodeAlgorithms, Tag, LinkMode, BaseHookType>
+ , detail::is_same<Tag, default_tag>::value*BaseHookType>
    /// @endcond
 {
    /// @cond
@@ -136,16 +128,10 @@
    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;
- };
+
+ typedef hooktags_impl
+ < typename GetNodeAlgorithms::type::node_traits
+ , Tag, LinkMode, BaseHookType> hooktags;
 
    node_ptr this_ptr()
    { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*this)); }
@@ -158,14 +144,14 @@
 
    generic_hook()
    {
- if(boost_intrusive_tags::safemode_or_autounlink){
+ if(hooktags::safemode_or_autounlink){
          node_algorithms::init(this->this_ptr());
       }
    }
 
    generic_hook(const generic_hook& )
    {
- if(boost_intrusive_tags::safemode_or_autounlink){
+ if(hooktags::safemode_or_autounlink){
          node_algorithms::init(this->this_ptr());
       }
    }
@@ -176,7 +162,7 @@
    ~generic_hook()
    {
       destructor_impl
- (*this, detail::link_dispatch<boost_intrusive_tags::link_mode>());
+ (*this, detail::link_dispatch<hooktags::link_mode>());
    }
 
    void swap_nodes(generic_hook &other)
@@ -188,19 +174,18 @@
    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 ));
+ BOOST_STATIC_ASSERT(( hooktags::safemode_or_autounlink ));
       return !node_algorithms::unique(this->this_ptr());
    }
 
    void unlink()
    {
- BOOST_STATIC_ASSERT(( (int)boost_intrusive_tags::link_mode == (int)auto_unlink ));
+ BOOST_STATIC_ASSERT(( (int)hooktags::link_mode == (int)auto_unlink ));
       node_algorithms::unlink(this->this_ptr());
       node_algorithms::init(this->this_ptr());
    }
 };
 
-} //namespace detail
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/detail/has_member_function_callable_with.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/has_member_function_callable_with.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/has_member_function_callable_with.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-2013. 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)
 //

Modified: branches/release/boost/intrusive/detail/hashtable_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/hashtable_node.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/hashtable_node.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,11 +20,13 @@
 #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 <boost/intrusive/slist.hpp> //remove-me
 #include <boost/intrusive/pointer_traits.hpp>
+#include <boost/intrusive/trivial_value_traits.hpp>
 #include <cstddef>
+#include <boost/type_traits/make_unsigned.hpp>
 #include <boost/pointer_cast.hpp>
-#include <boost/move/move.hpp>
+#include <boost/move/core.hpp>
 
 
 namespace boost {
@@ -89,6 +91,7 @@
    typedef typename pointer_traits
       <typename Slist::pointer>::template rebind_pointer
          < bucket_impl<Slist> >::type bucket_ptr;
+ typedef Slist slist;
    typedef typename Slist::size_type size_type;
    /// @endcond
 
@@ -100,7 +103,6 @@
       : buckets_(x.buckets_), buckets_len_(x.buckets_len_)
    {}
 
-
    bucket_traits_impl(BOOST_RV_REF(bucket_traits_impl) x)
       : buckets_(x.buckets_), buckets_len_(x.buckets_len_)
    { x.buckets_ = bucket_ptr(); x.buckets_len_ = 0; }
@@ -127,57 +129,104 @@
    size_type buckets_len_;
 };
 
-template<class Container, bool IsConst>
+template <class NodeTraits>
+struct hash_reduced_slist_node_traits
+{
+ template <class U> static detail::one test(...);
+ template <class U> static detail::two test(typename U::reduced_slist_node_traits* = 0);
+ static const bool value = sizeof(test<NodeTraits>(0)) == sizeof(detail::two);
+};
+
+template <class NodeTraits>
+struct apply_reduced_slist_node_traits
+{
+ typedef typename NodeTraits::reduced_slist_node_traits type;
+};
+
+template <class NodeTraits>
+struct reduced_slist_node_traits
+{
+ typedef typename detail::eval_if_c
+ < hash_reduced_slist_node_traits<NodeTraits>::value
+ , apply_reduced_slist_node_traits<NodeTraits>
+ , detail::identity<NodeTraits>
+ >::type type;
+};
+
+template<class NodeTraits>
+struct get_slist_impl
+{
+ typedef trivial_value_traits<NodeTraits, normal_link> trivial_traits;
+
+ //Reducing symbol length
+ struct type : make_slist
+ < typename NodeTraits::node
+ , boost::intrusive::value_traits<trivial_traits>
+ , boost::intrusive::constant_time_size<false>
+ , boost::intrusive::size_type<typename boost::make_unsigned
+ <typename pointer_traits<typename NodeTraits::node_ptr>::difference_type>::type >
+ >::type
+ {};
+};
+
+} //namespace detail {
+
+template<class BucketValueTraits, bool IsConst>
 class hashtable_iterator
    : public std::iterator
          < std::forward_iterator_tag
- , typename Container::value_type
- , typename pointer_traits<typename Container::value_type*>::difference_type
+ , typename BucketValueTraits::real_value_traits::value_type
+ , typename pointer_traits<typename BucketValueTraits::real_value_traits::value_type*>::difference_type
          , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *
+ <typename BucketValueTraits::real_value_traits::value_type, IsConst>::type *
          , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &
+ <typename BucketValueTraits::real_value_traits::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 BucketValueTraits::real_value_traits real_value_traits;
+ typedef typename BucketValueTraits::real_bucket_traits real_bucket_traits;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename detail::get_slist_impl
+ <typename detail::reduced_slist_node_traits
+ <typename real_value_traits::node_traits>::type
+ >::type slist_impl;
+ typedef typename slist_impl::iterator siterator;
+ typedef typename slist_impl::const_iterator const_siterator;
+ typedef detail::bucket_impl<slist_impl> bucket_type;
 
    typedef typename pointer_traits
- <typename Container::pointer>::template rebind_pointer
- < const Container >::type const_cont_ptr;
- typedef typename Container::size_type size_type;
+ <typename real_value_traits::pointer>::template rebind_pointer
+ < const BucketValueTraits >::type const_bucketvaltraits_ptr;
+ typedef typename slist_impl::size_type size_type;
 
- static typename Container::node_ptr downcast_bucket(typename bucket_type::node_ptr p)
+
+ static typename node_traits::node_ptr downcast_bucket(typename bucket_type::node_ptr p)
    {
- return pointer_traits<typename Container::node_ptr>::
- pointer_to(static_cast<typename Container::node&>(*p));
+ return pointer_traits<typename node_traits::node_ptr>::
+ pointer_to(static_cast<typename node_traits::node&>(*p));
    }
 
    public:
- typedef typename Container::value_type value_type;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *pointer;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &reference;
+ typedef typename real_value_traits::value_type value_type;
+ typedef typename detail::add_const_if_c<value_type, IsConst>::type *pointer;
+ typedef typename detail::add_const_if_c<value_type, IsConst>::type &reference;
 
    hashtable_iterator ()
    {}
 
- explicit hashtable_iterator(siterator ptr, const Container *cont)
- : slist_it_ (ptr), cont_ (cont ? pointer_traits<const_cont_ptr>::pointer_to(*cont) : const_cont_ptr() )
+ explicit hashtable_iterator(siterator ptr, const BucketValueTraits *cont)
+ : slist_it_ (ptr), traitsptr_ (cont ? pointer_traits<const_bucketvaltraits_ptr>::pointer_to(*cont) : const_bucketvaltraits_ptr() )
    {}
 
- hashtable_iterator(const hashtable_iterator<Container, false> &other)
- : slist_it_(other.slist_it()), cont_(other.get_container())
+ hashtable_iterator(const hashtable_iterator<BucketValueTraits, false> &other)
+ : slist_it_(other.slist_it()), traitsptr_(other.get_bucket_value_traits())
    {}
 
    const siterator &slist_it() const
    { return slist_it_; }
 
- hashtable_iterator<Container, false> unconst() const
- { return hashtable_iterator<Container, false>(this->slist_it(), this->get_container()); }
+ hashtable_iterator<BucketValueTraits, false> unconst() const
+ { return hashtable_iterator<BucketValueTraits, false>(this->slist_it(), this->get_bucket_value_traits()); }
 
    public:
    hashtable_iterator& operator++()
@@ -201,48 +250,57 @@
 
    pointer operator->() const
    {
- return boost::intrusive::detail::to_raw_pointer(this->get_real_value_traits()->to_value_ptr
+ return boost::intrusive::detail::to_raw_pointer(this->priv_real_value_traits().to_value_ptr
          (downcast_bucket(slist_it_.pointed_node())));
    }
 
- const const_cont_ptr &get_container() const
- { return cont_; }
+ const const_bucketvaltraits_ptr &get_bucket_value_traits() const
+ { return traitsptr_; }
+
+ const real_value_traits &priv_real_value_traits() const
+ { return traitsptr_->priv_real_value_traits(); }
 
- const real_value_traits *get_real_value_traits() const
- { return &this->get_container()->get_real_value_traits(); }
+ const real_bucket_traits &priv_real_bucket_traits() const
+ { return traitsptr_->priv_real_bucket_traits(); }
 
    private:
    void increment()
    {
- const Container *cont = boost::intrusive::detail::to_raw_pointer(cont_);
- bucket_type* buckets = boost::intrusive::detail::to_raw_pointer(cont->bucket_pointer());
- size_type buckets_len = cont->bucket_count();
+ const real_bucket_traits &rbuck_traits = this->priv_real_bucket_traits();
+ bucket_type* const buckets = boost::intrusive::detail::to_raw_pointer(rbuck_traits.bucket_begin());
+ const size_type buckets_len = rbuck_traits.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 typename slist_impl::node_ptr n = slist_it_.pointed_node();
+ const siterator first_bucket_bbegin = buckets->end();
+ if(first_bucket_bbegin.pointed_node() <= n && n <= buckets[buckets_len-1].cend().pointed_node()){
+ //If one-past the node is inside the bucket then look for the next non-empty bucket
+ //1. 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]);
+ //2. Now just calculate the index b has in the bucket array
+ size_type n_bucket = static_cast<size_type>(&b - buckets);
+
+ //3. Iterate until a non-empty bucket is found
          do{
- if (++n_bucket == buckets_len){
- slist_it_ = (&buckets[0] + buckets_len)->end();
- break;
+ if (++n_bucket >= buckets_len){ //bucket overflow, return end() iterator
+ slist_it_ = buckets->before_begin();
+ return;
             }
- slist_it_ = buckets[n_bucket].begin();
          }
- while (slist_it_ == buckets[n_bucket].end());
+ while (buckets[n_bucket].empty());
+ slist_it_ = buckets[n_bucket].begin();
+ }
+ else{
+ //++slist_it_ yield to a valid object
       }
    }
 
- siterator slist_it_;
- const_cont_ptr cont_;
+ siterator slist_it_;
+ const_bucketvaltraits_ptr traitsptr_;
 };
 
-} //namespace detail {
 } //namespace intrusive {
 } //namespace boost {
 

Modified: branches/release/boost/intrusive/detail/is_stateful_value_traits.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/is_stateful_value_traits.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/is_stateful_value_traits.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2009-2012.
+// (C) Copyright Ion Gaztanaga 2009-2013.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/detail/list_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/list_node.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/list_node.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -65,41 +65,41 @@
 
 // list_iterator provides some basic functions for a
 // node oriented bidirectional iterator:
-template<class Container, bool IsConst>
+template<class RealValueTraits, bool IsConst>
 class list_iterator
- : public std::iterator
- < std::bidirectional_iterator_tag
- , typename Container::value_type
- , typename Container::difference_type
- , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
- , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
- >
+ : public iiterator<RealValueTraits, IsConst, std::bidirectional_iterator_tag>::iterator_base
 {
    protected:
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename real_value_traits::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<void>::type void_pointer;
- static const bool store_container_ptr =
- detail::store_cont_ptr_on_it<Container>::value;
+ typedef iiterator
+ <RealValueTraits, IsConst, std::bidirectional_iterator_tag> types_t;
+
+ static const bool stateful_value_traits = types_t::stateful_value_traits;
+
+ typedef RealValueTraits real_value_traits;
+ typedef typename types_t::node_traits node_traits;
+
+ typedef typename types_t::node node;
+ typedef typename types_t::node_ptr node_ptr;
+ typedef typename types_t::void_pointer void_pointer;
 
    public:
- typedef typename Container::value_type value_type;
- typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
- typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;
+ typedef typename types_t::value_type value_type;
+ typedef typename types_t::pointer pointer;
+ typedef typename types_t::reference reference;
+
+ typedef typename pointer_traits
+ <void_pointer>::template rebind_pointer
+ <const real_value_traits>::type const_real_value_traits_ptr;
 
    list_iterator()
- : members_ (node_ptr(), 0)
    {}
 
- explicit list_iterator(const node_ptr & node, const Container *cont_ptr)
- : members_ (node, cont_ptr)
+ explicit list_iterator(const node_ptr & nodeptr, const const_real_value_traits_ptr &traits_ptr)
+ : members_(nodeptr, traits_ptr)
    {}
 
- list_iterator(list_iterator<Container, false> const& other)
- : members_(other.pointed_node(), other.get_container())
+ list_iterator(list_iterator<RealValueTraits, false> const& other)
+ : members_(other.pointed_node(), other.get_real_value_traits())
    {}
 
    const node_ptr &pointed_node() const
@@ -108,12 +108,14 @@
    list_iterator &operator=(const node_ptr &node)
    { members_.nodeptr_ = node; return static_cast<list_iterator&>(*this); }
 
+ const_real_value_traits_ptr get_real_value_traits() const
+ { return pointer_traits<const_real_value_traits_ptr>::static_cast_from(members_.get_ptr()); }
+
    public:
    list_iterator& operator++()
    {
       node_ptr p = node_traits::get_next(members_.nodeptr_);
       members_.nodeptr_ = p;
- //members_.nodeptr_ = node_traits::get_next(members_.nodeptr_);
       return static_cast<list_iterator&> (*this);
    }
 
@@ -149,43 +151,11 @@
    pointer operator->() const
    { return this->get_real_value_traits()->to_value_ptr(members_.nodeptr_); }
 
- const Container *get_container() const
- {
- if(store_container_ptr){
- const Container* c = static_cast<const Container*>(members_.get_ptr());
- BOOST_INTRUSIVE_INVARIANT_ASSERT(c != 0);
- return c;
- }
- else{
- return 0;
- }
- }
-
- const real_value_traits *get_real_value_traits() const
- {
- if(store_container_ptr)
- return &this->get_container()->get_real_value_traits();
- else
- return 0;
- }
-
- list_iterator<Container, false> unconst() const
- { return list_iterator<Container, false>(this->pointed_node(), this->get_container()); }
+ list_iterator<RealValueTraits, false> unconst() const
+ { return list_iterator<RealValueTraits, false>(this->pointed_node(), this->get_real_value_traits()); }
 
    private:
- struct members
- : public detail::select_constptr
- <void_pointer, store_container_ptr>::type
- {
- typedef typename detail::select_constptr
- <void_pointer, store_container_ptr>::type Base;
-
- members(const node_ptr &n_ptr, const void *cont)
- : Base(cont), nodeptr_(n_ptr)
- {}
-
- node_ptr nodeptr_;
- } members_;
+ iiterator_members<node_ptr, stateful_value_traits> members_;
 };
 
 } //namespace intrusive

Modified: branches/release/boost/intrusive/detail/memory_util.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/memory_util.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/memory_util.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -6,7 +6,7 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-2013. 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)
 //
@@ -45,6 +45,10 @@
 template <> struct unvoid<void> { struct type { }; };
 template <> struct unvoid<const void> { struct type { }; };
 
+template <typename T> struct unvoid_ref { typedef T &type; };
+template <> struct unvoid_ref<void> { struct type_impl { }; typedef type_impl & type; };
+template <> struct unvoid_ref<const void> { struct type_impl { }; typedef type_impl & type; };
+
 template <typename T>
 struct LowPriorityConversion
 {

Modified: branches/release/boost/intrusive/detail/mpl.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/mpl.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/mpl.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -283,20 +283,13 @@
 template <typename T, typename U>
 struct is_same
 {
- typedef char yes_type;
- struct no_type
- {
- char padding[8];
- };
-
- template <typename V>
- static yes_type is_same_tester(V*, V*);
- static no_type is_same_tester(...);
-
- static T *t;
- static U *u;
+ static const bool value = false;
+};
 
- static const bool value = sizeof(yes_type) == sizeof(is_same_tester(t,u));
+template <typename T>
+struct is_same<T, T>
+{
+ static const bool value = true;
 };
 
 template<typename T>

Modified: branches/release/boost/intrusive/detail/parent_from_member.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/parent_from_member.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/parent_from_member.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -30,18 +30,38 @@
 {
    //The implementation of a pointer to member is compiler dependent.
    #if defined(BOOST_INTRUSIVE_MSVC_ABI_PTR_TO_MEMBER)
- //msvc compliant compilers use their the first 32 bits as offset (even in 64 bit mode)
+
+ //MSVC compliant compilers use their the first 32 bits as offset (even in 64 bit mode)
    union caster_union
    {
       const Member Parent::* ptr_to_member;
       boost::int32_t offset;
    } caster;
- caster.ptr_to_member = ptr_to_member;
+
    //MSVC ABI can use up to 3 int32 to represent pointer to member data
    //with virtual base classes, in those cases there is no simple to
- //obtain the address of parent. So static assert to avoid runtime errors
+ //obtain the address of the parent. So static assert to avoid runtime errors
    BOOST_STATIC_ASSERT( sizeof(caster) == sizeof(boost::int32_t) );
+
+ caster.ptr_to_member = ptr_to_member;
    return std::ptrdiff_t(caster.offset);
+ //Additional info on MSVC behaviour for the future. For 2/3 int ptr-to-member
+ //types dereference seems to be:
+ //
+ // vboffset = [compile_time_offset if 2-int ptr2memb] /
+ // [ptr2memb.i32[2] if 3-int ptr2memb].
+ // vbtable = *(this + vboffset);
+ // adj = vbtable[ptr2memb.i32[1]];
+ // var = adj + (this + vboffset) + ptr2memb.i32[0];
+ //
+ //To reverse the operation we need to
+ // - obtain vboffset (in 2-int ptr2memb implementation only)
+ // - Go to Parent's vbtable and obtain adjustment at index ptr2memb.i32[1]
+ // - parent = member - adj - vboffset - ptr2memb.i32[0]
+ //
+ //Even accessing to RTTI we might not be able to obtain this information
+ //so anyone who thinks it's possible, please send a patch.
+
    //This works with gcc, msvc, ac++, ibmcpp
    #elif defined(__GNUC__) || defined(__HP_aCC) || defined(BOOST_INTEL) || \
          defined(__IBMCPP__) || defined(__DECCXX)

Modified: branches/release/boost/intrusive/detail/preprocessor.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/preprocessor.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/preprocessor.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2013. 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)
 //

Modified: branches/release/boost/intrusive/detail/rbtree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/rbtree_node.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/rbtree_node.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012.
+// (C) Copyright Ion Gaztanaga 2006-2013.
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,6 +20,8 @@
 #include <boost/intrusive/rbtree_algorithms.hpp>
 #include <boost/intrusive/pointer_plus_bits.hpp>
 #include <boost/intrusive/detail/mpl.hpp>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/detail/tree_node.hpp>
 
 namespace boost {
 namespace intrusive {

Modified: branches/release/boost/intrusive/detail/slist_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/slist_node.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/slist_node.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -15,7 +15,7 @@
 #define BOOST_INTRUSIVE_SLIST_NODE_HPP
 
 #include <boost/intrusive/detail/config_begin.hpp>
-#include <iterator>
+#include <boost/intrusive/detail/utilities.hpp>
 #include <boost/intrusive/detail/assert.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
 
@@ -54,41 +54,41 @@
 
 // slist_iterator provides some basic functions for a
 // node oriented bidirectional iterator:
-template<class Container, bool IsConst>
+template<class RealValueTraits, bool IsConst>
 class slist_iterator
- : public std::iterator
- < std::forward_iterator_tag
- , typename Container::value_type
- , typename Container::difference_type
- , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
- , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
- >
+ : public iiterator<RealValueTraits, IsConst, std::forward_iterator_tag>::iterator_base
 {
    protected:
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename real_value_traits::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename pointer_traits
- <node_ptr>::template rebind_pointer <void>::type void_pointer;
- static const bool store_container_ptr =
- detail::store_cont_ptr_on_it<Container>::value;
+ typedef iiterator
+ <RealValueTraits, IsConst, std::forward_iterator_tag> types_t;
+
+ static const bool stateful_value_traits = types_t::stateful_value_traits;
+
+ typedef RealValueTraits real_value_traits;
+ typedef typename types_t::node_traits node_traits;
+
+ typedef typename types_t::node node;
+ typedef typename types_t::node_ptr node_ptr;
+ typedef typename types_t::void_pointer void_pointer;
 
    public:
- typedef typename Container::value_type value_type;
- typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
- typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;
+ typedef typename types_t::value_type value_type;
+ typedef typename types_t::pointer pointer;
+ typedef typename types_t::reference reference;
+
+ typedef typename pointer_traits
+ <void_pointer>::template rebind_pointer
+ <const real_value_traits>::type const_real_value_traits_ptr;
 
    slist_iterator()
- : members_ (node_ptr(), 0)
    {}
 
- explicit slist_iterator(const node_ptr & node, const Container *cont_ptr)
- : members_ (node, cont_ptr)
+ explicit slist_iterator(const node_ptr & nodeptr, const const_real_value_traits_ptr &traits_ptr)
+ : members_(nodeptr, traits_ptr)
    {}
 
- slist_iterator(slist_iterator<Container, false> const& other)
- : members_(other.pointed_node(), other.get_container())
+ slist_iterator(slist_iterator<RealValueTraits, false> const& other)
+ : members_(other.pointed_node(), other.get_real_value_traits())
    {}
 
    const node_ptr &pointed_node() const
@@ -97,6 +97,9 @@
    slist_iterator &operator=(const node_ptr &node)
    { members_.nodeptr_ = node; return static_cast<slist_iterator&>(*this); }
 
+ const_real_value_traits_ptr get_real_value_traits() const
+ { return pointer_traits<const_real_value_traits_ptr>::static_cast_from(members_.get_ptr()); }
+
    public:
    slist_iterator& operator++()
    {
@@ -123,39 +126,12 @@
    pointer operator->() const
    { return this->get_real_value_traits()->to_value_ptr(members_.nodeptr_); }
 
- const Container *get_container() const
- {
- if(store_container_ptr)
- return static_cast<const Container*>(members_.get_ptr());
- else
- return 0;
- }
-
- slist_iterator<Container, false> unconst() const
- { return slist_iterator<Container, false>(this->pointed_node(), this->get_container()); }
-
- const real_value_traits *get_real_value_traits() const
- {
- if(store_container_ptr)
- return &this->get_container()->get_real_value_traits();
- else
- return 0;
- }
+ slist_iterator<RealValueTraits, false> unconst() const
+ { return slist_iterator<RealValueTraits, false>(this->pointed_node(), this->get_real_value_traits()); }
 
    private:
- struct members
- : public detail::select_constptr
- <void_pointer, store_container_ptr>::type
- {
- typedef typename detail::select_constptr
- <void_pointer, store_container_ptr>::type Base;
-
- members(const node_ptr &n_ptr, const void *cont)
- : Base(cont), nodeptr_(n_ptr)
- {}
 
- node_ptr nodeptr_;
- } members_;
+ iiterator_members<node_ptr, stateful_value_traits> members_;
 };
 
 } //namespace intrusive

Modified: branches/release/boost/intrusive/detail/transform_iterator.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/transform_iterator.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/transform_iterator.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Deleted: branches/release/boost/intrusive/detail/tree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/tree_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85444)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,1742 +0,0 @@
-/////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2007-2012
-//
-// 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_TREE_ALGORITHMS_HPP
-#define BOOST_INTRUSIVE_TREE_ALGORITHMS_HPP
-
-#include <boost/intrusive/detail/config_begin.hpp>
-#include <boost/intrusive/detail/assert.hpp>
-#include <boost/intrusive/intrusive_fwd.hpp>
-#include <cstddef>
-#include <boost/intrusive/detail/utilities.hpp>
-#include <boost/intrusive/pointer_traits.hpp>
-
-namespace boost {
-namespace intrusive {
-namespace detail {
-
-//! This is an implementation of a binary search tree.
-//! A node in the search tree has references to its children and its parent. This
-//! is to allow traversal of the whole tree from a given node making the
-//! implementation of iterator a pointer to a node.
-//! At the top of the tree a node is used specially. This node's parent pointer
-//! is pointing to the root of the tree. Its left pointer points to the
-//! leftmost node in the tree and the right pointer to the rightmost one.
-//! This node is used to represent the end-iterator.
-//!
-//! +---------+
-//! header------------------------------>| |
-//! | |
-//! +----------(left)--------| |--------(right)---------+
-//! | +---------+ |
-//! | | |
-//! | | (parent) |
-//! | | |
-//! | | |
-//! | +---------+ |
-//! root of tree ..|......................> | | |
-//! | | D | |
-//! | | | |
-//! | +-------+---------+-------+ |
-//! | | | |
-//! | | | |
-//! | | | |
-//! | | | |
-//! | | | |
-//! | +---------+ +---------+ |
-//! | | | | | |
-//! | | B | | F | |
-//! | | | | | |
-//! | +--+---------+--+ +--+---------+--+ |
-//! | | | | | |
-//! | | | | | |
-//! | | | | | |
-//! | +---+-----+ +-----+---+ +---+-----+ +-----+---+ |
-//! +-->| | | | | | | |<--+
-//! | A | | C | | E | | G |
-//! | | | | | | | |
-//! +---------+ +---------+ +---------+ +---------+
-//!
-
-//! tree_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_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>
-template<class NodeTraits>
-class tree_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;
-
- //! This type is the information that will be filled by insert_unique_check
- struct insert_commit_data
- {
- insert_commit_data()
- : link_left(false)
- , node()
- {}
- bool link_left;
- node_ptr node;
- };
-
- struct nop_erase_fixup
- {
- void operator()(const node_ptr&, const node_ptr&){}
- };
-
- /// @cond
- private:
- template<class Disposer>
- struct dispose_subtree_disposer
- {
- dispose_subtree_disposer(Disposer &disp, const node_ptr & subtree)
- : disposer_(&disp), subtree_(subtree)
- {}
-
- void release()
- { disposer_ = 0; }
-
- ~dispose_subtree_disposer()
- {
- if(disposer_){
- dispose_subtree(subtree_, *disposer_);
- }
- }
- Disposer *disposer_;
- node_ptr subtree_;
- };
-
- static node_ptr uncast(const const_node_ptr & ptr)
- { return pointer_traits<node_ptr>::const_cast_from(ptr); }
-
- /// @endcond
-
- public:
- static node_ptr begin_node(const const_node_ptr & header)
- { return node_traits::get_left(header); }
-
- static node_ptr end_node(const const_node_ptr & header)
- { return uncast(header); }
-
- //! <b>Requires</b>: 'node' is a node of the tree or an node initialized
- //! by init(...) or init_node.
- //!
- //! <b>Effects</b>: Returns true if the node is initialized by init() or init_node().
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- static bool unique(const const_node_ptr & node)
- { return !NodeTraits::get_parent(node); }
-
- static node_ptr get_header(const const_node_ptr & node)
- {
- node_ptr h = uncast(node);
- if(NodeTraits::get_parent(node)){
- h = NodeTraits::get_parent(node);
- while(!is_header(h))
- h = NodeTraits::get_parent(h);
- }
- return h;
- }
-
- //! <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(const node_ptr & node1, const node_ptr & node2)
- {
- if(node1 == node2)
- return;
-
- node_ptr header1(get_header(node1)), header2(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(const node_ptr & node1, const node_ptr & header1, const node_ptr & node2, const node_ptr & header2)
- {
- if(node1 == node2)
- return;
-
- //node1 and node2 must not be header nodes
- //BOOST_INTRUSIVE_INVARIANT_ASSERT((header1 != node1 && header2 != node2));
- if(header1 != header2){
- //Update header1 if necessary
- if(node1 == NodeTraits::get_left(header1)){
- NodeTraits::set_left(header1, node2);
- }
-
- if(node1 == NodeTraits::get_right(header1)){
- NodeTraits::set_right(header1, node2);
- }
-
- if(node1 == NodeTraits::get_parent(header1)){
- NodeTraits::set_parent(header1, node2);
- }
-
- //Update header2 if necessary
- if(node2 == NodeTraits::get_left(header2)){
- NodeTraits::set_left(header2, node1);
- }
-
- if(node2 == NodeTraits::get_right(header2)){
- NodeTraits::set_right(header2, node1);
- }
-
- if(node2 == NodeTraits::get_parent(header2)){
- NodeTraits::set_parent(header2, node1);
- }
- }
- else{
- //If both nodes are from the same tree
- //Update header if necessary
- if(node1 == NodeTraits::get_left(header1)){
- NodeTraits::set_left(header1, node2);
- }
- else if(node2 == NodeTraits::get_left(header2)){
- NodeTraits::set_left(header2, node1);
- }
-
- if(node1 == NodeTraits::get_right(header1)){
- NodeTraits::set_right(header1, node2);
- }
- else if(node2 == NodeTraits::get_right(header2)){
- NodeTraits::set_right(header2, node1);
- }
-
- if(node1 == NodeTraits::get_parent(header1)){
- NodeTraits::set_parent(header1, node2);
- }
- else if(node2 == NodeTraits::get_parent(header2)){
- NodeTraits::set_parent(header2, node1);
- }
-
- //Adjust data in nodes to be swapped
- //so that final link swap works as expected
- if(node1 == NodeTraits::get_parent(node2)){
- NodeTraits::set_parent(node2, node2);
-
- if(node2 == NodeTraits::get_right(node1)){
- NodeTraits::set_right(node1, node1);
- }
- else{
- NodeTraits::set_left(node1, node1);
- }
- }
- else if(node2 == NodeTraits::get_parent(node1)){
- NodeTraits::set_parent(node1, node1);
-
- if(node1 == NodeTraits::get_right(node2)){
- NodeTraits::set_right(node2, node2);
- }
- else{
- NodeTraits::set_left(node2, node2);
- }
- }
- }
-
- //Now swap all the links
- node_ptr temp;
- //swap left link
- temp = NodeTraits::get_left(node1);
- NodeTraits::set_left(node1, NodeTraits::get_left(node2));
- NodeTraits::set_left(node2, temp);
- //swap right link
- temp = NodeTraits::get_right(node1);
- NodeTraits::set_right(node1, NodeTraits::get_right(node2));
- NodeTraits::set_right(node2, temp);
- //swap parent link
- temp = NodeTraits::get_parent(node1);
- NodeTraits::set_parent(node1, NodeTraits::get_parent(node2));
- NodeTraits::set_parent(node2, temp);
-
- //Now adjust adjacent nodes for newly inserted node 1
- if((temp = NodeTraits::get_left(node1))){
- NodeTraits::set_parent(temp, node1);
- }
- if((temp = NodeTraits::get_right(node1))){
- NodeTraits::set_parent(temp, node1);
- }
- if((temp = NodeTraits::get_parent(node1)) &&
- //The header has been already updated so avoid it
- temp != header2){
- if(NodeTraits::get_left(temp) == node2){
- NodeTraits::set_left(temp, node1);
- }
- if(NodeTraits::get_right(temp) == node2){
- NodeTraits::set_right(temp, node1);
- }
- }
- //Now adjust adjacent nodes for newly inserted node 2
- if((temp = NodeTraits::get_left(node2))){
- NodeTraits::set_parent(temp, node2);
- }
- if((temp = NodeTraits::get_right(node2))){
- NodeTraits::set_parent(temp, node2);
- }
- if((temp = NodeTraits::get_parent(node2)) &&
- //The header has been already updated so avoid it
- temp != header1){
- if(NodeTraits::get_left(temp) == node1){
- NodeTraits::set_left(temp, node2);
- }
- if(NodeTraits::get_right(temp) == node1){
- NodeTraits::set_right(temp, node2);
- }
- }
- }
-
- //! <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(const node_ptr & node_to_be_replaced, const node_ptr & new_node)
- {
- if(node_to_be_replaced == new_node)
- return;
- replace_node(node_to_be_replaced, 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(const node_ptr & node_to_be_replaced, const node_ptr & header, const node_ptr & new_node)
- {
- if(node_to_be_replaced == new_node)
- return;
-
- //Update header if necessary
- if(node_to_be_replaced == NodeTraits::get_left(header)){
- NodeTraits::set_left(header, new_node);
- }
-
- if(node_to_be_replaced == NodeTraits::get_right(header)){
- NodeTraits::set_right(header, new_node);
- }
-
- if(node_to_be_replaced == NodeTraits::get_parent(header)){
- NodeTraits::set_parent(header, new_node);
- }
-
- //Now set data from the original node
- node_ptr temp;
- NodeTraits::set_left(new_node, NodeTraits::get_left(node_to_be_replaced));
- NodeTraits::set_right(new_node, NodeTraits::get_right(node_to_be_replaced));
- NodeTraits::set_parent(new_node, NodeTraits::get_parent(node_to_be_replaced));
-
- //Now adjust adjacent nodes for newly inserted node
- if((temp = NodeTraits::get_left(new_node))){
- NodeTraits::set_parent(temp, new_node);
- }
- if((temp = NodeTraits::get_right(new_node))){
- NodeTraits::set_parent(temp, new_node);
- }
- if((temp = NodeTraits::get_parent(new_node)) &&
- //The header has been already updated so avoid it
- temp != header){
- if(NodeTraits::get_left(temp) == node_to_be_replaced){
- NodeTraits::set_left(temp, new_node);
- }
- if(NodeTraits::get_right(temp) == node_to_be_replaced){
- NodeTraits::set_right(temp, new_node);
- }
- }
- }
-
- //! <b>Requires</b>: 'node' 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(const node_ptr & node)
- {
- node_ptr p_right(NodeTraits::get_right(node));
- if(p_right){
- return minimum(p_right);
- }
- else {
- node_ptr p(node);
- node_ptr x = NodeTraits::get_parent(p);
- while(p == NodeTraits::get_right(x)){
- p = x;
- x = NodeTraits::get_parent(x);
- }
- return NodeTraits::get_right(p) != x ? x : uncast(p);
- }
- }
-
- //! <b>Requires</b>: 'node' 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(const node_ptr & node)
- {
- if(is_header(node)){
- return NodeTraits::get_right(node);
- //return maximum(NodeTraits::get_parent(node));
- }
- else if(NodeTraits::get_left(node)){
- return maximum(NodeTraits::get_left(node));
- }
- else {
- node_ptr p(node);
- node_ptr x = NodeTraits::get_parent(p);
- while(p == NodeTraits::get_left(x)){
- p = x;
- x = NodeTraits::get_parent(x);
- }
- return x;
- }
- }
-
- //! <b>Requires</b>: 'node' is a node of a tree but not the header.
- //!
- //! <b>Effects</b>: Returns the minimum node of the subtree starting at p.
- //!
- //! <b>Complexity</b>: Logarithmic to the size of the subtree.
- //!
- //! <b>Throws</b>: Nothing.
- static node_ptr minimum (node_ptr node)
- {
- for(node_ptr p_left = NodeTraits::get_left(node)
- ;p_left
- ;p_left = NodeTraits::get_left(node)){
- node = p_left;
- }
- return node;
- }
-
- //! <b>Requires</b>: 'node' is a node of a tree but not the header.
- //!
- //! <b>Effects</b>: Returns the maximum node of the subtree starting at p.
- //!
- //! <b>Complexity</b>: Logarithmic to the size of the subtree.
- //!
- //! <b>Throws</b>: Nothing.
- static node_ptr maximum(node_ptr node)
- {
- for(node_ptr p_right = NodeTraits::get_right(node)
- ;p_right
- ;p_right = NodeTraits::get_right(node)){
- node = p_right;
- }
- return node;
- }
-
- //! <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(const node_ptr & node)
- {
- NodeTraits::set_parent(node, node_ptr());
- NodeTraits::set_left(node, node_ptr());
- NodeTraits::set_right(node, node_ptr());
- };
-
- //! <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 const_node_ptr & node)
- {
- return !NodeTraits::get_parent(node) &&
- !NodeTraits::get_left(node) &&
- !NodeTraits::get_right(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(const node_ptr & header)
- {
- NodeTraits::set_parent(header, node_ptr());
- NodeTraits::set_left(header, header);
- NodeTraits::set_right(header, header);
- }
-
- //! <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()(const 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(const node_ptr & header, Disposer disposer)
- {
- node_ptr source_root = NodeTraits::get_parent(header);
- if(!source_root)
- return;
- dispose_subtree(source_root, disposer);
- init_header(header);
- }
-
- //! <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(const node_ptr & header)
- {
- node_ptr leftmost = NodeTraits::get_left(header);
- if (leftmost == header)
- return node_ptr();
- node_ptr leftmost_parent(NodeTraits::get_parent(leftmost));
- node_ptr leftmost_right (NodeTraits::get_right(leftmost));
- bool is_root = leftmost_parent == header;
-
- if (leftmost_right){
- NodeTraits::set_parent(leftmost_right, leftmost_parent);
- NodeTraits::set_left(header, tree_algorithms::minimum(leftmost_right));
-
- if (is_root)
- NodeTraits::set_parent(header, leftmost_right);
- else
- NodeTraits::set_left(NodeTraits::get_parent(header), leftmost_right);
- }
- else if (is_root){
- NodeTraits::set_parent(header, node_ptr());
- NodeTraits::set_left(header, header);
- NodeTraits::set_right(header, header);
- }
- else{
- NodeTraits::set_left(leftmost_parent, node_ptr());
- NodeTraits::set_left(header, leftmost_parent);
- }
- return leftmost;
- }
-
- //! <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 const_node_ptr & subtree)
- {
- if(!subtree) return 0;
- std::size_t count = 0;
- node_ptr p = minimum(uncast(subtree));
- bool continue_looping = true;
- while(continue_looping){
- ++count;
- node_ptr p_right(NodeTraits::get_right(p));
- if(p_right){
- p = minimum(p_right);
- }
- else {
- for(;;){
- node_ptr q;
- if (p == subtree){
- continue_looping = false;
- break;
- }
- q = p;
- p = NodeTraits::get_parent(p);
- if (NodeTraits::get_left(p) == q)
- break;
- }
- }
- }
- return count;
- }
-
- //! <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 size(const const_node_ptr & header)
- {
- node_ptr beg(begin_node(header));
- node_ptr end(end_node(header));
- std::size_t i = 0;
- for(;beg != end; beg = next_node(beg)) ++i;
- return i;
- }
-
- //! <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(const node_ptr & header1, const node_ptr & header2)
- {
- if(header1 == header2)
- return;
-
- node_ptr tmp;
-
- //Parent swap
- tmp = NodeTraits::get_parent(header1);
- NodeTraits::set_parent(header1, NodeTraits::get_parent(header2));
- NodeTraits::set_parent(header2, tmp);
- //Left swap
- tmp = NodeTraits::get_left(header1);
- NodeTraits::set_left(header1, NodeTraits::get_left(header2));
- NodeTraits::set_left(header2, tmp);
- //Right swap
- tmp = NodeTraits::get_right(header1);
- NodeTraits::set_right(header1, NodeTraits::get_right(header2));
- NodeTraits::set_right(header2, tmp);
-
- //Now test parent
- node_ptr h1_parent(NodeTraits::get_parent(header1));
- if(h1_parent){
- NodeTraits::set_parent(h1_parent, header1);
- }
- else{
- NodeTraits::set_left(header1, header1);
- NodeTraits::set_right(header1, header1);
- }
-
- node_ptr h2_parent(NodeTraits::get_parent(header2));
- if(h2_parent){
- NodeTraits::set_parent(h2_parent, header2);
- }
- else{
- NodeTraits::set_left(header2, header2);
- NodeTraits::set_right(header2, header2);
- }
- }
-
- static bool is_header(const const_node_ptr & p)
- {
- node_ptr p_left (NodeTraits::get_left(p));
- node_ptr p_right(NodeTraits::get_right(p));
- if(!NodeTraits::get_parent(p) || //Header condition when empty tree
- (p_left && p_right && //Header always has leftmost and rightmost
- (p_left == p_right || //Header condition when only node
- (NodeTraits::get_parent(p_left) != p ||
- NodeTraits::get_parent(p_right) != p ))
- //When tree size > 1 headers can't be leftmost's
- //and rightmost's parent
- )){
- return true;
- }
- return false;
- }
-
- //! <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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- {
- node_ptr end = uncast(header);
- node_ptr y = lower_bound(header, key, comp);
- return (y == end || comp(key, y)) ? end : y;
- }
-
- //! <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.
- //! 'lower_key' must not be greater than 'upper_key' according to 'comp'. If
- //! 'lower_key' == 'upper_key', ('left_closed' || 'right_closed') must be false.
- //!
- //! <b>Effects</b>: Returns an a pair with the following criteria:
- //!
- //! first = lower_bound(lower_key) if left_closed, upper_bound(lower_key) otherwise
- //!
- //! second = upper_bound(upper_key) if right_closed, lower_bound(upper_key) otherwise
- //!
- //! <b>Complexity</b>: Logarithmic.
- //!
- //! <b>Throws</b>: If "comp" throws.
- //!
- //! <b>Note</b>: This function can be more efficient than calling upper_bound
- //! and lower_bound for lower_key and upper_key.
- template< class KeyType, class KeyNodePtrCompare>
- static std::pair<node_ptr, node_ptr> bounded_range
- ( const const_node_ptr & header
- , const KeyType &lower_key
- , const KeyType &upper_key
- , KeyNodePtrCompare comp
- , bool left_closed
- , bool right_closed)
- {
- node_ptr y = uncast(header);
- node_ptr x = NodeTraits::get_parent(header);
-
- while(x){
- //If x is less than lower_key the target
- //range is on the right part
- if(comp(x, lower_key)){
- //Check for invalid input range
- BOOST_INTRUSIVE_INVARIANT_ASSERT(comp(x, upper_key));
- x = NodeTraits::get_right(x);
- }
- //If the upper_key is less than x, the target
- //range is on the left part
- else if(comp(upper_key, x)){
- //y > upper_key
- y = x;
- x = NodeTraits::get_left(x);
- }
- else{
- //x is inside the bounded range( x >= lower_key && x <= upper_key),
- //so we must split lower and upper searches
- //
- //Sanity check: if lower_key and upper_key are equal, then both left_closed and right_closed can't be false
- BOOST_INTRUSIVE_INVARIANT_ASSERT(left_closed || right_closed || comp(lower_key, x) || comp(x, upper_key));
- return std::pair<node_ptr,node_ptr>(
- left_closed
- //If left_closed, then comp(x, lower_key) is already the lower_bound
- //condition so we save one comparison and go to the next level
- //following traditional lower_bound algo
- ? lower_bound_loop(NodeTraits::get_left(x), x, lower_key, comp)
- //If left-open, comp(x, lower_key) is not the upper_bound algo
- //condition so we must recheck current 'x' node with upper_bound algo
- : upper_bound_loop(x, y, lower_key, comp)
- ,
- right_closed
- //If right_closed, then comp(upper_key, x) is already the upper_bound
- //condition so we can save one comparison and go to the next level
- //following lower_bound algo
- ? upper_bound_loop(NodeTraits::get_right(x), y, upper_key, comp)
- //If right-open, comp(upper_key, x) is not the lower_bound algo
- //condition so we must recheck current 'x' node with lower_bound algo
- : lower_bound_loop(x, y, upper_key, comp)
- );
- }
- }
- return std::pair<node_ptr,node_ptr> (y, y);
- }
-
- //! <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 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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- {
- return bounded_range(header, key, key, comp, true, true);
- }
-
- //! <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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- {
- return lower_bound_loop(NodeTraits::get_parent(header), uncast(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 const_node_ptr & header, const KeyType &key, KeyNodePtrCompare comp)
- {
- return upper_bound_loop(NodeTraits::get_parent(header), uncast(header), key, comp);
- }
-
- //! <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
- (const node_ptr & header, const node_ptr & new_value, const insert_commit_data &commit_data)
- { return insert_commit(header, new_value, commit_data); }
-
- static void insert_commit
- (const node_ptr & header, const node_ptr & new_node, const insert_commit_data &commit_data)
- {
- //Check if commit_data has not been initialized by a insert_unique_check call.
- BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != node_ptr());
- node_ptr parent_node(commit_data.node);
- if(parent_node == header){
- NodeTraits::set_parent(header, new_node);
- NodeTraits::set_right(header, new_node);
- NodeTraits::set_left(header, new_node);
- }
- else if(commit_data.link_left){
- NodeTraits::set_left(parent_node, new_node);
- if(parent_node == NodeTraits::get_left(header))
- NodeTraits::set_left(header, new_node);
- }
- else{
- NodeTraits::set_right(parent_node, new_node);
- if(parent_node == NodeTraits::get_right(header))
- NodeTraits::set_right(header, new_node);
- }
- NodeTraits::set_parent(new_node, parent_node);
- NodeTraits::set_right(new_node, node_ptr());
- NodeTraits::set_left(new_node, node_ptr());
- }
-
- //! <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 const_node_ptr & header, const KeyType &key
- ,KeyNodePtrCompare comp, insert_commit_data &commit_data, std::size_t *pdepth = 0)
- {
- std::size_t depth = 0;
- node_ptr h(uncast(header));
- node_ptr y(h);
- node_ptr x(NodeTraits::get_parent(y));
- node_ptr prev = node_ptr();
-
- //Find the upper bound, cache the previous value and if we should
- //store it in the left or right node
- bool left_child = true;
- while(x){
- ++depth;
- y = x;
- x = (left_child = comp(key, x)) ?
- NodeTraits::get_left(x) : (prev = y, NodeTraits::get_right(x));
- }
-
- if(pdepth) *pdepth = depth;
-
- //Since we've found the upper bound there is no other value with the same key if:
- // - There is no previous node
- // - The previous node is less than the key
- if(!prev || comp(prev, key)){
- commit_data.link_left = left_child;
- commit_data.node = y;
- return std::pair<node_ptr, bool>(node_ptr(), true);
- }
- //If the previous value was not less than key, it means that it's equal
- //(because we've checked the upper bound)
- else{
- return std::pair<node_ptr, bool>(prev, false);
- }
- }
-
- template<class KeyType, class KeyNodePtrCompare>
- static std::pair<node_ptr, bool> insert_unique_check
- (const const_node_ptr & header, const node_ptr &hint, const KeyType &key
- ,KeyNodePtrCompare comp, insert_commit_data &commit_data, std::size_t *pdepth = 0)
- {
- //hint must be bigger than the key
- if(hint == header || comp(key, hint)){
- node_ptr prev(hint);
- //Previous value should be less than the key
- if(hint == begin_node(header) || comp((prev = prev_node(hint)), key)){
- commit_data.link_left = unique(header) || !NodeTraits::get_left(hint);
- commit_data.node = commit_data.link_left ? hint : prev;
- if(pdepth){
- *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1;
- }
- return std::pair<node_ptr, bool>(node_ptr(), true);
- }
- }
- //Hint was wrong, use hintless insertion
- return insert_unique_check(header, key, comp, commit_data, pdepth);
- }
-
- template<class NodePtrCompare>
- static void insert_equal_check
- (const node_ptr &header, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp
- , insert_commit_data &commit_data, std::size_t *pdepth = 0)
- {
- if(hint == header || !comp(hint, new_node)){
- node_ptr prev(hint);
- if(hint == NodeTraits::get_left(header) ||
- !comp(new_node, (prev = prev_node(hint)))){
- bool link_left = unique(header) || !NodeTraits::get_left(hint);
- commit_data.link_left = link_left;
- commit_data.node = link_left ? hint : prev;
- if(pdepth){
- *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1;
- }
- }
- else{
- insert_equal_upper_bound_check(header, new_node, comp, commit_data, pdepth);
- }
- }
- else{
- insert_equal_lower_bound_check(header, new_node, comp, commit_data, pdepth);
- }
- }
-
- template<class NodePtrCompare>
- static void insert_equal_upper_bound_check
- (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0)
- { insert_equal_check_impl(true, h, new_node, comp, commit_data, pdepth); }
-
- template<class NodePtrCompare>
- static void insert_equal_lower_bound_check
- (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0)
- { insert_equal_check_impl(false, h, new_node, comp, commit_data, pdepth); }
-
- template<class NodePtrCompare>
- static node_ptr insert_equal
- (const node_ptr & h, const node_ptr & hint, const node_ptr & new_node, NodePtrCompare comp, std::size_t *pdepth = 0)
- {
- insert_commit_data commit_data;
- insert_equal_check(h, hint, new_node, comp, commit_data, pdepth);
- insert_commit(h, new_node, commit_data);
- return new_node;
- }
-
- template<class NodePtrCompare>
- static node_ptr insert_equal_upper_bound
- (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, std::size_t *pdepth = 0)
- {
- insert_commit_data commit_data;
- insert_equal_upper_bound_check(h, new_node, comp, commit_data, pdepth);
- insert_commit(h, new_node, commit_data);
- return new_node;
- }
-
- template<class NodePtrCompare>
- static node_ptr insert_equal_lower_bound
- (const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, std::size_t *pdepth = 0)
- {
- insert_commit_data commit_data;
- insert_equal_lower_bound_check(h, new_node, comp, commit_data, pdepth);
- insert_commit(h, new_node, commit_data);
- return new_node;
- }
-
- static node_ptr insert_before
- (const node_ptr & header, const node_ptr & pos, const node_ptr & new_node, std::size_t *pdepth = 0)
- {
- insert_commit_data commit_data;
- insert_before_check(header, pos, commit_data, pdepth);
- insert_commit(header, new_node, commit_data);
- return new_node;
- }
-
- static void insert_before_check
- (const node_ptr &header, const node_ptr & pos
- , insert_commit_data &commit_data, std::size_t *pdepth = 0)
- {
- node_ptr prev(pos);
- if(pos != NodeTraits::get_left(header))
- prev = prev_node(pos);
- bool link_left = unique(header) || !NodeTraits::get_left(pos);
- commit_data.link_left = link_left;
- commit_data.node = link_left ? pos : prev;
- if(pdepth){
- *pdepth = commit_data.node == header ? 0 : depth(commit_data.node) + 1;
- }
- }
-
- static void push_back
- (const node_ptr & header, const node_ptr & new_node, std::size_t *pdepth = 0)
- {
- insert_commit_data commit_data;
- push_back_check(header, commit_data, pdepth);
- insert_commit(header, new_node, commit_data);
- }
-
- static void push_back_check
- (const node_ptr & header, insert_commit_data &commit_data, std::size_t *pdepth = 0)
- {
- node_ptr prev(NodeTraits::get_right(header));
- if(pdepth){
- *pdepth = prev == header ? 0 : depth(prev) + 1;
- }
- commit_data.link_left = false;
- commit_data.node = prev;
- }
-
- static void push_front
- (const node_ptr & header, const node_ptr & new_node, std::size_t *pdepth = 0)
- {
- insert_commit_data commit_data;
- push_front_check(header, commit_data, pdepth);
- insert_commit(header, new_node, commit_data);
- }
-
- static void push_front_check
- (const node_ptr & header, insert_commit_data &commit_data, std::size_t *pdepth = 0)
- {
- node_ptr pos(NodeTraits::get_left(header));
- if(pdepth){
- *pdepth = pos == header ? 0 : depth(pos) + 1;
- }
- commit_data.link_left = true;
- commit_data.node = pos;
- }
-
- //! <b>Requires</b>: 'node' can't be a header node.
- //!
- //! <b>Effects</b>: Calculates the depth of a node: the depth of a
- //! node is the length (number of edges) of the path from the root
- //! to that node. (The root node is at depth 0.)
- //!
- //! <b>Complexity</b>: Logarithmic to the number of nodes in the tree.
- //!
- //! <b>Throws</b>: Nothing.
- static std::size_t depth(const_node_ptr node)
- {
- std::size_t depth = 0;
- node_ptr p_parent;
- while(node != NodeTraits::get_parent(p_parent = NodeTraits::get_parent(node))){
- ++depth;
- node = p_parent;
- }
- return depth;
- }
-
- //! <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()(const 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()(const node_ptr &)</tt> to obtain
- //! the nodes of the target tree. If "cloner" throws, the cloned target nodes
- //! are disposed using <tt>void disposer(const 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 const_node_ptr & source_header, const node_ptr & target_header, Cloner cloner, Disposer disposer)
- {
- if(!unique(target_header)){
- clear_and_dispose(target_header, disposer);
- }
-
- node_ptr leftmost, rightmost;
- node_ptr new_root = clone_subtree
- (source_header, target_header, cloner, disposer, leftmost, rightmost);
-
- //Now update header node
- NodeTraits::set_parent(target_header, new_root);
- NodeTraits::set_left (target_header, leftmost);
- NodeTraits::set_right (target_header, rightmost);
- }
-
- template <class Cloner, class Disposer>
- static node_ptr clone_subtree
- (const const_node_ptr &source_parent, const node_ptr &target_parent
- , Cloner cloner, Disposer disposer
- , node_ptr &leftmost_out, node_ptr &rightmost_out
- )
- {
- node_ptr target_sub_root = target_parent;
- node_ptr source_root = NodeTraits::get_parent(source_parent);
- if(!source_root){
- leftmost_out = rightmost_out = source_root;
- }
- else{
- //We'll calculate leftmost and rightmost nodes while iterating
- node_ptr current = source_root;
- node_ptr insertion_point = target_sub_root = cloner(current);
-
- //We'll calculate leftmost and rightmost nodes while iterating
- node_ptr leftmost = target_sub_root;
- node_ptr rightmost = target_sub_root;
-
- //First set the subroot
- NodeTraits::set_left(target_sub_root, node_ptr());
- NodeTraits::set_right(target_sub_root, node_ptr());
- NodeTraits::set_parent(target_sub_root, target_parent);
-
- dispose_subtree_disposer<Disposer> rollback(disposer, target_sub_root);
- while(true) {
- //First clone left nodes
- if( NodeTraits::get_left(current) &&
- !NodeTraits::get_left(insertion_point)) {
- current = NodeTraits::get_left(current);
- node_ptr temp = insertion_point;
- //Clone and mark as leaf
- insertion_point = cloner(current);
- NodeTraits::set_left (insertion_point, node_ptr());
- NodeTraits::set_right (insertion_point, node_ptr());
- //Insert left
- NodeTraits::set_parent(insertion_point, temp);
- NodeTraits::set_left (temp, insertion_point);
- //Update leftmost
- if(rightmost == target_sub_root)
- leftmost = insertion_point;
- }
- //Then clone right nodes
- else if( NodeTraits::get_right(current) &&
- !NodeTraits::get_right(insertion_point)){
- current = NodeTraits::get_right(current);
- node_ptr temp = insertion_point;
- //Clone and mark as leaf
- insertion_point = cloner(current);
- NodeTraits::set_left (insertion_point, node_ptr());
- NodeTraits::set_right (insertion_point, node_ptr());
- //Insert right
- NodeTraits::set_parent(insertion_point, temp);
- NodeTraits::set_right (temp, insertion_point);
- //Update rightmost
- rightmost = insertion_point;
- }
- //If not, go up
- else if(current == source_root){
- break;
- }
- else{
- //Branch completed, go up searching more nodes to clone
- current = NodeTraits::get_parent(current);
- insertion_point = NodeTraits::get_parent(insertion_point);
- }
- }
- rollback.release();
- leftmost_out = leftmost;
- rightmost_out = rightmost;
- }
- return target_sub_root;
- }
-
- template<class Disposer>
- static void dispose_subtree(node_ptr x, Disposer disposer)
- {
- while (x){
- node_ptr save(NodeTraits::get_left(x));
- if (save) {
- // Right rotation
- NodeTraits::set_left(x, NodeTraits::get_right(save));
- NodeTraits::set_right(save, x);
- }
- else {
- save = NodeTraits::get_right(x);
- init(x);
- disposer(x);
- }
- x = save;
- }
- }
-
- //! <b>Requires</b>: p is a node of a tree.
- //!
- //! <b>Effects</b>: Returns true if p is a left child.
- //!
- //! <b>Complexity</b>: Constant.
- //!
- //! <b>Throws</b>: Nothing.
- static bool is_left_child(const node_ptr & p)
- { return NodeTraits::get_left(NodeTraits::get_parent(p)) == p; }
-
- //! <b>Requires</b>: p is a node of a tree.
- //!
- //! <b>Effects</b>: Returns true if p is a right child.
- //!
- //! <b>Complexity</b>: Constant.
- //!
- //! <b>Throws</b>: Nothing.
- static bool is_right_child(const node_ptr & p)
- { return NodeTraits::get_right(NodeTraits::get_parent(p)) == p; }
-
- //Fix header and own's parent data when replacing x with own, providing own's old data with parent
- static void replace_own_impl(const node_ptr & own, const node_ptr & x, const node_ptr & header, const node_ptr & own_parent, bool own_was_left)
- {
- if(NodeTraits::get_parent(header) == own)
- NodeTraits::set_parent(header, x);
- else if(own_was_left)
- NodeTraits::set_left(own_parent, x);
- else
- NodeTraits::set_right(own_parent, x);
- }
-
- //Fix header and own's parent data when replacing x with own, supposing own
- //links with its parent are still ok
- static void replace_own(const node_ptr & own, const node_ptr & x, const node_ptr & header)
- {
- node_ptr own_parent(NodeTraits::get_parent(own));
- bool own_is_left(NodeTraits::get_left(own_parent) == own);
- replace_own_impl(own, x, header, own_parent, own_is_left);
- }
-
- // rotate parent p to left (no header and p's parent fixup)
- static node_ptr rotate_left(const node_ptr & p)
- {
- node_ptr x(NodeTraits::get_right(p));
- node_ptr x_left(NodeTraits::get_left(x));
- NodeTraits::set_right(p, x_left);
- if(x_left){
- NodeTraits::set_parent(x_left, p);
- }
- NodeTraits::set_left(x, p);
- NodeTraits::set_parent(p, x);
- return x;
- }
-
- // rotate parent p to left (with header and p's parent fixup)
- static void rotate_left(const node_ptr & p, const node_ptr & header)
- {
- bool p_was_left(is_left_child(p));
- node_ptr p_old_parent(NodeTraits::get_parent(p));
- node_ptr x(rotate_left(p));
- NodeTraits::set_parent(x, p_old_parent);
- replace_own_impl(p, x, header, p_old_parent, p_was_left);
- }
-
- // rotate parent p to right (no header and p's parent fixup)
- static node_ptr rotate_right(const node_ptr & p)
- {
- node_ptr x(NodeTraits::get_left(p));
- node_ptr x_right(NodeTraits::get_right(x));
- NodeTraits::set_left(p, x_right);
- if(x_right){
- NodeTraits::set_parent(x_right, p);
- }
- NodeTraits::set_right(x, p);
- NodeTraits::set_parent(p, x);
- return x;
- }
-
- // rotate parent p to right (with header and p's parent fixup)
- static void rotate_right(const node_ptr & p, const node_ptr & header)
- {
- bool p_was_left(is_left_child(p));
- node_ptr p_old_parent(NodeTraits::get_parent(p));
- node_ptr x(rotate_right(p));
- NodeTraits::set_parent(x, p_old_parent);
- replace_own_impl(p, x, header, p_old_parent, p_was_left);
- }
-
- static void erase(const node_ptr & header, const node_ptr & z)
- {
- data_for_rebalance ignored;
- erase_impl(header, z, ignored);
- }
-
- struct data_for_rebalance
- {
- node_ptr x;
- node_ptr x_parent;
- node_ptr y;
- };
-
- template<class F>
- static void erase(const node_ptr & header, const node_ptr & z, F z_and_successor_fixup, data_for_rebalance &info)
- {
- erase_impl(header, z, info);
- if(info.y != z){
- z_and_successor_fixup(z, info.y);
- }
- }
-
- static void unlink(const node_ptr & node)
- {
- node_ptr x = NodeTraits::get_parent(node);
- if(x){
- while(!is_header(x))
- x = NodeTraits::get_parent(x);
- erase(x, node);
- }
- }
-
- static void tree_to_vine(const node_ptr & header)
- { subtree_to_vine(NodeTraits::get_parent(header)); }
-
- static void vine_to_tree(const node_ptr & header, std::size_t count)
- { vine_to_subtree(NodeTraits::get_parent(header), count); }
-
- static void rebalance(const node_ptr & header)
- {
- //Taken from:
- //"Tree rebalancing in optimal time and space"
- //Quentin F. Stout and Bette L. Warren
- std::size_t len = 0;
- subtree_to_vine(NodeTraits::get_parent(header), &len);
- vine_to_subtree(NodeTraits::get_parent(header), len);
- }
-
- static node_ptr rebalance_subtree(const node_ptr & old_root)
- {
- std::size_t len = 0;
- node_ptr new_root = subtree_to_vine(old_root, &len);
- return vine_to_subtree(new_root, len);
- }
-
- static node_ptr subtree_to_vine(const node_ptr & old_root, std::size_t *plen = 0)
- {
- std::size_t len;
- len = 0;
- if(!old_root) return node_ptr();
-
- //To avoid irregularities in the algorithm (old_root can be a
- //left or right child or even the root of the tree) just put the
- //root as the right child of its parent. Before doing this backup
- //information to restore the original relationship after
- //the algorithm is applied.
- node_ptr super_root = NodeTraits::get_parent(old_root);
- BOOST_INTRUSIVE_INVARIANT_ASSERT(super_root);
-
- //Get info
- node_ptr super_root_right_backup = NodeTraits::get_right(super_root);
- bool super_root_is_header = is_header(super_root);
- bool old_root_is_right = is_right_child(old_root);
-
- node_ptr x(old_root);
- node_ptr new_root(x);
- node_ptr save;
- bool moved_to_right = false;
- for( ; x; x = save){
- save = NodeTraits::get_left(x);
- if(save){
- // Right rotation
- node_ptr save_right = NodeTraits::get_right(save);
- node_ptr x_parent = NodeTraits::get_parent(x);
- NodeTraits::set_parent(save, x_parent);
- NodeTraits::set_right (x_parent, save);
- NodeTraits::set_parent(x, save);
- NodeTraits::set_right (save, x);
- NodeTraits::set_left(x, save_right);
- if(save_right)
- NodeTraits::set_parent(save_right, x);
- if(!moved_to_right)
- new_root = save;
- }
- else{
- moved_to_right = true;
- save = NodeTraits::get_right(x);
- ++len;
- }
- }
-
- if(super_root_is_header){
- NodeTraits::set_right(super_root, super_root_right_backup);
- NodeTraits::set_parent(super_root, new_root);
- }
- else if(old_root_is_right){
- NodeTraits::set_right(super_root, new_root);
- }
- else{
- NodeTraits::set_right(super_root, super_root_right_backup);
- NodeTraits::set_left(super_root, new_root);
- }
- if(plen) *plen = len;
- return new_root;
- }
-
- static node_ptr vine_to_subtree(const node_ptr & old_root, std::size_t count)
- {
- std::size_t leaf_nodes = count + 1 - ((std::size_t) 1 << floor_log2 (count + 1));
- std::size_t vine_nodes = count - leaf_nodes;
-
- node_ptr new_root = compress_subtree(old_root, leaf_nodes);
- while(vine_nodes > 1){
- vine_nodes /= 2;
- new_root = compress_subtree(new_root, vine_nodes);
- }
- return new_root;
- }
-
- static node_ptr compress_subtree(const node_ptr & old_root, std::size_t count)
- {
- if(!old_root) return old_root;
-
- //To avoid irregularities in the algorithm (old_root can be
- //left or right child or even the root of the tree) just put the
- //root as the right child of its parent. First obtain
- //information to restore the original relationship after
- //the algorithm is applied.
- node_ptr super_root = NodeTraits::get_parent(old_root);
- BOOST_INTRUSIVE_INVARIANT_ASSERT(super_root);
-
- //Get info
- node_ptr super_root_right_backup = NodeTraits::get_right(super_root);
- bool super_root_is_header = is_header(super_root);
- bool old_root_is_right = is_right_child(old_root);
-
- //Put old_root as right child
- NodeTraits::set_right(super_root, old_root);
-
- //Start the compression algorithm
- node_ptr even_parent = super_root;
- node_ptr new_root = old_root;
-
- while(count--){
- node_ptr even = NodeTraits::get_right(even_parent);
- node_ptr odd = NodeTraits::get_right(even);
-
- if(new_root == old_root)
- new_root = odd;
-
- node_ptr even_right = NodeTraits::get_left(odd);
- NodeTraits::set_right(even, even_right);
- if (even_right)
- NodeTraits::set_parent(even_right, even);
-
- NodeTraits::set_right(even_parent, odd);
- NodeTraits::set_parent(odd, even_parent);
- NodeTraits::set_left(odd, even);
- NodeTraits::set_parent(even, odd);
- even_parent = odd;
- }
-
- if(super_root_is_header){
- NodeTraits::set_parent(super_root, new_root);
- NodeTraits::set_right(super_root, super_root_right_backup);
- }
- else if(old_root_is_right){
- NodeTraits::set_right(super_root, new_root);
- }
- else{
- NodeTraits::set_left(super_root, new_root);
- NodeTraits::set_right(super_root, super_root_right_backup);
- }
- return new_root;
- }
-
- //! <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_root(const node_ptr & node)
- {
- BOOST_INTRUSIVE_INVARIANT_ASSERT((!inited(node)));
- node_ptr x = NodeTraits::get_parent(node);
- if(x){
- while(!is_header(x)){
- x = NodeTraits::get_parent(x);
- }
- return x;
- }
- else{
- return node;
- }
- }
-
- private:
-
- template<class KeyType, class KeyNodePtrCompare>
- static node_ptr lower_bound_loop
- (node_ptr x, node_ptr y, const KeyType &key, KeyNodePtrCompare comp)
- {
- while(x){
- if(comp(x, key)){
- x = NodeTraits::get_right(x);
- }
- else{
- y = x;
- x = NodeTraits::get_left(x);
- }
- }
- return y;
- }
-
- template<class KeyType, class KeyNodePtrCompare>
- static node_ptr upper_bound_loop
- (node_ptr x, node_ptr y, const KeyType &key, KeyNodePtrCompare comp)
- {
- while(x){
- if(comp(key, x)){
- y = x;
- x = NodeTraits::get_left(x);
- }
- else{
- x = NodeTraits::get_right(x);
- }
- }
- return y;
- }
-
-
- template<class NodePtrCompare>
- static void insert_equal_check_impl
- (bool upper, const node_ptr & h, const node_ptr & new_node, NodePtrCompare comp, insert_commit_data & commit_data, std::size_t *pdepth = 0)
- {
- std::size_t depth = 0;
- node_ptr y(h);
- node_ptr x(NodeTraits::get_parent(y));
- bool link_left;
-
- if(upper){
- while(x){
- ++depth;
- y = x;
- x = comp(new_node, x) ?
- NodeTraits::get_left(x) : NodeTraits::get_right(x);
- }
- link_left = (y == h) || comp(new_node, y);
- }
- else{
- while(x){
- ++depth;
- y = x;
- x = !comp(x, new_node) ?
- NodeTraits::get_left(x) : NodeTraits::get_right(x);
- }
- link_left = (y == h) || !comp(y, new_node);
- }
-
- commit_data.link_left = link_left;
- commit_data.node = y;
- if(pdepth) *pdepth = depth;
- }
-
- static void erase_impl(const node_ptr & header, const node_ptr & z, data_for_rebalance &info)
- {
- node_ptr y(z);
- node_ptr x;
- node_ptr x_parent = node_ptr();
- node_ptr z_left(NodeTraits::get_left(z));
- node_ptr z_right(NodeTraits::get_right(z));
- if(!z_left){
- x = z_right; // x might be null.
- }
- else if(!z_right){ // z has exactly one non-null child. y == z.
- x = z_left; // x is not null.
- }
- else{
- // find z's successor
- y = tree_algorithms::minimum (z_right);
- x = NodeTraits::get_right(y); // x might be null.
- }
-
- if(y != z){
- // relink y in place of z. y is z's successor
- NodeTraits::set_parent(NodeTraits::get_left(z), y);
- NodeTraits::set_left(y, NodeTraits::get_left(z));
- if(y != NodeTraits::get_right(z)){
- x_parent = NodeTraits::get_parent(y);
- if(x)
- NodeTraits::set_parent(x, x_parent);
- NodeTraits::set_left(x_parent, x); // y must be a child of left_
- NodeTraits::set_right(y, NodeTraits::get_right(z));
- NodeTraits::set_parent(NodeTraits::get_right(z), y);
- }
- else
- x_parent = y;
- tree_algorithms::replace_own (z, y, header);
- NodeTraits::set_parent(y, NodeTraits::get_parent(z));
- }
- else { // y == z --> z has only one child, or none
- x_parent = NodeTraits::get_parent(z);
- if(x)
- NodeTraits::set_parent(x, x_parent);
- tree_algorithms::replace_own (z, x, header);
- if(NodeTraits::get_left(header) == z){
- NodeTraits::set_left(header, !NodeTraits::get_right(z) ? // z->get_left() must be null also
- NodeTraits::get_parent(z) : // makes leftmost == header if z == root
- tree_algorithms::minimum (x));
- }
- if(NodeTraits::get_right(header) == z){
- NodeTraits::set_right(header, !NodeTraits::get_left(z) ? // z->get_right() must be null also
- NodeTraits::get_parent(z) : // makes rightmost == header if z == root
- tree_algorithms::maximum(x));
- }
- }
-
- info.x = x;
- info.x_parent = x_parent;
- info.y = y;
- }
-};
-
-} //namespace detail {
-} //namespace intrusive
-} //namespace boost
-
-#include <boost/intrusive/detail/config_end.hpp>
-
-#endif //BOOST_INTRUSIVE_TREE_ALGORITHMS_HPP

Modified: branches/release/boost/intrusive/detail/tree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/tree_node.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/tree_node.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -15,8 +15,11 @@
 
 #include <boost/intrusive/detail/config_begin.hpp>
 #include <iterator>
+#include <boost/intrusive/detail/utilities.hpp>
+#include <boost/intrusive/options.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
 #include <boost/intrusive/detail/mpl.hpp>
+#include <boost/intrusive/bstree_algorithms.hpp>
 
 namespace boost {
 namespace intrusive {
@@ -77,43 +80,42 @@
 
 // tree_iterator provides some basic functions for a
 // node oriented bidirectional iterator:
-template<class Container, bool IsConst>
+template<class RealValueTraits, bool IsConst>
 class tree_iterator
- : public std::iterator
- < std::bidirectional_iterator_tag
- , typename Container::value_type
- , typename Container::difference_type
- , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
- , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
- >
+ : public iiterator<RealValueTraits, IsConst, std::bidirectional_iterator_tag>::iterator_base
 {
    protected:
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename Container::node_algorithms node_algorithms;
- typedef typename real_value_traits::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename pointer_traits<node_ptr>::template
- rebind_pointer<void>::type void_pointer;
- static const bool store_container_ptr =
- detail::store_cont_ptr_on_it<Container>::value;
+ typedef iiterator< RealValueTraits, IsConst
+ , std::bidirectional_iterator_tag> types_t;
+
+ typedef RealValueTraits real_value_traits;
+ typedef typename types_t::node_traits node_traits;
+
+ typedef typename types_t::node node;
+ typedef typename types_t::node_ptr node_ptr;
+ typedef typename types_t::void_pointer void_pointer;
+ static const bool stateful_value_traits = types_t::stateful_value_traits;
+
+ typedef typename pointer_traits
+ <void_pointer>::template rebind_pointer
+ <const real_value_traits>::type const_real_value_traits_ptr;
 
    public:
- typedef typename Container::value_type value_type;
- typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
- typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;
+ typedef typename types_t::value_type value_type;
+ typedef typename types_t::pointer pointer;
+ typedef typename types_t::reference reference;
 
+ typedef bstree_algorithms<node_traits> node_algorithms;
 
    tree_iterator()
- : members_ (node_ptr(), (const void *)0)
    {}
 
- explicit tree_iterator(const node_ptr & nodeptr, const Container *cont_ptr)
- : members_ (nodeptr, cont_ptr)
+ explicit tree_iterator(const node_ptr & nodeptr, const const_real_value_traits_ptr &traits_ptr)
+ : members_(nodeptr, traits_ptr)
    {}
 
- tree_iterator(tree_iterator<Container, false> const& other)
- : members_(other.pointed_node(), other.get_container())
+ tree_iterator(tree_iterator<real_value_traits, false> const& other)
+ : members_(other.pointed_node(), other.get_real_value_traits())
    {}
 
    const node_ptr &pointed_node() const
@@ -161,34 +163,21 @@
    pointer operator->() const
    { return this->get_real_value_traits()->to_value_ptr(members_.nodeptr_); }
 
- const Container *get_container() const
- { return static_cast<const Container*>(members_.get_ptr()); }
-
- const real_value_traits *get_real_value_traits() const
- { return &this->get_container()->get_real_value_traits(); }
+ const_real_value_traits_ptr get_real_value_traits() const
+ {
+ return pointer_traits<const_real_value_traits_ptr>::static_cast_from(members_.get_ptr());
+ }
 
    tree_iterator end_iterator_from_it() const
    {
- return tree_iterator(node_algorithms::get_header(this->pointed_node()), this->get_container());
+ return tree_iterator(node_algorithms::get_header(this->pointed_node()), this->get_real_value_traits());
    }
 
- tree_iterator<Container, false> unconst() const
- { return tree_iterator<Container, false>(this->pointed_node(), this->get_container()); }
+ tree_iterator<real_value_traits, false> unconst() const
+ { return tree_iterator<real_value_traits, false>(this->pointed_node(), this->get_real_value_traits()); }
 
    private:
- struct members
- : public detail::select_constptr
- <void_pointer, store_container_ptr>::type
- {
- typedef typename detail::select_constptr
- <void_pointer, store_container_ptr>::type Base;
-
- members(const node_ptr &n_ptr, const void *cont)
- : Base(cont), nodeptr_(n_ptr)
- {}
-
- node_ptr nodeptr_;
- } members_;
+ iiterator_members<node_ptr, stateful_value_traits> members_;
 };
 
 } //namespace intrusive

Modified: branches/release/boost/intrusive/detail/utilities.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/utilities.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/utilities.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -29,9 +29,36 @@
 #include <boost/cstdint.hpp>
 #include <boost/static_assert.hpp>
 #include <boost/detail/no_exceptions_support.hpp>
+#include <functional>
+#include <boost/functional/hash.hpp>
 
 namespace boost {
 namespace intrusive {
+
+enum algo_types
+{
+ CircularListAlgorithms,
+ CircularSListAlgorithms,
+ LinearSListAlgorithms,
+ BsTreeAlgorithms,
+ RbTreeAlgorithms,
+ AvlTreeAlgorithms,
+ SgTreeAlgorithms,
+ SplayTreeAlgorithms,
+ TreapAlgorithms
+};
+
+template<algo_types AlgoType, class NodeTraits>
+struct get_algo;
+
+template <link_mode_type link_mode>
+struct is_safe_autounlink
+{
+ static const bool value =
+ (int)link_mode == (int)auto_unlink ||
+ (int)link_mode == (int)safe_link;
+};
+
 namespace detail {
 
 template <class T>
@@ -60,17 +87,12 @@
 };\
 //
 
-BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, boost_intrusive_tags::is_base_hook)
+BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_base_hook, hooktags::is_base_hook)
 BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(internal_any_hook, is_any_hook)
 BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(external_value_traits, external_value_traits)
 BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(external_bucket_traits, external_bucket_traits)
 BOOST_INTRUSIVE_INTERNAL_STATIC_BOOL_IS_TRUE(resizable, resizable)
 
-template<class Node, class Tag, link_mode_type LinkMode, int>
-struct node_holder
- : public Node
-{};
-
 template <class T>
 inline T* to_raw_pointer(T* p)
 { return p; }
@@ -114,7 +136,7 @@
    { NodeAlgorithms::init(p); }
 };
 
-template<bool ConstantSize, class SizeType>
+template<bool ConstantSize, class SizeType, class Tag = void>
 struct size_holder
 {
    static const bool constant_time_size = ConstantSize;
@@ -166,17 +188,17 @@
    {}
 };
 
-template<class KeyValueCompare, class Container>
+template<class KeyValueCompare, class RealValueTraits>
 struct key_nodeptr_comp
    : private detail::ebo_functor_holder<KeyValueCompare>
 {
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename Container::value_type value_type;
+ typedef RealValueTraits real_value_traits;
+ typedef typename real_value_traits::value_type value_type;
    typedef typename real_value_traits::node_ptr node_ptr;
    typedef typename real_value_traits::const_node_ptr const_node_ptr;
    typedef detail::ebo_functor_holder<KeyValueCompare> base_t;
- key_nodeptr_comp(KeyValueCompare kcomp, const Container *cont)
- : base_t(kcomp), cont_(cont)
+ key_nodeptr_comp(KeyValueCompare kcomp, const RealValueTraits *traits)
+ : base_t(kcomp), traits_(traits)
    {}
 
    template<class T>
@@ -188,7 +210,7 @@
    template<class T>
    const value_type & key_forward
       (const T &node, typename enable_if_c<is_node_ptr<T>::value>::type * = 0) const
- { return *cont_->get_real_value_traits().to_value_ptr(node); }
+ { return *traits_->to_value_ptr(node); }
 
    template<class T>
    const T & key_forward(const T &key, typename enable_if_c<!is_node_ptr<T>::value>::type* = 0) const
@@ -199,27 +221,28 @@
    bool operator()(const KeyType &key1, const KeyType2 &key2) const
    { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); }
 
- const Container *cont_;
+ const RealValueTraits *traits_;
 };
 
-template<class F, class Container>
+template<class F, class RealValueTraits, algo_types AlgoType>
 struct node_cloner
    : private detail::ebo_functor_holder<F>
 {
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename Container::node_algorithms node_algorithms;
- typedef typename real_value_traits::value_type value_type;
- typedef typename real_value_traits::pointer pointer;
- typedef typename real_value_traits::node_traits::node node;
- typedef typename real_value_traits::node_ptr node_ptr;
+ typedef RealValueTraits real_value_traits;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef detail::ebo_functor_holder<F> base_t;
+ typedef typename get_algo< AlgoType
+ , node_traits>::type node_algorithms;
+ static const bool safemode_or_autounlink =
+ is_safe_autounlink<real_value_traits::link_mode>::value;
+ typedef typename real_value_traits::value_type value_type;
+ typedef typename real_value_traits::pointer pointer;
+ typedef typename node_traits::node node;
    typedef typename real_value_traits::const_node_ptr const_node_ptr;
- typedef detail::ebo_functor_holder<F> base_t;
- enum { safemode_or_autounlink =
- (int)real_value_traits::link_mode == (int)auto_unlink ||
- (int)real_value_traits::link_mode == (int)safe_link };
 
- node_cloner(F f, const Container *cont)
- : base_t(f), cont_(cont)
+ node_cloner(F f, const RealValueTraits *traits)
+ : base_t(f), traits_(traits)
    {}
 
    node_ptr operator()(const node_ptr & p)
@@ -228,50 +251,58 @@
    node_ptr operator()(const node &to_clone)
    {
       const value_type &v =
- *cont_->get_real_value_traits().to_value_ptr
+ *traits_->to_value_ptr
             (pointer_traits<const_node_ptr>::pointer_to(to_clone));
- node_ptr n = cont_->get_real_value_traits().to_node_ptr(*base_t::get()(v));
+ node_ptr n = traits_->to_node_ptr(*base_t::get()(v));
       //Cloned node must be in default mode if the linking mode requires it
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
       return n;
    }
 
- const Container *cont_;
+ const RealValueTraits *traits_;
 };
 
-template<class F, class Container>
+template<class F, class RealValueTraits, algo_types AlgoType>
 struct node_disposer
    : private detail::ebo_functor_holder<F>
 {
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename real_value_traits::node_ptr node_ptr;
+ typedef RealValueTraits real_value_traits;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename node_traits::node_ptr node_ptr;
    typedef detail::ebo_functor_holder<F> base_t;
- typedef typename Container::node_algorithms node_algorithms;
- enum { safemode_or_autounlink =
- (int)real_value_traits::link_mode == (int)auto_unlink ||
- (int)real_value_traits::link_mode == (int)safe_link };
+ typedef typename get_algo< AlgoType
+ , node_traits>::type node_algorithms;
+ static const bool safemode_or_autounlink =
+ is_safe_autounlink<real_value_traits::link_mode>::value;
 
- node_disposer(F f, const Container *cont)
- : base_t(f), cont_(cont)
+ node_disposer(F f, const RealValueTraits *cont)
+ : base_t(f), traits_(cont)
    {}
 
    void operator()(const node_ptr & p)
    {
       if(safemode_or_autounlink)
          node_algorithms::init(p);
- base_t::get()(cont_->get_real_value_traits().to_value_ptr(p));
+ base_t::get()(traits_->to_value_ptr(p));
    }
- const Container *cont_;
+ const RealValueTraits *traits_;
 };
 
+template<class VoidPointer>
 struct dummy_constptr
 {
- dummy_constptr(const void *)
+ typedef typename boost::intrusive::pointer_traits<VoidPointer>::
+ template rebind_pointer<const void>::type ConstVoidPtr;
+
+ explicit dummy_constptr(ConstVoidPtr)
    {}
 
- const void *get_ptr() const
- { return 0; }
+ dummy_constptr()
+ {}
+
+ ConstVoidPtr get_ptr() const
+ { return ConstVoidPtr(); }
 };
 
 template<class VoidPointer>
@@ -280,7 +311,10 @@
    typedef typename boost::intrusive::pointer_traits<VoidPointer>::
       template rebind_pointer<const void>::type ConstVoidPtr;
 
- constptr(const void *ptr)
+ constptr()
+ {}
+
+ explicit constptr(const ConstVoidPtr &ptr)
       : const_void_ptr_(ptr)
    {}
 
@@ -296,7 +330,7 @@
    typedef typename detail::if_c
       < store_ptr
       , constptr<VoidPointer>
- , dummy_constptr
+ , dummy_constptr<VoidPointer>
>::type type;
 };
 
@@ -330,148 +364,6 @@
 void destructor_impl(Hook &, detail::link_dispatch<normal_link>)
 {}
 
-template<class T, class NodeTraits, link_mode_type LinkMode, class Tag, int HookType>
-struct base_hook_traits
-{
- public:
- typedef detail::node_holder
- <typename NodeTraits::node, Tag, LinkMode, HookType> node_holder;
- typedef typename NodeTraits::node node;
- typedef NodeTraits node_traits;
- typedef T value_type;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename node_traits::const_node_ptr const_node_ptr;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<T>::type pointer;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<const T>::type const_pointer;
- //typedef typename pointer_traits<pointer>::reference reference;
- //typedef typename pointer_traits<const_pointer>::reference const_reference;
- typedef T & reference;
- typedef const T & const_reference;
- typedef node_holder & node_holder_reference;
- typedef const node_holder & const_node_holder_reference;
- typedef node& node_reference;
- typedef const node & const_node_reference;
-
- static const link_mode_type link_mode = LinkMode;
-
- static pointer to_value_ptr(const node_ptr & n)
- {
- return pointer_traits<pointer>::pointer_to
- (static_cast<reference>(static_cast<node_holder_reference>(*n)));
- }
-
- static const_pointer to_value_ptr(const const_node_ptr & n)
- {
- return pointer_traits<const_pointer>::pointer_to
- (static_cast<const_reference>(static_cast<const_node_holder_reference>(*n)));
- }
-
- static node_ptr to_node_ptr(reference value)
- {
- return pointer_traits<node_ptr>::pointer_to
- (static_cast<node_reference>(static_cast<node_holder_reference>(value)));
- }
-
- static const_node_ptr to_node_ptr(const_reference value)
- {
- return pointer_traits<const_node_ptr>::pointer_to
- (static_cast<const_node_reference>(static_cast<const_node_holder_reference>(value)));
- }
-};
-
-template<class T, class Hook, Hook T::* P>
-struct member_hook_traits
-{
- public:
- typedef Hook hook_type;
- typedef typename hook_type::boost_intrusive_tags::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef T value_type;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename node_traits::const_node_ptr const_node_ptr;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<T>::type pointer;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<const T>::type const_pointer;
- typedef T & reference;
- typedef const T & const_reference;
- typedef node& node_reference;
- typedef const node & const_node_reference;
- typedef hook_type& hook_reference;
- typedef const hook_type & const_hook_reference;
-
- static const link_mode_type link_mode = Hook::boost_intrusive_tags::link_mode;
-
- static node_ptr to_node_ptr(reference value)
- {
- return pointer_traits<node_ptr>::pointer_to
- (static_cast<node_reference>(static_cast<hook_reference>(value.*P)));
- }
-
- static const_node_ptr to_node_ptr(const_reference value)
- {
- return pointer_traits<const_node_ptr>::pointer_to
- (static_cast<const_node_reference>(static_cast<const_hook_reference>(value.*P)));
- }
-
- static pointer to_value_ptr(const node_ptr & n)
- {
- return pointer_traits<pointer>::pointer_to
- (*detail::parent_from_member<T, Hook>
- (static_cast<Hook*>(boost::intrusive::detail::to_raw_pointer(n)), P));
- }
-
- static const_pointer to_value_ptr(const const_node_ptr & n)
- {
- return pointer_traits<const_pointer>::pointer_to
- (*detail::parent_from_member<T, Hook>
- (static_cast<const Hook*>(boost::intrusive::detail::to_raw_pointer(n)), P));
- }
-};
-
-template<class Functor>
-struct function_hook_traits
-{
- public:
- typedef typename Functor::hook_type hook_type;
- typedef typename Functor::hook_ptr hook_ptr;
- typedef typename Functor::const_hook_ptr const_hook_ptr;
- typedef typename hook_type::boost_intrusive_tags::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename Functor::value_type value_type;
- typedef typename node_traits::node_ptr node_ptr;
- typedef typename node_traits::const_node_ptr const_node_ptr;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<value_type>::type pointer;
- typedef typename pointer_traits<node_ptr>::
- template rebind_pointer<const value_type>::type const_pointer;
- typedef value_type & reference;
- typedef const value_type & const_reference;
- static const link_mode_type link_mode = hook_type::boost_intrusive_tags::link_mode;
-
- static node_ptr to_node_ptr(reference value)
- { return static_cast<node*>(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); }
-
- static const_node_ptr to_node_ptr(const_reference value)
- { return static_cast<const node*>(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); }
-
- static pointer to_value_ptr(const node_ptr & n)
- { return Functor::to_value_ptr(to_hook_ptr(n)); }
-
- static const_pointer to_value_ptr(const const_node_ptr & n)
- { return Functor::to_value_ptr(to_hook_ptr(n)); }
-
- private:
- static hook_ptr to_hook_ptr(const node_ptr & n)
- { return hook_ptr(&*static_cast<hook_type*>(&*n)); }
-
- static const_hook_ptr to_hook_ptr(const const_node_ptr & n)
- { return const_hook_ptr(&*static_cast<const hook_type*>(&*n)); }
-};
-
-
 //This function uses binary search to discover the
 //highest set bit of the integer
 inline std::size_t floor_log2 (std::size_t x)
@@ -492,6 +384,8 @@
    return log2;
 }
 
+//Thanks to Laurent de Soras in
+//http://www.flipcode.com/archives/Fast_log_Function.shtml
 inline float fast_log2 (float val)
 {
    union caster_t
@@ -502,13 +396,15 @@
 
    caster.val = val;
    boost::uint32_t x = caster.x;
- const int log_2 = (int)(((x >> 23) & 255) - 128);
- x &= ~(255 << 23);
- x += 127 << 23;
+ const int log_2 = int((x >> 23) & 255) - 128;
+ x &= ~(boost::uint32_t(255u) << 23u);
+ x += boost::uint32_t(127) << 23u;
    caster.x = x;
    val = caster.val;
+ //1+log2(m), m ranging from 1 to 2
+ //3rd degree polynomial keeping first derivate continuity.
+ //For less precision the line can be commented out
    val = ((-1.0f/3.f) * val + 2.f) * val - (2.0f/3.f);
-
    return (val + log_2);
 }
 
@@ -605,72 +501,47 @@
    }
 };
 
-template<class ValueTraits, bool ExternalValueTraits>
-struct store_cont_ptr_on_it_impl
-{
- static const bool value = is_stateful_value_traits<ValueTraits>::value;
-};
-
-template<class ValueTraits>
-struct store_cont_ptr_on_it_impl<ValueTraits, true>
-{
- static const bool value = true;
-};
-
-template <class Container>
-struct store_cont_ptr_on_it
-{
- typedef typename Container::value_traits value_traits;
- static const bool value = store_cont_ptr_on_it_impl
- <value_traits, external_value_traits_bool_is_true<value_traits>::value>::value;
-};
-
-template<class Container, bool IsConst>
+template<class RealValueTraits, bool IsConst>
 struct node_to_value
    : public detail::select_constptr
       < typename pointer_traits
- <typename Container::pointer>::template rebind_pointer<void>::type
- , detail::store_cont_ptr_on_it<Container>::value
+ <typename RealValueTraits::pointer>::template rebind_pointer<void>::type
+ , is_stateful_value_traits<RealValueTraits>::value
>::type
 {
- static const bool store_container_ptr =
- detail::store_cont_ptr_on_it<Container>::value;
-
- typedef typename Container::real_value_traits real_value_traits;
- typedef typename real_value_traits::value_type value_type;
+ static const bool stateful_value_traits = is_stateful_value_traits<RealValueTraits>::value;
    typedef typename detail::select_constptr
       < typename pointer_traits
- <typename Container::pointer>::template rebind_pointer<void>::type
- , store_container_ptr >::type Base;
- typedef typename real_value_traits::node_traits::node node;
+ <typename RealValueTraits::pointer>::
+ template rebind_pointer<void>::type
+ , stateful_value_traits >::type Base;
+
+ typedef RealValueTraits real_value_traits;
+ typedef typename real_value_traits::value_type value_type;
+ typedef typename real_value_traits::node_traits::node node;
    typedef typename detail::add_const_if_c
- <value_type, IsConst>::type vtype;
+ <value_type, IsConst>::type vtype;
    typedef typename detail::add_const_if_c
- <node, IsConst>::type ntype;
+ <node, IsConst>::type ntype;
    typedef typename pointer_traits
- <typename Container::pointer>::template rebind_pointer<ntype>::type npointer;
+ <typename RealValueTraits::pointer>::
+ template rebind_pointer<ntype>::type npointer;
+ typedef typename pointer_traits<npointer>::
+ template rebind_pointer<const RealValueTraits>::type const_real_value_traits_ptr;
 
- node_to_value(const Container *cont)
- : Base(cont)
+ node_to_value(const const_real_value_traits_ptr &ptr)
+ : Base(ptr)
    {}
 
    typedef vtype & result_type;
    typedef ntype & first_argument_type;
 
- const Container *get_container() const
- {
- if(store_container_ptr)
- return static_cast<const Container*>(Base::get_ptr());
- else
- return 0;
- }
-
- const real_value_traits *get_real_value_traits() const
+ const_real_value_traits_ptr get_real_value_traits() const
    {
- if(store_container_ptr)
- return &this->get_container()->get_real_value_traits();
+ if(stateful_value_traits)
+ return pointer_traits<const_real_value_traits_ptr>::static_cast_from(Base::get_ptr());
       else
- return 0;
+ return const_real_value_traits_ptr();
    }
 
    result_type operator()(first_argument_type arg) const
@@ -849,7 +720,346 @@
         It m_current; // the wrapped iterator
 };
 
+template<class ConstNodePtr>
+struct uncast_types
+{
+ typedef typename pointer_traits<ConstNodePtr>::element_type element_type;
+ typedef typename remove_const<element_type>::type non_const_type;
+ typedef typename pointer_traits<ConstNodePtr>::
+ template rebind_pointer<non_const_type>::type non_const_pointer;
+ typedef pointer_traits<non_const_pointer> non_const_traits;
+};
+
+template<class ConstNodePtr>
+static typename uncast_types<ConstNodePtr>::non_const_pointer
+ uncast(const ConstNodePtr & ptr)
+{
+ return uncast_types<ConstNodePtr>::non_const_traits::const_cast_from(ptr);
+}
+
 } //namespace detail
+
+template<class Node, class Tag, unsigned int>
+struct node_holder
+ : public Node
+{};
+
+template<class T, class NodePtr, class Tag, unsigned int Type>
+struct bhtraits_base
+{
+ public:
+ typedef NodePtr node_ptr;
+ typedef typename pointer_traits<node_ptr>::element_type node;
+ typedef node_holder<node, Tag, Type> node_holder_type;
+ typedef T value_type;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<const node>::type const_node_ptr;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<T>::type pointer;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<const T>::type const_pointer;
+ //typedef typename pointer_traits<pointer>::reference reference;
+ //typedef typename pointer_traits<const_pointer>::reference const_reference;
+ typedef T & reference;
+ typedef const T & const_reference;
+ typedef node_holder_type & node_holder_reference;
+ typedef const node_holder_type & const_node_holder_reference;
+ typedef node& node_reference;
+ typedef const node & const_node_reference;
+
+ static pointer to_value_ptr(const node_ptr & n)
+ {
+ return pointer_traits<pointer>::pointer_to
+ (static_cast<reference>(static_cast<node_holder_reference>(*n)));
+ }
+
+ static const_pointer to_value_ptr(const const_node_ptr & n)
+ {
+ return pointer_traits<const_pointer>::pointer_to
+ (static_cast<const_reference>(static_cast<const_node_holder_reference>(*n)));
+ }
+
+ static node_ptr to_node_ptr(reference value)
+ {
+ return pointer_traits<node_ptr>::pointer_to
+ (static_cast<node_reference>(static_cast<node_holder_reference>(value)));
+ }
+
+ static const_node_ptr to_node_ptr(const_reference value)
+ {
+ return pointer_traits<const_node_ptr>::pointer_to
+ (static_cast<const_node_reference>(static_cast<const_node_holder_reference>(value)));
+ }
+};
+
+template<class T, class NodeTraits, link_mode_type LinkMode, class Tag, unsigned int Type>
+struct bhtraits
+ : public bhtraits_base<T, typename NodeTraits::node_ptr, Tag, Type>
+{
+ static const link_mode_type link_mode = LinkMode;
+ typedef NodeTraits node_traits;
+};
+
+/*
+template<class T, class NodePtr, typename pointer_traits<NodePtr>::element_type T::* P>
+struct mhtraits_base
+{
+ public:
+ typedef typename pointer_traits<NodePtr>::element_type node;
+ typedef T value_type;
+ typedef NodePtr node_ptr;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<const node>::type const_node_ptr;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<T>::type pointer;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<const T>::type const_pointer;
+ typedef T & reference;
+ typedef const T & const_reference;
+ typedef node& node_reference;
+ typedef const node & const_node_reference;
+
+ static node_ptr to_node_ptr(reference value)
+ {
+ return pointer_traits<node_ptr>::pointer_to
+ (static_cast<node_reference>(value.*P));
+ }
+
+ static const_node_ptr to_node_ptr(const_reference value)
+ {
+ return pointer_traits<const_node_ptr>::pointer_to
+ (static_cast<const_node_reference>(value.*P));
+ }
+
+ static pointer to_value_ptr(const node_ptr & n)
+ {
+ return pointer_traits<pointer>::pointer_to
+ (*detail::parent_from_member<T, node>
+ (boost::intrusive::detail::to_raw_pointer(n), P));
+ }
+
+ static const_pointer to_value_ptr(const const_node_ptr & n)
+ {
+ return pointer_traits<const_pointer>::pointer_to
+ (*detail::parent_from_member<T, node>
+ (boost::intrusive::detail::to_raw_pointer(n), P));
+ }
+};
+
+
+template<class T, class NodeTraits, typename NodeTraits::node T::* P, link_mode_type LinkMode>
+struct mhtraits
+ : public mhtraits_base<T, typename NodeTraits::node_ptr, P>
+{
+ static const link_mode_type link_mode = LinkMode;
+ typedef NodeTraits node_traits;
+};
+*/
+
+
+template<class T, class Hook, Hook T::* P>
+struct mhtraits
+{
+ public:
+ typedef Hook hook_type;
+ typedef typename hook_type::hooktags::node_traits node_traits;
+ typedef typename node_traits::node node;
+ typedef T value_type;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::const_node_ptr const_node_ptr;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<T>::type pointer;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<const T>::type const_pointer;
+ typedef T & reference;
+ typedef const T & const_reference;
+ typedef node& node_reference;
+ typedef const node & const_node_reference;
+ typedef hook_type& hook_reference;
+ typedef const hook_type & const_hook_reference;
+
+ static const link_mode_type link_mode = Hook::hooktags::link_mode;
+
+ static node_ptr to_node_ptr(reference value)
+ {
+ return pointer_traits<node_ptr>::pointer_to
+ (static_cast<node_reference>(static_cast<hook_reference>(value.*P)));
+ }
+
+ static const_node_ptr to_node_ptr(const_reference value)
+ {
+ return pointer_traits<const_node_ptr>::pointer_to
+ (static_cast<const_node_reference>(static_cast<const_hook_reference>(value.*P)));
+ }
+
+ static pointer to_value_ptr(const node_ptr & n)
+ {
+ return pointer_traits<pointer>::pointer_to
+ (*detail::parent_from_member<T, Hook>
+ (static_cast<Hook*>(boost::intrusive::detail::to_raw_pointer(n)), P));
+ }
+
+ static const_pointer to_value_ptr(const const_node_ptr & n)
+ {
+ return pointer_traits<const_pointer>::pointer_to
+ (*detail::parent_from_member<T, Hook>
+ (static_cast<const Hook*>(boost::intrusive::detail::to_raw_pointer(n)), P));
+ }
+};
+
+
+template<class Functor>
+struct fhtraits
+{
+ public:
+ typedef typename Functor::hook_type hook_type;
+ typedef typename Functor::hook_ptr hook_ptr;
+ typedef typename Functor::const_hook_ptr const_hook_ptr;
+ typedef typename hook_type::hooktags::node_traits node_traits;
+ typedef typename node_traits::node node;
+ typedef typename Functor::value_type value_type;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::const_node_ptr const_node_ptr;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<value_type>::type pointer;
+ typedef typename pointer_traits<node_ptr>::
+ template rebind_pointer<const value_type>::type const_pointer;
+ typedef value_type & reference;
+ typedef const value_type & const_reference;
+ static const link_mode_type link_mode = hook_type::hooktags::link_mode;
+
+ static node_ptr to_node_ptr(reference value)
+ { return static_cast<node*>(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); }
+
+ static const_node_ptr to_node_ptr(const_reference value)
+ { return static_cast<const node*>(boost::intrusive::detail::to_raw_pointer(Functor::to_hook_ptr(value))); }
+
+ static pointer to_value_ptr(const node_ptr & n)
+ { return Functor::to_value_ptr(to_hook_ptr(n)); }
+
+ static const_pointer to_value_ptr(const const_node_ptr & n)
+ { return Functor::to_value_ptr(to_hook_ptr(n)); }
+
+ private:
+ static hook_ptr to_hook_ptr(const node_ptr & n)
+ { return hook_ptr(&*static_cast<hook_type*>(&*n)); }
+
+ static const_hook_ptr to_hook_ptr(const const_node_ptr & n)
+ { return const_hook_ptr(&*static_cast<const hook_type*>(&*n)); }
+};
+
+template<class RealValueTraits, bool IsConst, class Category>
+struct iiterator
+{
+ typedef RealValueTraits real_value_traits;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename node_traits::node node;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef ::boost::intrusive::pointer_traits<node_ptr> nodepointer_traits_t;
+ typedef typename nodepointer_traits_t::template
+ rebind_pointer<void>::type void_pointer;
+ typedef typename RealValueTraits::value_type value_type;
+ typedef typename RealValueTraits::pointer nonconst_pointer;
+ typedef typename RealValueTraits::const_pointer yesconst_pointer;
+ typedef typename ::boost::intrusive::pointer_traits
+ <nonconst_pointer>::reference nonconst_reference;
+ typedef typename ::boost::intrusive::pointer_traits
+ <yesconst_pointer>::reference yesconst_reference;
+ typedef typename nodepointer_traits_t::difference_type difference_type;
+ typedef typename detail::if_c
+ <IsConst, yesconst_pointer, nonconst_pointer>::type pointer;
+ typedef typename detail::if_c
+ <IsConst, yesconst_reference, nonconst_reference>::type reference;
+ typedef std::iterator
+ < Category
+ , value_type
+ , difference_type
+ , pointer
+ , reference
+ > iterator_base;
+ static const bool stateful_value_traits =
+ detail::is_stateful_value_traits<real_value_traits>::value;
+};
+
+template<class NodePtr, bool StatefulValueTraits = true>
+struct iiterator_members
+{
+ typedef ::boost::intrusive::pointer_traits<NodePtr> pointer_traits_t;
+ typedef typename pointer_traits_t::template
+ rebind_pointer<const void>::type const_void_pointer;
+
+ iiterator_members()
+ {}
+
+ iiterator_members(const NodePtr &n_ptr, const const_void_pointer &data)
+ : nodeptr_(n_ptr), ptr_(data)
+ {}
+
+ const_void_pointer get_ptr() const
+ { return ptr_; }
+
+ NodePtr nodeptr_;
+ const_void_pointer ptr_;
+};
+
+template<class NodePtr>
+struct iiterator_members<NodePtr, false>
+{
+ typedef ::boost::intrusive::pointer_traits<NodePtr> pointer_traits_t;
+ typedef typename pointer_traits_t::template
+ rebind_pointer<const void>::type const_void_pointer;
+
+ iiterator_members()
+ {}
+
+ iiterator_members(const NodePtr &n_ptr, const const_void_pointer &)
+ : nodeptr_(n_ptr)
+ {}
+
+ const_void_pointer get_ptr() const
+ { return const_void_pointer(); }
+
+ NodePtr nodeptr_;
+};
+
+template<class Less, class T>
+struct get_less
+{
+ typedef Less type;
+};
+
+template<class T>
+struct get_less<void, T>
+{
+ typedef ::std::less<T> type;
+};
+
+template<class EqualTo, class T>
+struct get_equal_to
+{
+ typedef EqualTo type;
+};
+
+template<class T>
+struct get_equal_to<void, T>
+{
+ typedef ::std::equal_to<T> type;
+};
+
+template<class Hash, class T>
+struct get_hash
+{
+ typedef Hash type;
+};
+
+template<class T>
+struct get_hash<void, T>
+{
+ typedef ::boost::hash<T> type;
+};
+
+struct empty{};
+
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/detail/workaround.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/workaround.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/detail/workaround.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2005-2013. 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)
 //
@@ -17,6 +17,10 @@
    #define BOOST_INTRUSIVE_PERFECT_FORWARDING
 #endif
 
+//Macros for documentation purposes. For code, expands to the argument
+#define BOOST_INTRUSIVE_IMPDEF(TYPE) TYPE
+#define BOOST_INTRUSIVE_SEEDOC(TYPE) TYPE
+
 #include <boost/intrusive/detail/config_end.hpp>
 
 #endif //#ifndef BOOST_INTRUSIVE_DETAIL_WRKRND_HPP

Modified: branches/release/boost/intrusive/hashtable.hpp
==============================================================================
--- branches/release/boost/intrusive/hashtable.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/hashtable.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -32,12 +32,10 @@
 #include <boost/intrusive/detail/clear_on_destructor_base.hpp>
 #include <boost/intrusive/detail/utilities.hpp>
 //Implementation utilities
-#include <boost/intrusive/trivial_value_traits.hpp>
 #include <boost/intrusive/unordered_set_hook.hpp>
 #include <boost/intrusive/slist.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
 #include <boost/intrusive/detail/mpl.hpp>
-#include <boost/type_traits.hpp>
 #include <boost/move/move.hpp>
 
 namespace boost {
@@ -45,8 +43,6 @@
 
 /// @cond
 
-namespace detail {
-
 struct hash_bool_flags
 {
    static const std::size_t unique_keys_pos = 1u;
@@ -57,99 +53,13 @@
    static const std::size_t incremental_pos = 32u;
 };
 
-template
- < class ValueTraits
- , class Hash
- , class Equal
- , class SizeType
- , class BucketTraits
- , std::size_t BoolFlags
- >
-struct usetopt
-{
- typedef ValueTraits value_traits;
- typedef Hash hash;
- typedef Equal equal;
- typedef SizeType size_type;
- typedef BucketTraits bucket_traits;
- static const std::size_t bool_flags = BoolFlags;
-};
-
-template
- < class UsetOpt
- , std::size_t BoolMask
- >
-struct usetopt_mask
-{
- typedef usetopt
- <typename UsetOpt::value_traits
- ,typename UsetOpt::hash
- ,typename UsetOpt::equal
- ,typename UsetOpt::size_type
- ,typename UsetOpt::bucket_traits
- ,UsetOpt::bool_flags & BoolMask
- > type;
-};
-
-template <class NodeTraits>
-struct hash_reduced_slist_node_traits
-{
- template <class U> static detail::one test(...);
- template <class U> static detail::two test(typename U::reduced_slist_node_traits* = 0);
- static const bool value = sizeof(test<NodeTraits>(0)) == sizeof(detail::two);
-};
-
-template <class NodeTraits>
-struct apply_reduced_slist_node_traits
-{
- typedef typename NodeTraits::reduced_slist_node_traits type;
-};
-
-template <class NodeTraits>
-struct reduced_slist_node_traits
-{
- typedef typename detail::eval_if_c
- < hash_reduced_slist_node_traits<NodeTraits>::value
- , apply_reduced_slist_node_traits<NodeTraits>
- , detail::identity<NodeTraits>
- >::type type;
-};
-
-template<class NodeTraits>
-struct get_slist_impl
-{
- typedef trivial_value_traits<NodeTraits, normal_link> trivial_traits;
-
- //Reducing symbol length
- struct type : make_slist
- < typename NodeTraits::node
- , boost::intrusive::value_traits<trivial_traits>
- , boost::intrusive::constant_time_size<false>
- , boost::intrusive::size_type<typename boost::make_unsigned
- <typename pointer_traits<typename NodeTraits::node_ptr>::difference_type>::type >
- >::type
- {};
-};
-
-template<class SupposedValueTraits>
-struct real_from_supposed_value_traits
-{
- typedef typename detail::eval_if_c
- < detail::external_value_traits_bool_is_true
- <SupposedValueTraits>::value
- , detail::eval_value_traits
- <SupposedValueTraits>
- , detail::identity
- <SupposedValueTraits>
- >::type type;
-};
+namespace detail {
 
 template<class SupposedValueTraits>
 struct get_slist_impl_from_supposed_value_traits
 {
- typedef typename
- real_from_supposed_value_traits
- < SupposedValueTraits>::type real_value_traits;
+ typedef typename detail::get_real_value_traits
+ <SupposedValueTraits>::type real_value_traits;
    typedef typename detail::get_node_traits
       <real_value_traits>::type node_traits;
    typedef typename get_slist_impl
@@ -214,135 +124,19 @@
    static const bool value = optimize_multikey_bool<T>::value > sizeof(one)*2;
 };
 
-template<class Config>
-struct bucket_plus_size
- : public detail::size_holder //size_traits
- < 0 != (Config::bool_flags & hash_bool_flags::constant_time_size_pos)
- , typename Config::size_type>
-{
- typedef detail::size_holder
- < 0 != (Config::bool_flags & hash_bool_flags::constant_time_size_pos)
- , typename Config::size_type> size_traits;
- typedef typename Config::bucket_traits bucket_traits;
-
- template<class BucketTraits>
- bucket_plus_size(BOOST_FWD_REF(BucketTraits) b_traits)
- : bucket_traits_(::boost::forward<BucketTraits>(b_traits))
- {}
-
- bucket_plus_size & operator =(const bucket_plus_size &x)
- {
- this->size_traits::operator=(x);
- bucket_traits_ = x.bucket_traits_;
- return *this;
- }
- bucket_traits bucket_traits_;
-};
-
-template<class Config>
-struct bucket_hash_t
- : public detail::ebo_functor_holder<typename Config::hash> //hash
-{
- typedef typename Config::hash hasher;
- typedef detail::size_holder
- < 0 != (Config::bool_flags & hash_bool_flags::constant_time_size_pos)
- , typename Config::size_type> size_traits;
- typedef typename Config::bucket_traits bucket_traits;
-
- template<class BucketTraits>
- bucket_hash_t(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h)
- : detail::ebo_functor_holder<hasher>(h), bucket_plus_size_(::boost::forward<BucketTraits>(b_traits))
- {}
-
- bucket_plus_size<Config> bucket_plus_size_;
-};
-
-template<class Config, bool>
-struct bucket_hash_equal_t
- : public detail::ebo_functor_holder<typename Config::equal>
-{
- typedef typename Config::equal equal;
- typedef typename Config::hash hasher;
- typedef typename Config::bucket_traits bucket_traits;
-
- template<class BucketTraits>
- bucket_hash_equal_t(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h, const equal &e)
- : detail::ebo_functor_holder<typename Config::equal>(e)//equal()
- , bucket_hash(::boost::forward<BucketTraits>(b_traits), h)
- {}
-
- template<class T>
- void set_cache(T)
- {}
-
- bucket_hash_t<Config> bucket_hash;
-};
-
-template<class Config> //cache_begin == true version
-struct bucket_hash_equal_t<Config, true>
- : public detail::ebo_functor_holder<typename Config::equal>
-{
- typedef typename Config::equal equal;
- typedef typename Config::hash hasher;
- typedef typename Config::bucket_traits bucket_traits;
- typedef typename unordered_bucket_ptr_impl
- <typename Config::value_traits>::type bucket_ptr;
-
- template<class BucketTraits>
- bucket_hash_equal_t(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h, const equal &e)
- : detail::ebo_functor_holder<typename Config::equal>(e) //equal()
- , bucket_hash(::boost::forward<BucketTraits>(b_traits), h)
- {}
-
- void set_cache(const bucket_ptr & c)
- { cached_begin_ = c; }
-
- bucket_hash_t<Config> bucket_hash;
- bucket_ptr cached_begin_;
-};
-
-template<class Config>
-struct hashtable_data_t : public Config::value_traits
-{
- static const std::size_t bool_flags = Config::bool_flags;
- typedef typename Config::value_traits value_traits;
- typedef typename Config::equal equal;
- typedef typename Config::hash hasher;
- typedef typename Config::bucket_traits bucket_traits;
-
- template<class BucketTraits>
- hashtable_data_t( BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h
- , const equal &e, const value_traits &val_traits)
- : Config::value_traits(val_traits) //value_traits
- , internal_(::boost::forward<BucketTraits>(b_traits), h, e)
- {}
- typedef typename detail::usetopt_mask
- < Config
- , detail::hash_bool_flags::constant_time_size_pos
- | detail::hash_bool_flags::incremental_pos
- >::type masked_config_t;
- struct internal
- : public detail::size_holder //split_traits
- < 0 != (Config::bool_flags & hash_bool_flags::incremental_pos)
- , typename Config::size_type>
- {
- template<class BucketTraits>
- internal(BOOST_FWD_REF(BucketTraits) b_traits, const hasher & h, const equal &e)
- : bucket_hash_equal_(::boost::forward<BucketTraits>(b_traits), h, e)
- {}
-
- bucket_hash_equal_t
- < masked_config_t
- , 0 != (bool_flags & hash_bool_flags::cache_begin_pos)
- > bucket_hash_equal_;
- } internal_;
-};
-
 struct insert_commit_data_impl
 {
    std::size_t hash;
 };
 
+template<class Node, class SlistNodePtr>
+inline typename pointer_traits<SlistNodePtr>::template rebind_pointer<Node>::type
+ dcast_bucket_ptr(const SlistNodePtr &p)
+{
+ typedef typename pointer_traits<SlistNodePtr>::template rebind_pointer<Node>::type node_ptr;
+ return pointer_traits<node_ptr>::pointer_to(static_cast<Node&>(*p));
+}
+
 template<class NodeTraits>
 struct group_functions
 {
@@ -356,9 +150,6 @@
    typedef typename reduced_node_traits::node slist_node;
    typedef circular_slist_algorithms<group_traits> group_algorithms;
 
- static node_ptr dcast_bucket_ptr(const slist_node_ptr &p)
- { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*p)); }
-
    static slist_node_ptr get_bucket_before_begin
       (const slist_node_ptr &bucket_beg, const slist_node_ptr &bucket_end, const node_ptr &p)
    {
@@ -384,7 +175,7 @@
       slist_node_ptr possible_end = node_traits::get_next(last_node_group);
 
       while(!(bucket_beg <= possible_end && possible_end <= bucket_end)){
- first_node_of_group = group_functions::dcast_bucket_ptr(possible_end);
+ first_node_of_group = detail::dcast_bucket_ptr<node>(possible_end);
          last_node_group = group_traits::get_next(first_node_of_group);
          possible_end = node_traits::get_next(last_node_group);
       }
@@ -395,7 +186,7 @@
    {
       //Just iterate using group links and obtain the node
       //before "first_in_group)"
- node_ptr prev_node = group_functions::dcast_bucket_ptr(bucket_node);
+ node_ptr prev_node = detail::dcast_bucket_ptr<node>(bucket_node);
       node_ptr nxt(node_traits::get_next(prev_node));
       while(nxt != first_in_group){
          prev_node = group_traits::get_next(nxt);
@@ -480,7 +271,7 @@
       , const slist_node_ptr &first_end_ptr, const slist_node_ptr &last_end_ptr)
    {
       slist_node_ptr prev;
- node_ptr elem(group_functions::dcast_bucket_ptr(i));
+ node_ptr elem(detail::dcast_bucket_ptr<node>(i));
 
       //It's the last in group if the next_node is a bucket
       slist_node_ptr nxt(node_traits::get_next(elem));
@@ -575,6 +366,22 @@
    {}
 };
 
+inline std::size_t hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, detail::false_)
+{ return hash_value % bucket_cnt; }
+
+inline std::size_t hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, detail::true_)
+{ return hash_value & (bucket_cnt - 1); }
+
+template<bool Power2Buckets, bool Incremental>
+inline std::size_t hash_to_bucket_split(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split)
+{
+ std::size_t bucket_number = detail::hash_to_bucket(hash_value, bucket_cnt, detail::bool_<Power2Buckets>());
+ if(Incremental)
+ if(bucket_number >= split)
+ bucket_number -= bucket_cnt/2;
+ return bucket_number;
+}
+
 } //namespace detail {
 
 //!This metafunction will obtain the type of a bucket
@@ -584,7 +391,7 @@
 struct unordered_bucket
    : public detail::unordered_bucket_impl
       <typename ValueTraitsOrHookOption::
- template pack<none>::value_traits
+ template pack<none>::proto_value_traits
>
 {};
 
@@ -595,7 +402,7 @@
 struct unordered_bucket_ptr
    : public detail::unordered_bucket_ptr_impl
          <typename ValueTraitsOrHookOption::
- template pack<none>::value_traits
+ template pack<none>::proto_value_traits
>
 {};
 
@@ -607,7 +414,7 @@
 struct unordered_default_bucket_traits
 {
    typedef typename ValueTraitsOrHookOption::
- template pack<none>::value_traits supposed_value_traits;
+ template pack<none>::proto_value_traits supposed_value_traits;
    typedef typename detail::
       get_slist_impl_from_supposed_value_traits
          <supposed_value_traits>::type slist_impl;
@@ -618,271 +425,821 @@
 
 struct default_bucket_traits;
 
-template <class T>
-struct uset_defaults
- : pack_options
- < none
- , base_hook<detail::default_uset_hook>
- , constant_time_size<true>
- , size_type<std::size_t>
- , equal<std::equal_to<T> >
- , hash<boost::hash<T> >
- , bucket_traits<default_bucket_traits>
- , power_2_buckets<false>
- , cache_begin<false>
- , compare_hash<false>
- , incremental<false>
- >::type
-{};
+struct hashtable_defaults
+{
+ typedef detail::default_hashtable_hook proto_value_traits;
+ typedef std::size_t size_type;
+ typedef void equal;
+ typedef void hash;
+ typedef default_bucket_traits bucket_traits;
+ static const bool constant_time_size = true;
+ static const bool power_2_buckets = false;
+ static const bool cache_begin = false;
+ static const bool compare_hash = false;
+ static const bool incremental = false;
+};
+
+template<class RealValueTraits, bool IsConst>
+struct downcast_node_to_value_t
+ : public detail::node_to_value<RealValueTraits, IsConst>
+{
+ typedef detail::node_to_value<RealValueTraits, IsConst> base_t;
+ typedef typename base_t::result_type result_type;
+ typedef RealValueTraits real_value_traits;
+ typedef typename detail::get_slist_impl
+ <typename detail::reduced_slist_node_traits
+ <typename real_value_traits::node_traits>::type
+ >::type slist_impl;
+ typedef typename detail::add_const_if_c
+ <typename slist_impl::node, IsConst>::type & first_argument_type;
+ typedef typename detail::add_const_if_c
+ < typename RealValueTraits::node_traits::node
+ , IsConst>::type & intermediate_argument_type;
+ typedef typename pointer_traits
+ <typename RealValueTraits::pointer>::
+ template rebind_pointer
+ <const RealValueTraits>::type const_real_value_traits_ptr;
 
-/// @endcond
+ downcast_node_to_value_t(const const_real_value_traits_ptr &ptr)
+ : base_t(ptr)
+ {}
 
-//! The class template hashtable is an intrusive hash table container, that
-//! is used to construct intrusive unordered_set and unordered_multiset containers. The
-//! no-throw guarantee holds only, if the Equal object and Hasher don't throw.
-//!
-//! hashtable is a semi-intrusive container: each object to be stored in the
-//! container must contain a proper hook, but the container also needs
-//! additional auxiliary memory to work: hashtable needs a pointer to an array
-//! of type `bucket_type` to be passed in the constructor. This bucket array must
-//! have at least the same lifetime as the container. This makes the use of
-//! hashtable more complicated than purely intrusive containers.
-//! `bucket_type` is default-constructible, copyable and assignable
-//!
-//! 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<>, \c hash<> and \c equal<>
-//! \c bucket_traits<>, power_2_buckets<>, cache_begin<> and incremental<>.
-//!
-//! hashtable only provides forward iterators but it provides 4 iterator types:
-//! iterator and const_iterator to navigate through the whole container and
-//! local_iterator and const_local_iterator to navigate through the values
-//! stored in a single bucket. Local iterators are faster and smaller.
-//!
-//! It's not recommended to use non constant-time size hashtables because several
-//! key functions, like "empty()", become non-constant time functions. Non
-//! constant_time size hashtables are mainly provided to support auto-unlink hooks.
-//!
-//! hashtables, does not make automatic rehashings nor
-//! offers functions related to a load factor. Rehashing can be explicitly requested
-//! and the user must provide a new bucket array that will be used from that moment.
-//!
-//! Since no automatic rehashing is done, iterators are never invalidated when
-//! inserting or erasing elements. Iterators are only invalidated when rehashing.
-#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
-template<class T, class ...Options>
-#else
-template<class Config>
-#endif
-class hashtable_impl
- : private detail::clear_on_destructor_base<hashtable_impl<Config> >
+ result_type operator()(first_argument_type arg) const
+ { return this->base_t::operator()(static_cast<intermediate_argument_type>(arg)); }
+};
+
+template<class F, class SlistNodePtr, class NodePtr>
+struct node_cast_adaptor
+ : private detail::ebo_functor_holder<F>
 {
- template<class C> friend class detail::clear_on_destructor_base;
- public:
- typedef typename Config::value_traits value_traits;
+ typedef detail::ebo_functor_holder<F> base_t;
+
+ typedef typename pointer_traits<SlistNodePtr>::element_type slist_node;
+ typedef typename pointer_traits<NodePtr>::element_type node;
+
+ template<class ConvertibleToF, class RealValuTraits>
+ node_cast_adaptor(const ConvertibleToF &c2f, const RealValuTraits *traits)
+ : base_t(base_t(c2f, traits))
+ {}
+
+ typename base_t::node_ptr operator()(const slist_node &to_clone)
+ { return base_t::operator()(static_cast<const node &>(to_clone)); }
+
+ void operator()(SlistNodePtr to_clone)
+ {
+ base_t::operator()(pointer_traits<NodePtr>::pointer_to(static_cast<node &>(*to_clone)));
+ }
+};
+
+static const std::size_t hashtable_data_bool_flags_mask =
+ ( hash_bool_flags::cache_begin_pos
+ | hash_bool_flags::constant_time_size_pos
+ | hash_bool_flags::incremental_pos
+ );
+
+template<class ValueTraits, class BucketTraits>
+struct bucket_plus_vtraits : public ValueTraits
+{
+ typedef BucketTraits bucket_traits;
+ typedef ValueTraits value_traits;
+
+ static const bool external_value_traits =
+ detail::external_value_traits_bool_is_true<ValueTraits>::value;
 
- /// @cond
- static const bool external_value_traits =
- detail::external_value_traits_bool_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;
- typedef typename Config::bucket_traits bucket_traits;
    static const bool external_bucket_traits =
       detail::external_bucket_traits_bool_is_true<bucket_traits>::value;
+
+ typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits;
+
+ static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value;
+
    typedef typename detail::eval_if_c
       < external_bucket_traits
       , detail::eval_bucket_traits<bucket_traits>
       , detail::identity<bucket_traits>
>::type real_bucket_traits;
- typedef typename detail::get_slist_impl
- <typename detail::reduced_slist_node_traits
- <typename real_value_traits::node_traits>::type
- >::type slist_impl;
- /// @endcond
+ typedef typename
+ detail::get_slist_impl_from_supposed_value_traits
+ <real_value_traits>::type slist_impl;
 
- typedef typename real_value_traits::pointer pointer;
- typedef typename real_value_traits::const_pointer const_pointer;
- typedef typename real_value_traits::value_type value_type;
- typedef typename pointer_traits<pointer>::reference reference;
- typedef typename pointer_traits<const_pointer>::reference const_reference;
- typedef typename pointer_traits<pointer>::difference_type difference_type;
- typedef typename Config::size_type size_type;
- typedef value_type key_type;
- typedef typename Config::equal key_equal;
- typedef typename Config::hash hasher;
- typedef detail::bucket_impl<slist_impl> bucket_type;
- typedef typename pointer_traits
- <pointer>::template rebind_pointer
- < bucket_type >::type bucket_ptr;
- typedef typename slist_impl::iterator siterator;
- typedef typename slist_impl::const_iterator const_siterator;
- typedef detail::hashtable_iterator<hashtable_impl, false> iterator;
- typedef detail::hashtable_iterator<hashtable_impl, true> const_iterator;
- typedef typename real_value_traits::node_traits node_traits;
- typedef typename node_traits::node node;
- typedef typename pointer_traits
- <pointer>::template rebind_pointer
- < node >::type node_ptr;
- typedef typename pointer_traits
- <pointer>::template rebind_pointer
- < const node >::type const_node_ptr;
- typedef typename slist_impl::node_algorithms node_algorithms;
+ template<class BucketTraitsType>
+ bucket_plus_vtraits(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits)
+ : ValueTraits(val_traits), bucket_traits_(::boost::forward<BucketTraitsType>(b_traits))
+ {}
 
- static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
- static const bool store_hash = detail::store_hash_is_true<node_traits>::value;
+ bucket_plus_vtraits & operator =(const bucket_plus_vtraits &x)
+ {
+ bucket_traits_ = x.bucket_traits_;
+ return *this;
+ }
 
- static const bool unique_keys = 0 != (Config::bool_flags & detail::hash_bool_flags::unique_keys_pos);
- static const bool constant_time_size = 0 != (Config::bool_flags & detail::hash_bool_flags::constant_time_size_pos);
- static const bool cache_begin = 0 != (Config::bool_flags & detail::hash_bool_flags::cache_begin_pos);
- static const bool compare_hash = 0 != (Config::bool_flags & detail::hash_bool_flags::compare_hash_pos);
- static const bool incremental = 0 != (Config::bool_flags & detail::hash_bool_flags::incremental_pos);
- static const bool power_2_buckets = incremental || (0 != (Config::bool_flags & detail::hash_bool_flags::power_2_buckets_pos));
+ //real_value_traits
+ //
+ const real_value_traits &priv_real_value_traits(detail::false_) const
+ { return *this; }
 
- static const bool optimize_multikey
- = detail::optimize_multikey_is_true<node_traits>::value && !unique_keys;
+ const real_value_traits &priv_real_value_traits(detail::true_) const
+ { return this->get_value_traits(*this); }
 
- /// @cond
- private:
+ real_value_traits &priv_real_value_traits(detail::false_)
+ { return *this; }
 
- //Configuration error: compare_hash<> can't be specified without store_hash<>
- //See documentation for more explanations
- BOOST_STATIC_ASSERT((!compare_hash || store_hash));
+ real_value_traits &priv_real_value_traits(detail::true_)
+ { return this->get_value_traits(*this); }
 
- typedef typename slist_impl::node_ptr slist_node_ptr;
- typedef typename pointer_traits
- <slist_node_ptr>::template rebind_pointer
- < void >::type void_pointer;
- //We'll define group traits, but these won't be instantiated if
- //optimize_multikey is not true
- typedef unordered_group_adapter<node_traits> group_traits;
- typedef circular_slist_algorithms<group_traits> group_algorithms;
- typedef detail::bool_<store_hash> store_hash_t;
- typedef detail::bool_<optimize_multikey> optimize_multikey_t;
- typedef detail::bool_<cache_begin> cache_begin_t;
- typedef detail::bool_<power_2_buckets> power_2_buckets_t;
- typedef detail::size_holder<constant_time_size, size_type> size_traits;
- typedef detail::size_holder<incremental, size_type> split_traits;
- typedef detail::group_functions<node_traits> group_functions_t;
- typedef detail::node_functions<node_traits> node_functions_t;
+ const real_value_traits &priv_real_value_traits() const
+ { return this->priv_real_value_traits(detail::bool_<external_value_traits>()); }
 
- static const std::size_t hashtable_data_bool_flags_mask =
- ( detail::hash_bool_flags::cache_begin_pos
- | detail::hash_bool_flags::constant_time_size_pos
- | detail::hash_bool_flags::incremental_pos
- );
- typedef typename detail::usetopt_mask
- <Config, hashtable_data_bool_flags_mask>::type masked_config_t;
- detail::hashtable_data_t<masked_config_t> data_;
-
- template<bool IsConst>
- struct downcast_node_to_value
- : public detail::node_to_value<hashtable_impl, IsConst>
- {
- typedef detail::node_to_value<hashtable_impl, IsConst> base_t;
- typedef typename base_t::result_type result_type;
- typedef typename detail::add_const_if_c
- <typename slist_impl::node, IsConst>::type &first_argument_type;
- typedef typename detail::add_const_if_c
- <node, IsConst>::type &intermediate_argument_type;
-
- downcast_node_to_value(const hashtable_impl *cont)
- : base_t(cont)
- {}
-
- result_type operator()(first_argument_type arg) const
- { return this->base_t::operator()(static_cast<intermediate_argument_type>(arg)); }
- };
-
- template<class F>
- struct node_cast_adaptor
- : private detail::ebo_functor_holder<F>
- {
- typedef detail::ebo_functor_holder<F> base_t;
-
- template<class ConvertibleToF>
- node_cast_adaptor(const ConvertibleToF &c2f, const hashtable_impl *cont)
- : base_t(base_t(c2f, cont))
- {}
+ real_value_traits &priv_real_value_traits()
+ { return this->priv_real_value_traits(detail::bool_<external_value_traits>()); }
 
- typename base_t::node_ptr operator()(const typename slist_impl::node &to_clone)
- { return base_t::operator()(static_cast<const node &>(to_clone)); }
+ typedef typename pointer_traits<typename real_value_traits::pointer>::
+ template rebind_pointer<const real_value_traits>::type const_real_value_traits_ptr;
 
- void operator()(typename slist_impl::node_ptr to_clone)
- {
- base_t::operator()(pointer_traits<node_ptr>::pointer_to(static_cast<node &>(*to_clone)));
- }
- };
+ const_real_value_traits_ptr real_value_traits_ptr() const
+ { return pointer_traits<const_real_value_traits_ptr>::pointer_to(this->priv_real_value_traits()); }
 
- private:
- //noncopyable, movable
- BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable_impl)
+ //real_bucket_traits
+ //
+ const real_bucket_traits &priv_real_bucket_traits(detail::false_) const
+ { return this->bucket_traits_; }
 
- enum { safemode_or_autounlink =
- (int)real_value_traits::link_mode == (int)auto_unlink ||
- (int)real_value_traits::link_mode == (int)safe_link };
+ const real_bucket_traits &priv_real_bucket_traits(detail::true_) const
+ { return this->bucket_traits_.get_bucket_traits(*this); }
 
- //Constant-time size is incompatible with auto-unlink hooks!
- BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
- //Cache begin is incompatible with auto-unlink hooks!
- BOOST_STATIC_ASSERT(!(cache_begin && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+ real_bucket_traits &priv_real_bucket_traits(detail::false_)
+ { return bucket_traits_; }
 
- template<class Disposer>
- node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> >
- make_node_disposer(const Disposer &disposer) const
- { return node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> >(disposer, this); }
+ real_bucket_traits &priv_real_bucket_traits(detail::true_)
+ { return this->get_bucket_traits(*this); }
 
- /// @endcond
+ const real_bucket_traits &priv_real_bucket_traits() const
+ { return this->priv_real_bucket_traits(detail::bool_<external_bucket_traits>()); }
 
- public:
- typedef detail::insert_commit_data_impl insert_commit_data;
+ real_bucket_traits &priv_real_bucket_traits()
+ { return this->priv_real_bucket_traits(detail::bool_<external_bucket_traits>()); }
 
- typedef detail::transform_iterator
- < typename slist_impl::iterator
- , downcast_node_to_value<false> > local_iterator;
+ //bucket_value_traits
+ //
+ const bucket_plus_vtraits &get_bucket_value_traits() const
+ { return *this; }
+
+ bucket_plus_vtraits &get_bucket_value_traits()
+ { return *this; }
 
- typedef detail::transform_iterator
- < typename slist_impl::iterator
- , downcast_node_to_value<true> > const_local_iterator;
+ typedef typename pointer_traits<typename real_value_traits::pointer>::
+ template rebind_pointer<const bucket_plus_vtraits>::type const_bucket_value_traits_ptr;
 
- /// @cond
+ const_bucket_value_traits_ptr bucket_value_traits_ptr() const
+ { return pointer_traits<const_bucket_value_traits_ptr>::pointer_to(this->get_bucket_value_traits()); }
 
- const real_value_traits &get_real_value_traits(detail::false_) const
- { return this->data_; }
+ //value traits
+ //
+ const value_traits &priv_value_traits() const
+ { return *this; }
 
- const real_value_traits &get_real_value_traits(detail::true_) const
- { return data_.get_value_traits(*this); }
+ value_traits &priv_value_traits()
+ { return *this; }
 
- real_value_traits &get_real_value_traits(detail::false_)
- { return this->data_; }
+ //bucket_traits
+ //
+ const bucket_traits &priv_bucket_traits() const
+ { return this->bucket_traits_; }
 
- real_value_traits &get_real_value_traits(detail::true_)
- { return data_.get_value_traits(*this); }
+ bucket_traits &priv_bucket_traits()
+ { return this->bucket_traits_; }
 
- /// @endcond
+ //operations
+ typedef typename detail::unordered_bucket_ptr_impl<real_value_traits>::type bucket_ptr;
 
- public:
+ bucket_ptr priv_bucket_pointer() const
+ { return this->priv_real_bucket_traits().bucket_begin(); }
 
- const real_value_traits &get_real_value_traits() const
- { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+ typename slist_impl::size_type priv_bucket_count() const
+ { return this->priv_real_bucket_traits().bucket_count(); }
 
- real_value_traits &get_real_value_traits()
- { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+ bucket_ptr priv_invalid_bucket() const
+ {
+ const real_bucket_traits &rbt = this->priv_real_bucket_traits();
+ return rbt.bucket_begin() + rbt.bucket_count();
+ }
 
- //! <b>Requires</b>: buckets must not be being used by any other resource.
- //!
- //! <b>Effects</b>: Constructs an empty unordered_set, storing a reference
- //! to the bucket array and copies of the key_hasher and equal_func functors.
- //!
- //! <b>Complexity</b>: Constant.
- //!
- //! <b>Throws</b>: If value_traits::node_traits::node
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef unordered_group_adapter<node_traits> group_traits;
+ typedef typename slist_impl::iterator siterator;
+ typedef typename slist_impl::size_type size_type;
+ typedef detail::bucket_impl<slist_impl> bucket_type;
+ typedef detail::group_functions<node_traits> group_functions_t;
+ typedef typename slist_impl::node_algorithms node_algorithms;
+ typedef typename slist_impl::node_ptr slist_node_ptr;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::node node;
+ typedef typename real_value_traits::value_type value_type;
+ typedef circular_slist_algorithms<group_traits> group_algorithms;
+
+
+/*
+ siterator priv_invalid_local_it() const
+ { return this->priv_invalid_bucket()->end(); }
+*/
+ siterator priv_invalid_local_it() const
+ {
+ return this->priv_real_bucket_traits().bucket_begin()->before_begin();
+ }
+
+ ///
+ static siterator priv_get_last(bucket_type &b, detail::true_) //optimize multikey
+ {
+ //First find the last node of p's group.
+ //This requires checking the first node of the next group or
+ //the bucket node.
+ slist_node_ptr end_ptr(b.end().pointed_node());
+ node_ptr possible_end(node_traits::get_next( detail::dcast_bucket_ptr<node>(end_ptr)));
+ node_ptr last_node_group(possible_end);
+
+ while(end_ptr != possible_end){
+ last_node_group = group_traits::get_next(detail::dcast_bucket_ptr<node>(possible_end));
+ possible_end = node_traits::get_next(last_node_group);
+ }
+ return bucket_type::s_iterator_to(*last_node_group);
+ }
+
+ static siterator priv_get_last(bucket_type &b, detail::false_) //NOT optimize multikey
+ { return b.previous(b.end()); }
+
+ static siterator priv_get_previous(bucket_type &b, siterator i, detail::true_) //optimize multikey
+ {
+ node_ptr elem(detail::dcast_bucket_ptr<node>(i.pointed_node()));
+ node_ptr prev_in_group(group_traits::get_next(elem));
+ bool first_in_group = node_traits::get_next(prev_in_group) != elem;
+ typename bucket_type::node &n = first_in_group
+ ? *group_functions_t::get_prev_to_first_in_group(b.end().pointed_node(), elem)
+ : *group_traits::get_next(elem)
+ ;
+ return bucket_type::s_iterator_to(n);
+ }
+
+ static siterator priv_get_previous(bucket_type &b, siterator i, detail::false_) //NOT optimize multikey
+ { return b.previous(i); }
+
+ static void priv_clear_group_nodes(bucket_type &b, detail::true_) //optimize multikey
+ {
+ siterator it(b.begin()), itend(b.end());
+ while(it != itend){
+ node_ptr to_erase(detail::dcast_bucket_ptr<node>(it.pointed_node()));
+ ++it;
+ group_algorithms::init(to_erase);
+ }
+ }
+
+ static void priv_clear_group_nodes(bucket_type &, detail::false_) //NOT optimize multikey
+ {}
+
+ std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_) //optimize multikey
+ {
+ const bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
+ slist_node_ptr bb = group_functions_t::get_bucket_before_begin
+ ( f->end().pointed_node()
+ , l->end().pointed_node()
+ , detail::dcast_bucket_ptr<node>(it.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(bucket_type::s_iterator_to(*bb)));
+ //Now just calculate the index b has in the bucket array
+ return static_cast<size_type>(&b - &*f);
+ }
+
+ std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_) //NO optimize multikey
+ {
+ bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
+ slist_node_ptr first_ptr(f->cend().pointed_node())
+ , last_ptr(l->cend().pointed_node());
+
+ //The end node is embedded in the singly linked list:
+ //iterate until we reach it.
+ while(!(first_ptr <= it.pointed_node() && it.pointed_node() <= last_ptr)){
+ ++it;
+ }
+ //Now get the bucket_impl from the iterator
+ const bucket_type &b = static_cast<const bucket_type&>
+ (bucket_type::container_from_end_iterator(it));
+
+ //Now just calculate the index b has in the bucket array
+ return static_cast<std::size_t>(&b - &*f);
+ }
+
+ static std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) //store_hash
+ { return node_traits::get_hash(detail::dcast_bucket_ptr<node>(n)); }
+
+ static std::size_t priv_stored_hash(slist_node_ptr, detail::false_) //NO store_hash
+ {
+ //This code should never be reached!
+ BOOST_INTRUSIVE_INVARIANT_ASSERT(0);
+ return 0;
+ }
+
+ node &priv_value_to_node(value_type &v)
+ { return *this->priv_real_value_traits().to_node_ptr(v); }
+
+ const node &priv_value_to_node(const value_type &v) const
+ { return *this->priv_real_value_traits().to_node_ptr(v); }
+
+ value_type &priv_value_from_slist_node(slist_node_ptr n)
+ { return *this->priv_real_value_traits().to_value_ptr(detail::dcast_bucket_ptr<node>(n)); }
+
+ const value_type &priv_value_from_slist_node(slist_node_ptr n) const
+ { return *this->priv_real_value_traits().to_value_ptr(detail::dcast_bucket_ptr<node>(n)); }
+
+ bucket_traits bucket_traits_;
+};
+
+template<class VoidOrKeyHash, class ValueTraits, class BucketTraits>
+struct bucket_hash_t
+ : public detail::ebo_functor_holder
+ <typename get_hash< VoidOrKeyHash
+ , typename bucket_plus_vtraits<ValueTraits,BucketTraits>::real_value_traits::value_type
+ >::type
+ >
+ , bucket_plus_vtraits<ValueTraits, BucketTraits>
+{
+ typedef typename bucket_plus_vtraits<ValueTraits,BucketTraits>::real_value_traits real_value_traits;
+ typedef typename real_value_traits::value_type value_type;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename get_hash< VoidOrKeyHash, value_type>::type hasher;
+ typedef BucketTraits bucket_traits;
+ typedef bucket_plus_vtraits<ValueTraits, BucketTraits> bucket_plus_vtraits_t;
+
+ template<class BucketTraitsType>
+ bucket_hash_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h)
+ : detail::ebo_functor_holder<hasher>(h), bucket_plus_vtraits_t(val_traits, ::boost::forward<BucketTraitsType>(b_traits))
+ {}
+
+ const hasher &priv_hasher() const
+ { return this->detail::ebo_functor_holder<hasher>::get(); }
+
+ hasher &priv_hasher()
+ { return this->detail::ebo_functor_holder<hasher>::get(); }
+
+ std::size_t priv_stored_or_compute_hash(const value_type &v, detail::true_) const //For store_hash == true
+ { return node_traits::get_hash(this->priv_real_value_traits().to_node_ptr(v)); }
+
+ std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const //For store_hash == false
+ { return this->priv_hasher()(v); }
+};
+
+template<class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits, bool>
+struct bucket_hash_equal_t
+ : public detail::ebo_functor_holder //equal
+ <typename get_equal_to< VoidOrKeyEqual
+ , typename bucket_plus_vtraits<ValueTraits,BucketTraits>::real_value_traits::value_type
+ >::type
+ >
+ , bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits>
+{
+ typedef bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> bucket_hash_type;
+ typedef typename bucket_plus_vtraits<ValueTraits,BucketTraits>::real_value_traits real_value_traits;
+ typedef typename get_equal_to< VoidOrKeyEqual
+ , typename real_value_traits::value_type
+ >::type value_equal;
+ typedef typename bucket_hash_type::hasher hasher;
+ typedef BucketTraits bucket_traits;
+ typedef bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> buckethash_t;
+ typedef typename bucket_hash_type::real_bucket_traits real_bucket_traits;
+ typedef typename bucket_hash_type::slist_impl slist_impl;
+ typedef typename slist_impl::size_type size_type;
+ typedef typename slist_impl::iterator siterator;
+ typedef detail::bucket_impl<slist_impl> bucket_type;
+ typedef typename detail::unordered_bucket_ptr_impl<real_value_traits>::type bucket_ptr;
+
+ template<class BucketTraitsType>
+ bucket_hash_equal_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e)
+ : detail::ebo_functor_holder<value_equal>(e)
+ , buckethash_t(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h)
+ {}
+
+ bucket_ptr priv_get_cache()
+ { return this->priv_bucket_pointer(); }
+
+ void priv_set_cache(const bucket_ptr &)
+ {}
+
+ size_type priv_get_cache_bucket_num()
+ { return 0u; }
+
+ void priv_initialize_cache()
+ {}
+
+ void priv_swap_cache(bucket_hash_equal_t &)
+ {}
+
+ siterator priv_begin() const
+ {
+ size_type n = 0;
+ size_type bucket_cnt = this->priv_bucket_count();
+ for (n = 0; n < bucket_cnt; ++n){
+ bucket_type &b = this->priv_bucket_pointer()[n];
+ if(!b.empty()){
+ return b.begin();
+ }
+ }
+ return this->priv_invalid_local_it();
+ }
+
+ void priv_insertion_update_cache(size_type)
+ {}
+
+ void priv_erasure_update_cache_range(size_type, size_type)
+ {}
+
+ void priv_erasure_update_cache()
+ {}
+
+ const value_equal &priv_equal() const
+ { return this->detail::ebo_functor_holder<value_equal>::get(); }
+
+ value_equal &priv_equal()
+ { return this->detail::ebo_functor_holder<value_equal>::get(); }
+};
+
+template<class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits> //cache_begin == true version
+struct bucket_hash_equal_t<VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits, true>
+ : public detail::ebo_functor_holder //equal
+ <typename get_equal_to< VoidOrKeyEqual
+ , typename bucket_plus_vtraits<ValueTraits,BucketTraits>::real_value_traits::value_type
+ >::type
+ >
+ , public bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits>
+{
+ typedef bucket_hash_t<VoidOrKeyHash, ValueTraits, BucketTraits> bucket_hash_type;
+ typedef typename get_equal_to< VoidOrKeyEqual
+ , typename bucket_plus_vtraits<ValueTraits,BucketTraits>::real_value_traits::value_type
+ >::type value_equal;
+ typedef typename bucket_hash_type::hasher hasher;
+ typedef BucketTraits bucket_traits;
+ typedef typename bucket_hash_type::slist_impl::size_type size_type;
+ typedef typename bucket_hash_type::slist_impl::iterator siterator;
+
+ template<class BucketTraitsType>
+ bucket_hash_equal_t(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e)
+ : detail::ebo_functor_holder<value_equal>(e)
+ , bucket_hash_type(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h)
+ {}
+
+ typedef typename detail::unordered_bucket_ptr_impl
+ <typename bucket_hash_type::real_value_traits>::type bucket_ptr;
+
+ bucket_ptr &priv_get_cache()
+ { return cached_begin_; }
+
+ const bucket_ptr &priv_get_cache() const
+ { return cached_begin_; }
+
+ void priv_set_cache(const bucket_ptr &p)
+ { cached_begin_ = p; }
+
+ std::size_t priv_get_cache_bucket_num()
+ { return this->cached_begin_ - this->priv_bucket_pointer(); }
+
+ void priv_initialize_cache()
+ { this->cached_begin_ = this->priv_invalid_bucket(); }
+
+ void priv_swap_cache(bucket_hash_equal_t &other)
+ {
+ std::swap(this->cached_begin_, other.cached_begin_);
+ }
+
+ siterator priv_begin() const
+ {
+ if(this->cached_begin_ == this->priv_invalid_bucket()){
+ return this->priv_invalid_local_it();
+ }
+ else{
+ return this->cached_begin_->begin();
+ }
+ }
+
+ void priv_insertion_update_cache(size_type insertion_bucket)
+ {
+ bucket_ptr p = this->priv_bucket_pointer() + insertion_bucket;
+ if(p < this->cached_begin_){
+ this->cached_begin_ = p;
+ }
+ }
+
+ const value_equal &priv_equal() const
+ { return this->detail::ebo_functor_holder<value_equal>::get(); }
+
+ value_equal &priv_equal()
+ { return this->detail::ebo_functor_holder<value_equal>::get(); }
+
+ void priv_erasure_update_cache_range(size_type first_bucket_num, size_type last_bucket_num)
+ {
+ //If the last bucket is the end, the cache must be updated
+ //to the last position if all
+ if(this->priv_get_cache_bucket_num() == first_bucket_num &&
+ this->priv_bucket_pointer()[first_bucket_num].empty() ){
+ this->priv_set_cache(this->priv_bucket_pointer() + last_bucket_num);
+ this->priv_erasure_update_cache();
+ }
+ }
+
+ void priv_erasure_update_cache()
+ {
+ if(this->cached_begin_ != this->priv_invalid_bucket()){
+ size_type current_n = this->priv_get_cache() - this->priv_bucket_pointer();
+ for( const size_type num_buckets = this->priv_bucket_count()
+ ; current_n < num_buckets
+ ; ++current_n, ++this->priv_get_cache()){
+ if(!this->priv_get_cache()->empty()){
+ return;
+ }
+ }
+ this->priv_initialize_cache();
+ }
+ }
+
+ private:
+ bucket_ptr cached_begin_;
+};
+
+template<class SizeType, std::size_t BoolFlags, class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits>
+struct hashdata_internal
+ : public detail::size_holder< 0 != (BoolFlags & hash_bool_flags::incremental_pos), SizeType, int> //split_traits
+ , public bucket_hash_equal_t
+ < VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits
+ , 0 != (BoolFlags & hash_bool_flags::cache_begin_pos)
+ >
+{
+ typedef bucket_hash_equal_t
+ < VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits
+ , 0 != (BoolFlags & hash_bool_flags::cache_begin_pos)
+ > bucket_hash_equal_type;
+
+ typedef typename bucket_hash_equal_type::value_equal value_equal;
+ typedef typename bucket_hash_equal_type::hasher hasher;
+ typedef bucket_plus_vtraits<ValueTraits,BucketTraits> bucket_plus_vtraits_t;
+ typedef typename bucket_plus_vtraits_t::size_type size_type;
+ typedef typename bucket_plus_vtraits_t::bucket_ptr bucket_ptr;
+ static const bool optimize_multikey
+ = detail::optimize_multikey_is_true<typename bucket_plus_vtraits_t::real_value_traits::node_traits>::value;
+
+ typedef detail::bool_<optimize_multikey> optimize_multikey_t;
+
+ template<class BucketTraitsType>
+ hashdata_internal(const ValueTraits &val_traits, BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h, const value_equal &e)
+ : bucket_hash_equal_type(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h, e)
+ {}
+
+ typedef detail::size_holder
+ <0 != (BoolFlags & hash_bool_flags::incremental_pos), SizeType, int> split_traits;
+
+ split_traits &priv_split_traits()
+ { return *this; }
+
+ const split_traits &priv_split_traits() const
+ { return *this; }
+};
+
+template<class SizeType, std::size_t BoolFlags, class VoidOrKeyHash, class VoidOrKeyEqual, class ValueTraits, class BucketTraits>
+struct hashtable_data_t
+ : public detail::size_holder< 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos), SizeType> //size_traits
+ , public hashdata_internal
+ < SizeType, BoolFlags & (hash_bool_flags::incremental_pos | hash_bool_flags::cache_begin_pos)
+ , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits>
+{
+ static const std::size_t bool_flags = BoolFlags;
+ typedef detail::size_holder
+ < 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos)
+ , SizeType> size_traits;
+
+ typedef hashdata_internal
+ < SizeType, BoolFlags & (hash_bool_flags::incremental_pos | hash_bool_flags::cache_begin_pos)
+ , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits> internal_type;
+
+ typedef ValueTraits value_traits;
+ typedef typename internal_type::value_equal value_equal;
+ typedef typename internal_type::hasher hasher;
+ typedef BucketTraits bucket_traits;
+ typedef bucket_plus_vtraits
+ <ValueTraits,BucketTraits> bucket_plus_vtraits_t;
+
+ static const bool external_value_traits =
+ detail::external_value_traits_bool_is_true<ValueTraits>::value;
+ static const bool external_bucket_traits = bucket_plus_vtraits_t::external_bucket_traits;
+
+ typedef typename bucket_plus_vtraits_t::real_value_traits real_value_traits;
+ typedef typename bucket_plus_vtraits_t::real_bucket_traits real_bucket_traits;
+
+ size_traits &priv_size_traits()
+ { return *this; }
+
+ const size_traits &priv_size_traits() const
+ { return *this; }
+
+ template<class BucketTraitsType>
+ hashtable_data_t( BOOST_FWD_REF(BucketTraitsType) b_traits, const hasher & h
+ , const value_equal &e, const value_traits &val_traits)
+ : size_traits()
+ , internal_type(val_traits, ::boost::forward<BucketTraitsType>(b_traits), h, e)
+ {}
+};
+
+/// @endcond
+
+//! The class template hashtable is an intrusive hash table container, that
+//! is used to construct intrusive unordered_set and unordered_multiset containers. The
+//! no-throw guarantee holds only, if the VoidOrKeyEqual object and Hasher don't throw.
+//!
+//! hashtable is a semi-intrusive container: each object to be stored in the
+//! container must contain a proper hook, but the container also needs
+//! additional auxiliary memory to work: hashtable needs a pointer to an array
+//! of type `bucket_type` to be passed in the constructor. This bucket array must
+//! have at least the same lifetime as the container. This makes the use of
+//! hashtable more complicated than purely intrusive containers.
+//! `bucket_type` is default-constructible, copyable and assignable
+//!
+//! 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<>, \c hash<> and \c equal<>
+//! \c bucket_traits<>, power_2_buckets<>, cache_begin<> and incremental<>.
+//!
+//! hashtable only provides forward iterators but it provides 4 iterator types:
+//! iterator and const_iterator to navigate through the whole container and
+//! local_iterator and const_local_iterator to navigate through the values
+//! stored in a single bucket. Local iterators are faster and smaller.
+//!
+//! It's not recommended to use non constant-time size hashtables because several
+//! key functions, like "empty()", become non-constant time functions. Non
+//! constant_time size hashtables are mainly provided to support auto-unlink hooks.
+//!
+//! hashtables, does not make automatic rehashings nor
+//! offers functions related to a load factor. Rehashing can be explicitly requested
+//! and the user must provide a new bucket array that will be used from that moment.
+//!
+//! Since no automatic rehashing is done, iterators are never invalidated when
+//! inserting or erasing elements. Iterators are only invalidated when rehashing.
+#if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+template<class T, class ...Options>
+#else
+template<class ValueTraits, class VoidOrKeyHash, class VoidOrKeyEqual, class SizeType, class BucketTraits, std::size_t BoolFlags>
+#endif
+class hashtable_impl
+ : public hashtable_data_t
+ < SizeType
+ , BoolFlags & hashtable_data_bool_flags_mask
+ , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits>
+ , private detail::clear_on_destructor_base
+ < hashtable_impl<ValueTraits, VoidOrKeyHash, VoidOrKeyEqual, SizeType, BucketTraits, BoolFlags>
+ , true //To always clear the bucket array
+ //is_safe_autounlink<detail::get_real_value_traits<ValueTraits>::type::link_mode>::value
+ >
+{
+ template<class C, bool> friend class detail::clear_on_destructor_base;
+ public:
+ typedef ValueTraits value_traits;
+
+ typedef hashtable_data_t
+ < SizeType
+ , BoolFlags & hashtable_data_bool_flags_mask
+ , VoidOrKeyHash, VoidOrKeyEqual, ValueTraits, BucketTraits> data_type;
+
+ /// @cond
+ static const bool external_value_traits = data_type::external_value_traits;
+ static const bool external_bucket_traits = data_type::external_bucket_traits;
+
+ typedef BucketTraits bucket_traits;
+ typedef typename data_type::real_bucket_traits real_bucket_traits;
+ typedef typename data_type::real_value_traits real_value_traits;
+
+
+ typedef typename detail::get_slist_impl
+ <typename detail::reduced_slist_node_traits
+ <typename real_value_traits::node_traits>::type
+ >::type slist_impl;
+ typedef bucket_plus_vtraits<ValueTraits, BucketTraits> bucket_plus_vtraits_t;
+ typedef typename bucket_plus_vtraits_t::const_real_value_traits_ptr const_real_value_traits_ptr;
+
+
+ /// @endcond
+
+ typedef typename real_value_traits::pointer pointer;
+ typedef typename real_value_traits::const_pointer const_pointer;
+ typedef typename real_value_traits::value_type value_type;
+ typedef typename pointer_traits<pointer>::reference reference;
+ typedef typename pointer_traits<const_pointer>::reference const_reference;
+ typedef typename pointer_traits<pointer>::difference_type difference_type;
+ typedef SizeType size_type;
+ typedef value_type key_type;
+ typedef typename data_type::value_equal key_equal;
+ typedef typename data_type::hasher hasher;
+ typedef detail::bucket_impl<slist_impl> bucket_type;
+ typedef typename pointer_traits
+ <pointer>::template rebind_pointer
+ < bucket_type >::type bucket_ptr;
+ typedef typename slist_impl::iterator siterator;
+ typedef typename slist_impl::const_iterator const_siterator;
+ typedef hashtable_iterator<bucket_plus_vtraits_t, false> iterator;
+ typedef hashtable_iterator<bucket_plus_vtraits_t, true> const_iterator;
+ typedef typename real_value_traits::node_traits node_traits;
+ typedef typename node_traits::node node;
+ typedef typename pointer_traits
+ <pointer>::template rebind_pointer
+ < node >::type node_ptr;
+ typedef typename pointer_traits
+ <pointer>::template rebind_pointer
+ < const node >::type const_node_ptr;
+ typedef typename slist_impl::node_algorithms node_algorithms;
+
+ static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
+ static const bool store_hash = detail::store_hash_is_true<node_traits>::value;
+
+ static const bool unique_keys = 0 != (BoolFlags & hash_bool_flags::unique_keys_pos);
+ static const bool constant_time_size = 0 != (BoolFlags & hash_bool_flags::constant_time_size_pos);
+ static const bool cache_begin = 0 != (BoolFlags & hash_bool_flags::cache_begin_pos);
+ static const bool compare_hash = 0 != (BoolFlags & hash_bool_flags::compare_hash_pos);
+ static const bool incremental = 0 != (BoolFlags & hash_bool_flags::incremental_pos);
+ static const bool power_2_buckets = incremental || (0 != (BoolFlags & hash_bool_flags::power_2_buckets_pos));
+
+ static const bool optimize_multikey
+ = detail::optimize_multikey_is_true<node_traits>::value && !unique_keys;
+
+ /// @cond
+ private:
+
+ //Configuration error: compare_hash<> can't be specified without store_hash<>
+ //See documentation for more explanations
+ BOOST_STATIC_ASSERT((!compare_hash || store_hash));
+
+ typedef typename slist_impl::node_ptr slist_node_ptr;
+ typedef typename pointer_traits
+ <slist_node_ptr>::template rebind_pointer
+ < void >::type void_pointer;
+ //We'll define group traits, but these won't be instantiated if
+ //optimize_multikey is not true
+ typedef unordered_group_adapter<node_traits> group_traits;
+ typedef circular_slist_algorithms<group_traits> group_algorithms;
+ typedef detail::bool_<store_hash> store_hash_t;
+ typedef detail::bool_<optimize_multikey> optimize_multikey_t;
+ typedef detail::bool_<cache_begin> cache_begin_t;
+ typedef detail::bool_<power_2_buckets> power_2_buckets_t;
+ typedef detail::size_holder<constant_time_size, size_type> size_traits;
+ typedef detail::size_holder<incremental, size_type, int> split_traits;
+ typedef detail::group_functions<node_traits> group_functions_t;
+ typedef detail::node_functions<node_traits> node_functions_t;
+
+ private:
+ //noncopyable, movable
+ BOOST_MOVABLE_BUT_NOT_COPYABLE(hashtable_impl)
+
+ static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value;
+
+ //Constant-time size is incompatible with auto-unlink hooks!
+ BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+ //Cache begin is incompatible with auto-unlink hooks!
+ BOOST_STATIC_ASSERT(!(cache_begin && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+
+ template<class Disposer>
+ node_cast_adaptor< detail::node_disposer<Disposer, real_value_traits, CircularSListAlgorithms>
+ , slist_node_ptr, node_ptr >
+ make_node_disposer(const Disposer &disposer) const
+ {
+ return node_cast_adaptor
+ < detail::node_disposer<Disposer, real_value_traits, CircularSListAlgorithms>
+ , slist_node_ptr, node_ptr >
+ (disposer, &this->priv_real_value_traits());
+ }
+
+ /// @endcond
+
+ public:
+ typedef detail::insert_commit_data_impl insert_commit_data;
+
+ typedef detail::transform_iterator
+ < typename slist_impl::iterator
+ , downcast_node_to_value_t
+ < real_value_traits
+ , false> > local_iterator;
+
+ typedef detail::transform_iterator
+ < typename slist_impl::iterator
+ , downcast_node_to_value_t
+ < real_value_traits
+ , true> > const_local_iterator;
+
+ public:
+
+ //! <b>Requires</b>: buckets must not be being used by any other resource.
+ //!
+ //! <b>Effects</b>: Constructs an empty unordered_set, storing a reference
+ //! to the bucket array and copies of the key_hasher and equal_func functors.
+ //!
+ //! <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 or invocation of hash_func or equal_func throws.
    //!
@@ -892,7 +1249,7 @@
                            , const hasher & hash_func = hasher()
                            , const key_equal &equal_func = key_equal()
                            , const value_traits &v_traits = value_traits())
- : data_(b_traits, hash_func, equal_func, v_traits)
+ : data_type(b_traits, hash_func, equal_func, v_traits)
    {
       this->priv_initialize_buckets();
       this->priv_size_traits().set_size(size_type(0));
@@ -907,13 +1264,13 @@
    //! <b>Effects</b>: to-do
    //!
    hashtable_impl(BOOST_RV_REF(hashtable_impl) x)
- : data_( ::boost::move(x.priv_bucket_traits())
+ : data_type( ::boost::move(x.priv_bucket_traits())
              , ::boost::move(x.priv_hasher())
              , ::boost::move(x.priv_equal())
              , ::boost::move(x.priv_value_traits())
              )
    {
- this->priv_swap_cache(cache_begin_t(), x);
+ this->priv_swap_cache(x);
       x.priv_initialize_cache();
       if(constant_time_size){
          this->priv_size_traits().set_size(size_type(0));
@@ -931,6 +1288,7 @@
    hashtable_impl& operator=(BOOST_RV_REF(hashtable_impl) x)
    { this->swap(x); return *this; }
 
+ #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
    //! <b>Effects</b>: Detaches all elements from this. The objects in the unordered_set
    //! are not deleted (i.e. no destructors are called).
    //!
@@ -940,6 +1298,7 @@
    //! <b>Throws</b>: Nothing.
    ~hashtable_impl()
    {}
+ #endif
 
    //! <b>Effects</b>: Returns an iterator pointing to the beginning of the unordered_set.
    //!
@@ -948,7 +1307,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    iterator begin()
- { return iterator(this->priv_begin(), this); }
+ { return iterator(this->priv_begin(), &this->get_bucket_value_traits()); }
 
    //! <b>Effects</b>: Returns a const_iterator pointing to the beginning
    //! of the unordered_set.
@@ -968,7 +1327,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    const_iterator cbegin() const
- { return const_iterator(this->priv_begin(), this); }
+ { return const_iterator(this->priv_begin(), &this->get_bucket_value_traits()); }
 
    //! <b>Effects</b>: Returns an iterator pointing to the end of the unordered_set.
    //!
@@ -1077,7 +1436,7 @@
       //These can't throw
       swap(this->priv_bucket_traits(), other.priv_bucket_traits());
       swap(this->priv_value_traits(), other.priv_value_traits());
- this->priv_swap_cache(cache_begin_t(), other);
+ this->priv_swap_cache(other);
       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());
@@ -1128,9 +1487,12 @@
             const bucket_ptr src_buckets = src.priv_bucket_pointer();
             const bucket_ptr dst_buckets = this->priv_bucket_pointer();
             size_type constructed;
- typedef node_cast_adaptor<detail::node_disposer<Disposer, hashtable_impl> > NodeDisposer;
- typedef node_cast_adaptor<detail::node_cloner<Cloner, hashtable_impl> > NodeCloner;
- NodeDisposer node_disp(disposer, this);
+
+ typedef node_cast_adaptor< detail::node_disposer<Disposer, real_value_traits, CircularSListAlgorithms>
+ , slist_node_ptr, node_ptr > NodeDisposer;
+ typedef node_cast_adaptor< detail::node_cloner <Cloner, real_value_traits, CircularSListAlgorithms>
+ , slist_node_ptr, node_ptr > NodeCloner;
+ NodeDisposer node_disp(disposer, &this->priv_real_value_traits());
 
             detail::exception_array_disposer<bucket_type, NodeDisposer, size_type>
                rollback(dst_buckets[0], node_disp, constructed);
@@ -1139,7 +1501,7 @@
                ; ++constructed){
                dst_buckets[constructed].clone_from
                   ( src_buckets[constructed]
- , NodeCloner(cloner, this), node_disp);
+ , NodeCloner(cloner, &this->priv_real_value_traits()), node_disp);
             }
             if(src_bucket_count != dst_bucket_count){
                //Now insert the remaining ones using the modulo trick
@@ -1147,12 +1509,12 @@
                   ; constructed < src_bucket_count
                   ; ++constructed){
                   bucket_type &dst_b =
- dst_buckets[this->priv_hash_to_bucket(constructed, dst_bucket_count, dst_bucket_count)];
+ dst_buckets[detail::hash_to_bucket_split<power_2_buckets, incremental>(constructed, dst_bucket_count, dst_bucket_count)];
                   bucket_type &src_b = src_buckets[constructed];
                   for( siterator b(src_b.begin()), e(src_b.end())
                      ; b != e
                      ; ++b){
- dst_b.push_front(*(NodeCloner(cloner, this)(*b.pointed_node())));
+ dst_b.push_front(*(NodeCloner(cloner, &this->priv_real_value_traits())(*b.pointed_node())));
                   }
                }
             }
@@ -1327,7 +1689,7 @@
       if(success){
          prev_pos = prev;
       }
- return std::pair<iterator, bool>(iterator(prev_pos, this),success);
+ return std::pair<iterator, bool>(iterator(prev_pos, &this->get_bucket_value_traits()),success);
    }
 
    //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
@@ -1360,7 +1722,7 @@
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
       this->priv_insertion_update_cache(bucket_num);
       group_functions_t::insert_in_group(node_ptr(), n, optimize_multikey_t());
- return iterator(b.insert_after(b.before_begin(), *n), this);
+ return iterator(b.insert_after(b.before_begin(), *n), &this->get_bucket_value_traits());
    }
 
    //! <b>Effects</b>: Erases the element pointed to by i.
@@ -1485,7 +1847,7 @@
             last_bucket_num = this->priv_get_bucket_num(last_local_it);
          }
          this->priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer);
- this->priv_erasure_update_cache(first_bucket_num, last_bucket_num);
+ this->priv_erasure_update_cache_range(first_bucket_num, last_bucket_num);
       }
    }
 
@@ -1530,8 +1892,7 @@
       size_type bucket_num;
       std::size_t h;
       siterator prev;
- siterator it =
- this->priv_find(key, hash_func, equal_func, bucket_num, h, prev);
+ siterator it = this->priv_find(key, hash_func, equal_func, bucket_num, h, prev);
       bool success = it != this->priv_invalid_local_it();
       size_type cnt(0);
       if(!success){
@@ -1540,7 +1901,7 @@
       else if(optimize_multikey){
          siterator last = bucket_type::s_iterator_to
             (*node_traits::get_next(group_functions_t::get_last_in_group
- (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
+ (detail::dcast_bucket_ptr<node>(it.pointed_node()), optimize_multikey_t())));
          this->priv_erase_range_impl(bucket_num, prev, last, disposer, cnt);
       }
       else{
@@ -1670,7 +2031,7 @@
       std::size_t hash;
       siterator prev;
       siterator local_it = this->priv_find(key, hash_func, equal_func, bucket_n, hash, prev);
- return iterator(local_it, this);
+ return iterator(local_it, &this->get_bucket_value_traits());
    }
 
    //! <b>Effects</b>: Finds a const_iterator to the first element whose key is
@@ -1709,7 +2070,7 @@
       std::size_t hash_value;
       siterator prev;
       siterator sit = this->priv_find(key, hash_func, equal_func, bucket_n, hash_value, prev);
- return const_iterator(sit, this);
+ return const_iterator(sit, &this->get_bucket_value_traits());
    }
 
    //! <b>Effects</b>: Returns a range containing all elements with values equivalent
@@ -1750,7 +2111,7 @@
       std::pair<siterator, siterator> ret = this->priv_equal_range
          (key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
       return std::pair<iterator, iterator>
- (iterator(ret.first, this), iterator(ret.second, this));
+ (iterator(ret.first, &this->get_bucket_value_traits()), iterator(ret.second, &this->get_bucket_value_traits()));
    }
 
    //! <b>Effects</b>: Returns a range containing all elements with values equivalent
@@ -1792,7 +2153,7 @@
       std::pair<siterator, siterator> ret =
          this->priv_equal_range(key, hash_func, equal_func, bucket_n1, bucket_n2, cnt);
       return std::pair<const_iterator, const_iterator>
- (const_iterator(ret.first, this), const_iterator(ret.second, this));
+ (const_iterator(ret.first, &this->get_bucket_value_traits()), const_iterator(ret.second, &this->get_bucket_value_traits()));
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1806,7 +2167,7 @@
    //! <b>Throws</b>: If the internal hash function throws.
    iterator iterator_to(reference value)
    {
- return iterator(bucket_type::s_iterator_to(this->priv_value_to_node(value)), this);
+ return iterator(bucket_type::s_iterator_to(this->priv_value_to_node(value)), &this->get_bucket_value_traits());
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1821,7 +2182,7 @@
    const_iterator iterator_to(const_reference value) const
    {
       siterator sit = bucket_type::s_iterator_to(const_cast<node &>(this->priv_value_to_node(value)));
- return const_iterator(sit, this);
+ return const_iterator(sit, &this->get_bucket_value_traits());
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1840,7 +2201,7 @@
    {
       BOOST_STATIC_ASSERT((!stateful_value_traits));
       siterator sit = bucket_type::s_iterator_to(((hashtable_impl*)0)->priv_value_to_node(value));
- return local_iterator(sit, (hashtable_impl*)0);
+ return local_iterator(sit, const_real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1859,7 +2220,7 @@
    {
       BOOST_STATIC_ASSERT((!stateful_value_traits));
       siterator sit = bucket_type::s_iterator_to(((hashtable_impl*)0)->priv_value_to_node(const_cast<value_type&>(value)));
- return const_local_iterator(sit, (hashtable_impl*)0);
+ return const_local_iterator(sit, const_real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1874,7 +2235,7 @@
    local_iterator local_iterator_to(reference value)
    {
       siterator sit = bucket_type::s_iterator_to(this->priv_value_to_node(value));
- return local_iterator(sit, this);
+ return local_iterator(sit, this->real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be an lvalue and shall be in a unordered_set of
@@ -1890,7 +2251,7 @@
    {
       siterator sit = bucket_type::s_iterator_to
          (const_cast<node &>(this->priv_value_to_node(value)));
- return const_local_iterator(sit, this);
+ return const_local_iterator(sit, this->real_value_traits_ptr());
    }
 
    //! <b>Effects</b>: Returns the number of buckets passed in the constructor
@@ -1960,7 +2321,7 @@
    //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
    //! containing all of the elements in the nth bucket.
    local_iterator begin(size_type n)
- { return local_iterator(this->priv_bucket_pointer()[n].begin(), this); }
+ { return local_iterator(this->priv_bucket_pointer()[n].begin(), this->real_value_traits_ptr()); }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
    //!
@@ -1990,7 +2351,7 @@
    const_local_iterator cbegin(size_type n) const
    {
       siterator sit = const_cast<bucket_type&>(this->priv_bucket_pointer()[n]).begin();
- return const_local_iterator(sit, this);
+ return const_local_iterator(sit, this->real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
@@ -2005,7 +2366,7 @@
    //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
    //! containing all of the elements in the nth bucket.
    local_iterator end(size_type n)
- { return local_iterator(this->priv_bucket_pointer()[n].end(), this); }
+ { return local_iterator(this->priv_bucket_pointer()[n].end(), this->real_value_traits_ptr()); }
 
    //! <b>Requires</b>: n is in the range [0, this->bucket_count()).
    //!
@@ -2033,7 +2394,10 @@
    //! <b>Note</b>: [this->begin(n), this->end(n)) is a valid range
    //! containing all of the elements in the nth bucket.
    const_local_iterator cend(size_type n) const
- { return const_local_iterator(const_cast<bucket_type&>(this->priv_bucket_pointer()[n]).end(), this); }
+ {
+ return const_local_iterator ( const_cast<bucket_type&>(this->priv_bucket_pointer()[n]).end()
+ , this->real_value_traits_ptr());
+ }
 
    //! <b>Requires</b>: new_bucket_traits can hold a pointer to a new bucket array
    //! or the same as the old bucket array with a different length. new_size is the length of the
@@ -2107,12 +2471,12 @@
             for(;i != end_sit; ++i){
                const value_type &v = this->priv_value_from_slist_node(i.pointed_node());
                const std::size_t hash_value = this->priv_stored_or_compute_hash(v, store_hash_t());
- const size_type new_n = this->priv_hash_to_bucket(hash_value, new_bucket_count, new_bucket_count);
+ const size_type new_n = detail::hash_to_bucket_split<power_2_buckets, incremental>(hash_value, new_bucket_count, new_bucket_count);
                if(cache_begin && new_n < new_first_bucket_num)
                   new_first_bucket_num = new_n;
                siterator last = bucket_type::s_iterator_to
                   (*group_functions_t::get_last_in_group
- (hashtable_impl::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t()));
+ (detail::dcast_bucket_ptr<node>(i.pointed_node()), optimize_multikey_t()));
                if(same_buffer && new_n == n){
                   before_i = last;
                }
@@ -2124,7 +2488,7 @@
             }
          }
          else{
- const size_type new_n = this->priv_hash_to_bucket(n, new_bucket_count, new_bucket_count);
+ const size_type new_n = detail::hash_to_bucket_split<power_2_buckets, incremental>(n, new_bucket_count, new_bucket_count);
             if(cache_begin && new_n < new_first_bucket_num)
                new_first_bucket_num = new_n;
             bucket_type &new_b = new_buckets[new_n];
@@ -2186,7 +2550,7 @@
             const size_type new_n = this->priv_hash_to_bucket(hash_value);
             siterator last = bucket_type::s_iterator_to
                (*group_functions_t::get_last_in_group
- (hashtable_impl::dcast_bucket_ptr(i.pointed_node()), optimize_multikey_t()));
+ (detail::dcast_bucket_ptr<node>(i.pointed_node()), optimize_multikey_t()));
             if(new_n == bucket_to_rehash){
                before_i = last;
             }
@@ -2314,102 +2678,42 @@
       const std::size_t *primes_end = primes + detail::prime_list_holder<0>::prime_list_size;
       size_type const* bound = std::upper_bound(primes, primes_end, n);
       if(bound != primes)
- --bound;
- return size_type(*bound);
- }
-
- /// @cond
- private:
-
- std::size_t priv_hash_to_bucket(std::size_t hash_value) const
- { return this->priv_hash_to_bucket(hash_value, this->priv_real_bucket_traits().bucket_count(), this->priv_split_traits().get_size()); }
-
- std::size_t priv_hash_to_bucket(std::size_t hash_value, std::size_t bucket_cnt, std::size_t split) const
- {
- std::size_t bucket_number = hashtable_impl::priv_hash_to_bucket_impl(hash_value, bucket_cnt, power_2_buckets_t());
- if(incremental)
- if(bucket_number >= split)
- bucket_number -= bucket_cnt/2;
- return bucket_number;
- }
-
- static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_cnt, detail::false_)
- { return hash_value % bucket_cnt; }
-
- static std::size_t priv_hash_to_bucket_impl(std::size_t hash_value, std::size_t bucket_cnt, detail::true_)
- { return hash_value & (bucket_cnt - 1); }
-
- const key_equal &priv_equal() const
- { return static_cast<const key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); }
-
- key_equal &priv_equal()
- { return static_cast<key_equal&>(this->data_.internal_.bucket_hash_equal_.get()); }
-
- const value_traits &priv_value_traits() const
- { return data_; }
-
- value_traits &priv_value_traits()
- { return data_; }
-
- value_type &priv_value_from_slist_node(slist_node_ptr n)
- { return *this->get_real_value_traits().to_value_ptr(hashtable_impl::dcast_bucket_ptr(n)); }
-
- const value_type &priv_value_from_slist_node(slist_node_ptr n) const
- { return *this->get_real_value_traits().to_value_ptr(hashtable_impl::dcast_bucket_ptr(n)); }
-
- const real_bucket_traits &priv_real_bucket_traits(detail::false_) const
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; }
-
- const real_bucket_traits &priv_real_bucket_traits(detail::true_) const
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_.get_bucket_traits(*this); }
-
- real_bucket_traits &priv_real_bucket_traits(detail::false_)
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; }
-
- real_bucket_traits &priv_real_bucket_traits(detail::true_)
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_.get_bucket_traits(*this); }
-
- const real_bucket_traits &priv_real_bucket_traits() const
- { return this->priv_real_bucket_traits(detail::bool_<external_bucket_traits>()); }
-
- real_bucket_traits &priv_real_bucket_traits()
- { return this->priv_real_bucket_traits(detail::bool_<external_bucket_traits>()); }
-
- const bucket_traits &priv_bucket_traits() const
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; }
-
- bucket_traits &priv_bucket_traits()
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_.bucket_traits_; }
-
- const hasher &priv_hasher() const
- { return static_cast<const hasher&>(this->data_.internal_.bucket_hash_equal_.bucket_hash.get()); }
-
- hasher &priv_hasher()
- { return static_cast<hasher&>(this->data_.internal_.bucket_hash_equal_.bucket_hash.get()); }
-
- bucket_ptr priv_bucket_pointer() const
- { return this->priv_real_bucket_traits().bucket_begin(); }
-
- size_type priv_bucket_count() const
- { return this->priv_real_bucket_traits().bucket_count(); }
-
- node &priv_value_to_node(value_type &v)
- { return *this->get_real_value_traits().to_node_ptr(v); }
+ --bound;
+ return size_type(*bound);
+ }
 
- const node &priv_value_to_node(const value_type &v) const
- { return *this->get_real_value_traits().to_node_ptr(v); }
+ /// @cond
+ private:
 
- size_traits &priv_size_traits()
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_; }
+ void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_cnt)
+ {
+ for(; bucket_cnt--; ++buckets_ptr){
+ if(safemode_or_autounlink){
+ bucket_plus_vtraits_t::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t());
+ buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>());
+ }
+ else{
+ buckets_ptr->clear();
+ }
+ }
+ this->priv_initialize_cache();
+ }
 
- const size_traits &priv_size_traits() const
- { return this->data_.internal_.bucket_hash_equal_.bucket_hash.bucket_plus_size_; }
+ void priv_initialize_buckets()
+ { this->priv_clear_buckets(this->priv_bucket_pointer(), this->priv_bucket_count()); }
 
- split_traits &priv_split_traits()
- { return this->data_.internal_; }
+ void priv_clear_buckets()
+ {
+ this->priv_clear_buckets
+ ( this->priv_get_cache()
+ , this->priv_bucket_count() - (this->priv_get_cache() - this->priv_bucket_pointer()));
+ }
 
- const split_traits &priv_split_traits() const
- { return this->data_.internal_; }
+ std::size_t priv_hash_to_bucket(std::size_t hash_value) const
+ {
+ return detail::hash_to_bucket_split<power_2_buckets, incremental>
+ (hash_value, this->priv_real_bucket_traits().bucket_count(), this->priv_split_traits().get_size());
+ }
 
    template<class Disposer>
    void priv_erase_range_impl
@@ -2427,7 +2731,7 @@
          ++to_erase;
          slist_node_ptr end_ptr = end_sit.pointed_node();
          while(to_erase != end_sit){
- group_functions_t::erase_from_group(end_ptr, hashtable_impl::dcast_bucket_ptr(to_erase.pointed_node()), optimize_multikey_t());
+ group_functions_t::erase_from_group(end_ptr, detail::dcast_bucket_ptr<node>(to_erase.pointed_node()), optimize_multikey_t());
             to_erase = b.erase_after_and_dispose(before_first_it, make_node_disposer(disposer));
             ++num_erased;
          }
@@ -2449,7 +2753,7 @@
          ++nxt;
          siterator end_sit(b.end());
          while(nxt != end_sit){
- group_functions_t::init_group(hashtable_impl::dcast_bucket_ptr(nxt.pointed_node()), optimize_multikey_t());
+ group_functions_t::init_group(detail::dcast_bucket_ptr<node>(nxt.pointed_node()), optimize_multikey_t());
             nxt = b.erase_after_and_dispose
                (b_begin, make_node_disposer(disposer));
             this->priv_size_traits().decrement();
@@ -2476,125 +2780,23 @@
       }
    }
 
- static node_ptr dcast_bucket_ptr(typename slist_impl::node_ptr p)
- { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*p)); }
-
- std::size_t priv_stored_or_compute_hash(const value_type &v, detail::true_) const
- { return node_traits::get_hash(this->get_real_value_traits().to_node_ptr(v)); }
-
- std::size_t priv_stored_or_compute_hash(const value_type &v, detail::false_) const
- { return this->priv_hasher()(v); }
-
- std::size_t priv_stored_hash(slist_node_ptr n, detail::true_) const
- { return node_traits::get_hash(hashtable_impl::dcast_bucket_ptr(n)); }
-
- std::size_t priv_stored_hash(slist_node_ptr, detail::false_) const
- {
- //This code should never be reached!
- BOOST_INTRUSIVE_INVARIANT_ASSERT(0);
- return 0;
- }
-
- static void priv_clear_group_nodes(bucket_type &b, detail::true_)
- {
- siterator it(b.begin()), itend(b.end());
- while(it != itend){
- node_ptr to_erase(hashtable_impl::dcast_bucket_ptr(it.pointed_node()));
- ++it;
- group_algorithms::init(to_erase);
- }
- }
-
- static void priv_clear_group_nodes(bucket_type &, detail::false_)
- {}
-
    std::size_t priv_get_bucket_num(siterator it)
    { return this->priv_get_bucket_num_hash_dispatch(it, store_hash_t()); }
 
- std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::true_)
+ std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::true_) //store_hash
    {
       return this->priv_hash_to_bucket
          (this->priv_stored_hash(it.pointed_node(), store_hash_t()));
    }
 
- std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_)
+ std::size_t priv_get_bucket_num_hash_dispatch(siterator it, detail::false_) //NO store_hash
    { return this->priv_get_bucket_num_no_hash_store(it, optimize_multikey_t()); }
 
- std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::true_)
- {
- const bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
- slist_node_ptr bb = group_functions_t::get_bucket_before_begin
- ( f->end().pointed_node()
- , l->end().pointed_node()
- , hashtable_impl::dcast_bucket_ptr(it.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(bucket_type::s_iterator_to(*bb)));
- //Now just calculate the index b has in the bucket array
- return static_cast<size_type>(&b - &*f);
- }
-
- std::size_t priv_get_bucket_num_no_hash_store(siterator it, detail::false_)
- {
- bucket_ptr f(this->priv_bucket_pointer()), l(f + this->priv_bucket_count() - 1);
- slist_node_ptr first_ptr(f->cend().pointed_node())
- , last_ptr(l->cend().pointed_node());
-
- //The end node is embedded in the singly linked list:
- //iterate until we reach it.
- while(!(first_ptr <= it.pointed_node() && it.pointed_node() <= last_ptr)){
- ++it;
- }
- //Now get the bucket_impl from the iterator
- const bucket_type &b = static_cast<const bucket_type&>
- (bucket_type::container_from_end_iterator(it));
-
- //Now just calculate the index b has in the bucket array
- return static_cast<std::size_t>(&b - &*f);
- }
-
- siterator priv_get_previous
- (bucket_type &b, siterator i)
- { return this->priv_get_previous(b, i, optimize_multikey_t()); }
-
- siterator priv_get_previous
- (bucket_type &b, siterator i, detail::true_)
- {
- node_ptr elem(hashtable_impl::dcast_bucket_ptr(i.pointed_node()));
- node_ptr prev_in_group(group_traits::get_next(elem));
- bool first_in_group = node_traits::get_next(prev_in_group) != elem;
- typename bucket_type::node &n = first_in_group
- ? *group_functions_t::get_prev_to_first_in_group(b.end().pointed_node(), elem)
- : *group_traits::get_next(elem)
- ;
- return bucket_type::s_iterator_to(n);
- }
-
- siterator priv_get_previous
- (bucket_type &b, siterator i, detail::false_)
- { return b.previous(i); }
+ static siterator priv_get_previous(bucket_type &b, siterator i)
+ { return bucket_plus_vtraits_t::priv_get_previous(b, i, optimize_multikey_t()); }
 
    static siterator priv_get_last(bucket_type &b)
- { return hashtable_impl::priv_get_last(b, optimize_multikey_t()); }
-
- static siterator priv_get_last(bucket_type &b, detail::true_)
- {
- //First find the last node of p's group.
- //This requires checking the first node of the next group or
- //the bucket node.
- slist_node_ptr end_ptr(b.end().pointed_node());
- node_ptr possible_end(node_traits::get_next( hashtable_impl::dcast_bucket_ptr(end_ptr)));
- node_ptr last_node_group(possible_end);
-
- while(end_ptr != possible_end){
- last_node_group = group_traits::get_next(hashtable_impl::dcast_bucket_ptr(possible_end));
- possible_end = node_traits::get_next(last_node_group);
- }
- return bucket_type::s_iterator_to(*last_node_group);
- }
-
- static siterator priv_get_last(bucket_type &b, detail::false_)
- { return b.previous(b.end()); }
+ { return bucket_plus_vtraits_t::priv_get_last(b, optimize_multikey_t()); }
 
    template<class Disposer>
    void priv_erase(const_iterator i, Disposer disposer, detail::true_)
@@ -2621,7 +2823,7 @@
       if(nxt_in_group)
          group_algorithms::unlink_after(nxt_in_group);
       if(safemode_or_autounlink)
- group_algorithms::init(hashtable_impl::dcast_bucket_ptr(elem));
+ group_algorithms::init(detail::dcast_bucket_ptr<node>(elem));
    }
 
    template <class Disposer>
@@ -2633,159 +2835,6 @@
       b.erase_after_and_dispose(prev, make_node_disposer(disposer));
    }
 
- bucket_ptr priv_invalid_bucket() const
- {
- const real_bucket_traits &rbt = this->priv_real_bucket_traits();
- return rbt.bucket_begin() + rbt.bucket_count();
- }
-
- siterator priv_invalid_local_it() const
- { return this->priv_invalid_bucket()->end(); }
-
- siterator priv_begin() const
- { return this->priv_begin(cache_begin_t()); }
-
- siterator priv_begin(detail::false_) const
- {
- size_type n = 0;
- size_type bucket_cnt = this->priv_bucket_count();
- for (n = 0; n < bucket_cnt; ++n){
- bucket_type &b = this->priv_bucket_pointer()[n];
- if(!b.empty()){
- return b.begin();
- }
- }
- return this->priv_invalid_local_it();
- }
-
- siterator priv_begin(detail::true_) const
- {
- if(this->data_.internal_.bucket_hash_equal_.cached_begin_ == this->priv_invalid_bucket()){
- return this->priv_invalid_local_it();
- }
- else{
- return this->data_.internal_.bucket_hash_equal_.cached_begin_->begin();
- }
- }
-
- void priv_initialize_cache()
- { this->priv_initialize_cache(cache_begin_t()); }
-
- void priv_initialize_cache(detail::true_)
- { this->data_.internal_.bucket_hash_equal_.cached_begin_ = this->priv_invalid_bucket(); }
-
- void priv_initialize_cache(detail::false_)
- {}
-
- void priv_insertion_update_cache(size_type insertion_bucket)
- { this->priv_insertion_update_cache(insertion_bucket, cache_begin_t()); }
-
- void priv_insertion_update_cache(size_type insertion_bucket, detail::true_)
- {
- bucket_ptr p = this->priv_bucket_pointer() + insertion_bucket;
- if(p < this->data_.internal_.bucket_hash_equal_.cached_begin_){
- this->data_.internal_.bucket_hash_equal_.cached_begin_ = p;
- }
- }
-
- void priv_insertion_update_cache(size_type, detail::false_)
- {}
-
- void priv_erasure_update_cache(size_type first_bucket, size_type last_bucket)
- { this->priv_erasure_update_cache(first_bucket, last_bucket, cache_begin_t()); }
-
- void priv_erasure_update_cache(size_type first_bucket_num, size_type last_bucket_num, detail::true_)
- {
- //If the last bucket is the end, the cache must be updated
- //to the last position if all
- if(this->priv_get_cache_bucket_num() == first_bucket_num &&
- this->priv_bucket_pointer()[first_bucket_num].empty() ){
- this->priv_set_cache(this->priv_bucket_pointer() + last_bucket_num);
- this->priv_erasure_update_cache();
- }
- }
-
- void priv_erasure_update_cache(size_type, size_type, detail::false_)
- {}
-
- void priv_erasure_update_cache()
- { this->priv_erasure_update_cache(cache_begin_t()); }
-
- void priv_erasure_update_cache(detail::true_)
- {
- if(constant_time_size && !size()){
- this->priv_initialize_cache();
- }
- else{
- size_type current_n = this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_bucket_pointer();
- for( const size_type num_buckets = this->priv_bucket_count()
- ; current_n < num_buckets
- ; ++current_n, ++this->data_.internal_.bucket_hash_equal_.cached_begin_){
- if(!this->data_.internal_.bucket_hash_equal_.cached_begin_->empty()){
- return;
- }
- }
- this->priv_initialize_cache();
- }
- }
-
- void priv_erasure_update_cache(detail::false_)
- {}
-
- void priv_swap_cache(detail::true_, hashtable_impl &other)
- {
- std::swap( this->data_.internal_.bucket_hash_equal_.cached_begin_
- , other.data_.internal_.bucket_hash_equal_.cached_begin_);
- }
-
- void priv_swap_cache(detail::false_, hashtable_impl &)
- {}
-
- bucket_ptr priv_get_cache()
- { return this->priv_get_cache(cache_begin_t()); }
-
- bucket_ptr priv_get_cache(detail::true_)
- { return this->data_.internal_.bucket_hash_equal_.cached_begin_; }
-
- bucket_ptr priv_get_cache(detail::false_)
- { return this->priv_bucket_pointer(); }
-
- void priv_set_cache(const bucket_ptr &p)
- { this->data_.internal_.bucket_hash_equal_.set_cache(p); }
-
- size_type priv_get_cache_bucket_num()
- { return this->priv_get_cache_bucket_num(cache_begin_t()); }
-
- size_type priv_get_cache_bucket_num(detail::true_)
- { return this->data_.internal_.bucket_hash_equal_.cached_begin_ - this->priv_bucket_pointer(); }
-
- size_type priv_get_cache_bucket_num(detail::false_)
- { return 0u; }
-
- void priv_clear_buckets()
- {
- this->priv_clear_buckets
- ( this->priv_get_cache()
- , this->priv_bucket_count() - (this->priv_get_cache() - this->priv_bucket_pointer()));
- }
-
- void priv_initialize_buckets()
- { this->priv_clear_buckets(this->priv_bucket_pointer(), this->priv_bucket_count()); }
-
- void priv_clear_buckets(bucket_ptr buckets_ptr, size_type bucket_cnt)
- {
- for(; bucket_cnt--; ++buckets_ptr){
- if(safemode_or_autounlink){
- hashtable_impl::priv_clear_group_nodes(*buckets_ptr, optimize_multikey_t());
- buckets_ptr->clear_and_dispose(detail::init_disposer<node_algorithms>());
- }
- else{
- buckets_ptr->clear();
- }
- }
- this->priv_initialize_cache();
- }
-
    template<class KeyType, class KeyHasher, class KeyValueEqual>
    siterator priv_find
       ( const KeyType &key, KeyHasher hash_func
@@ -2823,7 +2872,7 @@
          if(optimize_multikey){
             previt = bucket_type::s_iterator_to
                (*group_functions_t::get_last_in_group
- (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t()));
+ (detail::dcast_bucket_ptr<node>(it.pointed_node()), optimize_multikey_t()));
             it = previt;
          }
          else{
@@ -2857,17 +2906,17 @@
       //Checks for some modes
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(n));
- //Shorcut for optimize_multikey cases
+ //Shortcut for optimize_multikey cases
       if(optimize_multikey){
          node_ptr first_in_group = found_equal ?
- hashtable_impl::dcast_bucket_ptr(it.pointed_node()) : node_ptr();
+ detail::dcast_bucket_ptr<node>(it.pointed_node()) : node_ptr();
          group_functions_t::insert_in_group(first_in_group, n, optimize_multikey_t());
       }
       //Update cache and increment size if needed
       this->priv_insertion_update_cache(bucket_num);
       this->priv_size_traits().increment();
       //Insert the element in the bucket after it
- return iterator(b.insert_after(it, *n), this);
+ return iterator(b.insert_after(it, *n), &this->get_bucket_value_traits());
    }
 
    template<class KeyType, class KeyHasher, class KeyValueEqual>
@@ -2898,7 +2947,7 @@
          if(optimize_multikey){
             to_return.second = bucket_type::s_iterator_to
                (*node_traits::get_next(group_functions_t::get_last_in_group
- (hashtable_impl::dcast_bucket_ptr(it.pointed_node()), optimize_multikey_t())));
+ (detail::dcast_bucket_ptr<node>(it.pointed_node()), optimize_multikey_t())));
             cnt = std::distance(it, to_return.second);
             if(to_return.second != b.end()){
                bucket_number_second = bucket_number_first;
@@ -2951,39 +3000,21 @@
 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template < class T
          , bool UniqueKeys
- , class O1 = none, class O2 = none
- , class O3 = none, class O4 = none
- , class O5 = none, class O6 = none
- , class O7 = none, class O8 = none
- , class O9 = none, class O10= none
+ , class PackedOptions
>
 #else
 template <class T, bool UniqueKeys, class ...Options>
 #endif
-struct make_hashtable_opt
+struct make_real_bucket_traits
 {
- typedef typename pack_options
- < uset_defaults<T>,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
- #else
- Options...
- #endif
- >::type packed_options;
-
    //Real value traits must be calculated from options
    typedef typename detail::get_value_traits
- <T, typename packed_options::value_traits>::type value_traits;
- static const bool external_value_traits =
- detail::external_value_traits_bool_is_true<value_traits>::value;/*
+ <T, typename PackedOptions::proto_value_traits>::type value_traits;
+/*
    static const bool resizable_bucket_traits =
       detail::resizable_bool_is_true<bucket_traits_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;
- typedef typename packed_options::bucket_traits specified_bucket_traits;
+ typedef typename detail::get_real_value_traits<value_traits>::type real_value_traits;
+ typedef typename PackedOptions::bucket_traits specified_bucket_traits;
 
    //Real bucket traits must be calculated from options and calculated value_traits
    typedef typename detail::get_slist_impl
@@ -2998,21 +3029,7 @@
>::value
                   , detail::bucket_traits_impl<slist_impl>
                   , specified_bucket_traits
- >::type real_bucket_traits;
-
- typedef detail::usetopt
- < value_traits
- , typename packed_options::hash
- , typename packed_options::equal
- , typename packed_options::size_type
- , real_bucket_traits
- , (std::size_t(UniqueKeys)*detail::hash_bool_flags::unique_keys_pos)
- | (std::size_t(packed_options::constant_time_size)*detail::hash_bool_flags::constant_time_size_pos)
- | (std::size_t(packed_options::power_2_buckets)*detail::hash_bool_flags::power_2_buckets_pos)
- | (std::size_t(packed_options::cache_begin)*detail::hash_bool_flags::cache_begin_pos)
- | (std::size_t(packed_options::compare_hash)*detail::hash_bool_flags::compare_hash_pos)
- | (std::size_t(packed_options::incremental)*detail::hash_bool_flags::incremental_pos)
- > type;
+ >::type type;
 };
 /// @endcond
 
@@ -3021,25 +3038,43 @@
 #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
- , class O5 = none, class O6 = none
- , class O7 = none, class O8 = none
- , class O9 = none, class O10= none
+template<class T, class O1 = void, class O2 = void
+ , class O3 = void, class O4 = void
+ , class O5 = void, class O6 = void
+ , class O7 = void, class O8 = void
+ , class O9 = void, class O10= void
>
 #endif
 struct make_hashtable
 {
    /// @cond
+ typedef typename pack_options
+ < hashtable_defaults,
+ #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+ O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
+ #else
+ Options...
+ #endif
+ >::type packed_options;
+
+ typedef typename detail::get_value_traits
+ <T, typename packed_options::proto_value_traits>::type value_traits;
+
+ typedef typename make_real_bucket_traits
+ <T, false, packed_options>::type real_bucket_traits;
+
    typedef hashtable_impl
- < typename make_hashtable_opt
- <T, false,
- #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
- O1, O2, O3, O4, O5, O6, O7, O8, O9, O10
- #else
- Options...
- #endif
- >::type
+ < value_traits
+ , typename packed_options::hash
+ , typename packed_options::equal
+ , typename packed_options::size_type
+ , real_bucket_traits
+ , (std::size_t(false)*hash_bool_flags::unique_keys_pos)
+ | (std::size_t(packed_options::constant_time_size)*hash_bool_flags::constant_time_size_pos)
+ | (std::size_t(packed_options::power_2_buckets)*hash_bool_flags::power_2_buckets_pos)
+ | (std::size_t(packed_options::cache_begin)*hash_bool_flags::cache_begin_pos)
+ | (std::size_t(packed_options::compare_hash)*hash_bool_flags::compare_hash_pos)
+ | (std::size_t(packed_options::incremental)*hash_bool_flags::incremental_pos)
> implementation_defined;
 
    /// @endcond
@@ -3085,7 +3120,7 @@
    //Assert if passed value traits are compatible with the type
    BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value));
 
- hashtable ( const bucket_traits &b_traits
+ explicit hashtable ( const bucket_traits &b_traits
              , const hasher & hash_func = hasher()
              , const key_equal &equal_func = key_equal()
              , const value_traits &v_traits = value_traits())
@@ -3097,7 +3132,7 @@
    {}
 
    hashtable& operator=(BOOST_RV_REF(hashtable) x)
- { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
+ { return static_cast<hashtable&>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
 };
 
 #endif

Modified: branches/release/boost/intrusive/intrusive_fwd.hpp
==============================================================================
--- branches/release/boost/intrusive/intrusive_fwd.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/intrusive_fwd.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -20,15 +20,6 @@
 /// @cond
 
 namespace boost {
-
-namespace intrusive {
-
-struct none;
-
-} //namespace intrusive{
-} //namespace boost{
-
-namespace boost {
 namespace intrusive {
 
 ////////////////////////////
@@ -53,11 +44,11 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
- , class O5 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ , class O5 = void
>
 #else
 template<class T, class ...Options>
@@ -66,9 +57,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -77,9 +68,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -90,9 +81,9 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class T, class ...Options>
@@ -101,9 +92,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -112,9 +103,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -123,9 +114,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -136,10 +127,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -149,10 +140,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -162,10 +153,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -174,10 +165,10 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class ...Options>
@@ -186,10 +177,10 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class ...Options>
@@ -200,10 +191,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -213,10 +204,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -226,10 +217,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -238,9 +229,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -249,9 +240,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -262,10 +253,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -275,10 +266,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -288,10 +279,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -300,10 +291,10 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class ...Options>
@@ -312,10 +303,10 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class ...Options>
@@ -327,10 +318,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -340,10 +331,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -353,10 +344,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -371,10 +362,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -384,10 +375,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -397,10 +388,10 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class T, class ...Options>
@@ -409,9 +400,48 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class T
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ >
+#else
+template<class T, class ...Options>
+#endif
+class bstree;
+
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template
+ < class T
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ >
+#else
+template<class T, class ...Options>
+#endif
+class bs_set;
+
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template
+ < class T
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ >
+#else
+template<class T, class ...Options>
+#endif
+class bs_multiset;
+
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -420,9 +450,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -434,16 +464,16 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
- , class O5 = none
- , class O6 = none
- , class O7 = none
- , class O8 = none
- , class O9 = none
- , class O10 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ , class O5 = void
+ , class O6 = void
+ , class O7 = void
+ , class O8 = void
+ , class O9 = void
+ , class O10 = void
>
 #else
 template<class T, class ...Options>
@@ -453,16 +483,16 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
- , class O5 = none
- , class O6 = none
- , class O7 = none
- , class O8 = none
- , class O9 = none
- , class O10 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ , class O5 = void
+ , class O6 = void
+ , class O7 = void
+ , class O8 = void
+ , class O9 = void
+ , class O10 = void
>
 #else
 template<class T, class ...Options>
@@ -472,16 +502,16 @@
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
    < class T
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
- , class O5 = none
- , class O6 = none
- , class O7 = none
- , class O8 = none
- , class O9 = none
- , class O10 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ , class O5 = void
+ , class O6 = void
+ , class O7 = void
+ , class O8 = void
+ , class O9 = void
+ , class O10 = void
>
 #else
 template<class T, class ...Options>
@@ -490,10 +520,10 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class ...Options>
@@ -502,10 +532,10 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
>
 #else
 template<class ...Options>
@@ -514,9 +544,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>
@@ -525,9 +555,9 @@
 
 #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 template
- < class O1 = none
- , class O2 = none
- , class O3 = none
+ < class O1 = void
+ , class O2 = void
+ , class O3 = void
>
 #else
 template<class ...Options>

Modified: branches/release/boost/intrusive/linear_slist_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/linear_slist_algorithms.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/linear_slist_algorithms.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,6 +17,7 @@
 #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/utilities.hpp>
 #include <cstddef>
 #include <utility>
 
@@ -319,6 +320,16 @@
    }
 };
 
+/// @cond
+
+template<class NodeTraits>
+struct get_algo<LinearSListAlgorithms, NodeTraits>
+{
+ typedef linear_slist_algorithms<NodeTraits> type;
+};
+
+/// @endcond
+
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/link_mode.hpp
==============================================================================
--- branches/release/boost/intrusive/link_mode.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/link_mode.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/list.hpp
==============================================================================
--- branches/release/boost/intrusive/list.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/list.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -38,25 +38,13 @@
 
 /// @cond
 
-template <class ValueTraits, class SizeType, bool ConstantTimeSize>
-struct listopt
+struct list_defaults
 {
- typedef ValueTraits value_traits;
- typedef SizeType size_type;
- static const bool constant_time_size = ConstantTimeSize;
+ typedef detail::default_list_hook proto_value_traits;
+ static const bool constant_time_size = true;
+ typedef std::size_t size_type;
 };
 
-
-template <class T>
-struct list_defaults
- : pack_options
- < none
- , base_hook<detail::default_list_hook>
- , constant_time_size<true>
- , size_type<std::size_t>
- >::type
-{};
-
 /// @endcond
 
 //! The class template list is an intrusive container that mimics most of the
@@ -72,23 +60,22 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 class list_impl
- : private detail::clear_on_destructor_base< list_impl<Config> >
+ : private detail::clear_on_destructor_base
+ < list_impl<ValueTraits, SizeType, ConstantTimeSize>
+ , is_safe_autounlink<detail::get_real_value_traits<ValueTraits>::type::link_mode>::value
+ >
 {
- template<class C> friend class detail::clear_on_destructor_base;
+ template<class C, bool> friend class detail::clear_on_destructor_base;
    //Public typedefs
    public:
- typedef typename Config::value_traits value_traits;
+ typedef ValueTraits value_traits;
    /// @cond
    static const bool external_value_traits =
       detail::external_value_traits_bool_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;
+ typedef typename detail::get_real_value_traits<ValueTraits>::type real_value_traits;
    /// @endcond
    typedef typename real_value_traits::pointer pointer;
    typedef typename real_value_traits::const_pointer const_pointer;
@@ -96,9 +83,9 @@
    typedef typename pointer_traits<pointer>::reference reference;
    typedef typename pointer_traits<const_pointer>::reference const_reference;
    typedef typename pointer_traits<pointer>::difference_type difference_type;
- typedef typename Config::size_type size_type;
- typedef list_iterator<list_impl, false> iterator;
- typedef list_iterator<list_impl, true> const_iterator;
+ typedef SizeType size_type;
+ typedef list_iterator<real_value_traits, false> iterator;
+ typedef list_iterator<real_value_traits, true> const_iterator;
    typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator;
    typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator;
    typedef typename real_value_traits::node_traits node_traits;
@@ -107,7 +94,7 @@
    typedef typename node_traits::const_node_ptr const_node_ptr;
    typedef circular_list_algorithms<node_traits> node_algorithms;
 
- static const bool constant_time_size = Config::constant_time_size;
+ static const bool constant_time_size = ConstantTimeSize;
    static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
 
    /// @cond
@@ -118,19 +105,13 @@
    //noncopyable
    BOOST_MOVABLE_BUT_NOT_COPYABLE(list_impl)
 
- enum { safemode_or_autounlink =
- (int)real_value_traits::link_mode == (int)auto_unlink ||
- (int)real_value_traits::link_mode == (int)safe_link };
+ static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value;
 
    //Constant-time size is incompatible with auto-unlink hooks!
    BOOST_STATIC_ASSERT(!(constant_time_size &&
                         ((int)real_value_traits::link_mode == (int)auto_unlink)
                       ));
 
- //Const cast emulation for smart pointers
- static node_ptr uncast(const const_node_ptr & ptr)
- { return pointer_traits<node_ptr>::const_cast_from(ptr); }
-
    node_ptr get_root_node()
    { return pointer_traits<node_ptr>::pointer_to(data_.root_plus_size_.root_); }
 
@@ -145,7 +126,7 @@
    struct data_t : public value_traits
    {
       typedef typename list_impl::value_traits value_traits;
- data_t(const value_traits &val_traits)
+ explicit data_t(const value_traits &val_traits)
          : value_traits(val_traits)
       {}
 
@@ -196,6 +177,11 @@
    real_value_traits &get_real_value_traits()
    { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
 
+ typedef typename pointer_traits<node_ptr>::template rebind_pointer<real_value_traits const>::type const_real_value_traits_ptr;
+
+ const_real_value_traits_ptr real_value_traits_ptr() const
+ { return pointer_traits<const_real_value_traits_ptr>::pointer_to(this->get_real_value_traits()); }
+
    //! <b>Effects</b>: constructs an empty list.
    //!
    //! <b>Complexity</b>: Constant
@@ -241,6 +227,7 @@
    list_impl& operator=(BOOST_RV_REF(list_impl) x)
    { this->swap(x); return *this; }
 
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
    //! <b>Effects</b>: If it's not a safe-mode or an auto-unlink value_type
    //! the destructor does nothing
    //! (ie. no code is generated). Otherwise it detaches all elements from this.
@@ -252,6 +239,7 @@
    //! it's a safe-mode or auto-unlink value . Otherwise constant.
    ~list_impl()
    {}
+ #endif
 
    //! <b>Requires</b>: value must be an lvalue.
    //!
@@ -371,7 +359,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_reference front() const
- { return *get_real_value_traits().to_value_ptr(uncast(node_traits::get_next(this->get_root_node()))); }
+ { return *get_real_value_traits().to_value_ptr(detail::uncast(node_traits::get_next(this->get_root_node()))); }
 
    //! <b>Effects</b>: Returns a reference to the last element of the list.
    //!
@@ -387,7 +375,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_reference back() const
- { return *get_real_value_traits().to_value_ptr(uncast(node_traits::get_previous(this->get_root_node()))); }
+ { return *get_real_value_traits().to_value_ptr(detail::uncast(node_traits::get_previous(this->get_root_node()))); }
 
    //! <b>Effects</b>: Returns an iterator to the first element contained in the list.
    //!
@@ -395,7 +383,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    iterator begin()
- { return iterator(node_traits::get_next(this->get_root_node()), this); }
+ { return iterator(node_traits::get_next(this->get_root_node()), real_value_traits_ptr()); }
 
    //! <b>Effects</b>: Returns a const_iterator to the first element contained in the list.
    //!
@@ -411,7 +399,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_iterator cbegin() const
- { return const_iterator(node_traits::get_next(this->get_root_node()), this); }
+ { return const_iterator(node_traits::get_next(this->get_root_node()), real_value_traits_ptr()); }
 
    //! <b>Effects</b>: Returns an iterator to the end of the list.
    //!
@@ -419,7 +407,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    iterator end()
- { return iterator(this->get_root_node(), this); }
+ { return iterator(this->get_root_node(), real_value_traits_ptr()); }
 
    //! <b>Effects</b>: Returns a const_iterator to the end of the list.
    //!
@@ -435,7 +423,7 @@
    //!
    //! <b>Complexity</b>: Constant.
    const_iterator cend() const
- { return const_iterator(uncast(this->get_root_node()), this); }
+ { return const_iterator(detail::uncast(this->get_root_node()), real_value_traits_ptr()); }
 
    //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
    //! of the reversed list.
@@ -806,7 +794,7 @@
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert));
       node_algorithms::link_before(p.pointed_node(), to_insert);
       this->priv_size_traits().increment();
- return iterator(to_insert, this);
+ return iterator(to_insert, real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: Dereferencing iterator must yield
@@ -1240,7 +1228,7 @@
    {
       BOOST_STATIC_ASSERT((!stateful_value_traits));
       BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(value)));
- return iterator(real_value_traits::to_node_ptr(value), 0);
+ return iterator(real_value_traits::to_node_ptr(value), const_real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be a const reference to a value inserted in a list.
@@ -1258,7 +1246,7 @@
    {
       BOOST_STATIC_ASSERT((!stateful_value_traits));
       BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(const_cast<reference> (value))));
- return const_iterator(real_value_traits::to_node_ptr(const_cast<reference> (value)), 0);
+ return const_iterator(real_value_traits::to_node_ptr(const_cast<reference> (value)), const_real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be a reference to a value inserted in a list.
@@ -1273,7 +1261,7 @@
    iterator iterator_to(reference value)
    {
       BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(value)));
- return iterator(real_value_traits::to_node_ptr(value), this);
+ return iterator(real_value_traits::to_node_ptr(value), real_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be a const reference to a value inserted in a list.
@@ -1288,7 +1276,7 @@
    const_iterator iterator_to(const_reference value) const
    {
       BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::inited(real_value_traits::to_node_ptr(const_cast<reference> (value))));
- return const_iterator(real_value_traits::to_node_ptr(const_cast<reference> (value)), this);
+ return const_iterator(real_value_traits::to_node_ptr(const_cast<reference> (value)), real_value_traits_ptr());
    }
 
    /// @cond
@@ -1309,29 +1297,29 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 inline bool operator<
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
 #else
-(const list_impl<Config> &x, const list_impl<Config> &y)
+(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &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>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 bool operator==
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
 #else
-(const list_impl<Config> &x, const list_impl<Config> &y)
+(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
 #endif
 {
- typedef list_impl<Config> list_type;
+ typedef list_impl<ValueTraits, SizeType, ConstantTimeSize> list_type;
    typedef typename list_type::const_iterator const_iterator;
    const bool C = list_type::constant_time_size;
    if(C && x.size() != y.size()){
@@ -1361,65 +1349,65 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 inline bool operator!=
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
 #else
-(const list_impl<Config> &x, const list_impl<Config> &y)
+(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
 #endif
 { return !(x == y); }
 
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 inline bool operator>
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
 #else
-(const list_impl<Config> &x, const list_impl<Config> &y)
+(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
 #endif
 { return y < x; }
 
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 inline bool operator<=
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
 #else
-(const list_impl<Config> &x, const list_impl<Config> &y)
+(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
 #endif
 { return !(y < x); }
 
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 inline bool operator>=
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (const list_impl<T, Options...> &x, const list_impl<T, Options...> &y)
 #else
-(const list_impl<Config> &x, const list_impl<Config> &y)
+(const list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, const list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
 #endif
 { return !(x < y); }
 
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template <class ValueTraits, class SizeType, bool ConstantTimeSize>
 #endif
 inline void swap
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 (list_impl<T, Options...> &x, list_impl<T, Options...> &y)
 #else
-(list_impl<Config> &x, list_impl<Config> &y)
+(list_impl<ValueTraits, SizeType, ConstantTimeSize> &x, list_impl<ValueTraits, SizeType, ConstantTimeSize> &y)
 #endif
 { x.swap(y); }
 
@@ -1428,13 +1416,13 @@
 #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>
+template<class T, class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_list
 {
    /// @cond
    typedef typename pack_options
- < list_defaults<T>,
+ < list_defaults,
          #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
          O1, O2, O3
          #else
@@ -1443,15 +1431,13 @@
>::type packed_options;
 
    typedef typename detail::get_value_traits
- <T, typename packed_options::value_traits>::type value_traits;
+ <T, typename packed_options::proto_value_traits>::type value_traits;
 
    typedef list_impl
       <
- listopt
- < value_traits
- , typename packed_options::size_type
- , packed_options::constant_time_size
- >
+ value_traits,
+ typename packed_options::size_type,
+ packed_options::constant_time_size
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -1492,7 +1478,7 @@
    typedef typename Base::iterator iterator;
    typedef typename Base::const_iterator const_iterator;
 
- list(const value_traits &v_traits = value_traits())
+ explicit list(const value_traits &v_traits = value_traits())
       : Base(v_traits)
    {}
 
@@ -1506,7 +1492,7 @@
    {}
 
    list& operator=(BOOST_RV_REF(list) x)
- { this->Base::operator=(::boost::move(static_cast<Base&>(x))); return *this; }
+ { return static_cast<list &>(this->Base::operator=(::boost::move(static_cast<Base&>(x)))); }
 
    static list &container_from_end_iterator(iterator end_iterator)
    { return static_cast<list &>(Base::container_from_end_iterator(end_iterator)); }

Modified: branches/release/boost/intrusive/list_hook.hpp
==============================================================================
--- branches/release/boost/intrusive/list_hook.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/list_hook.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,7 +1,7 @@
 /////////////////////////////////////////////////////////////////////////////
 //
 // (C) Copyright Olaf Krzikalla 2004-2006.
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -38,7 +38,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_list_base_hook
 {
@@ -52,11 +52,11 @@
       #endif
>::type packed_options;
 
- typedef detail::generic_hook
+ typedef generic_hook
    < get_list_node_algo<typename packed_options::void_pointer>
    , typename packed_options::tag
    , packed_options::link_mode
- , detail::ListBaseHook
+ , ListBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -165,7 +165,7 @@
 #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>
+template<class O1 = void, class O2 = void, class O3 = void>
 #endif
 struct make_list_member_hook
 {
@@ -179,11 +179,11 @@
       #endif
>::type packed_options;
 
- typedef detail::generic_hook
+ typedef generic_hook
    < get_list_node_algo<typename packed_options::void_pointer>
    , member_tag
    , packed_options::link_mode
- , detail::NoBaseHook
+ , NoBaseHookId
> implementation_defined;
    /// @endcond
    typedef implementation_defined type;

Modified: branches/release/boost/intrusive/member_value_traits.hpp
==============================================================================
--- branches/release/boost/intrusive/member_value_traits.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/member_value_traits.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/options.hpp
==============================================================================
--- branches/release/boost/intrusive/options.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/options.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -26,6 +26,7 @@
 
 /// @cond
 
+//typedef void default_tag;
 struct default_tag;
 struct member_tag;
 
@@ -45,11 +46,13 @@
 
 BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_list_hook);
 BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_slist_hook);
-BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_set_hook);
-BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_uset_hook);
-BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_avl_set_hook);
-BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_splay_set_hook);
-BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_bs_set_hook);
+BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_rbtree_hook);
+BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_hashtable_hook);
+BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_avltree_hook);
+BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_bstree_hook);
+//BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_splaytree_hook);
+//BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_sgtree_hook);
+//BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION(default_treap_hook);
 
 #undef BOOST_INTRUSIVE_DEFAULT_HOOK_MARKER_DEFINITION
 
@@ -61,6 +64,15 @@
    typedef typename ValueTraits::value_traits type;
 };
 
+template<class ValueTraits>
+struct get_real_value_traits
+ : public eval_if_c
+ < external_value_traits_bool_is_true<ValueTraits>::value
+ , eval_value_traits<ValueTraits>
+ , identity<ValueTraits>
+ >
+{};
+
 template <class BucketTraits>
 struct eval_bucket_traits
 {
@@ -70,29 +82,36 @@
 template <class T, class BaseHook>
 struct concrete_hook_base_value_traits
 {
- typedef typename BaseHook::boost_intrusive_tags tags;
- typedef detail::base_hook_traits
+ typedef typename BaseHook::hooktags tags;
+ typedef bhtraits
       < T
       , typename tags::node_traits
       , tags::link_mode
       , typename tags::tag
- , tags::hook_type> type;
+ , tags::type> type;
 };
 
 template <class BaseHook>
 struct concrete_hook_base_node_traits
-{ typedef typename BaseHook::boost_intrusive_tags::node_traits type; };
+{ typedef typename BaseHook::hooktags::node_traits type; };
 
-template <class T, class BaseHook>
+template <class T, class AnyToSomeHook_ProtoValueTraits>
 struct any_hook_base_value_traits
 {
- typedef typename BaseHook::boost_intrusive_tags tags;
- typedef detail::base_hook_traits
+ //AnyToSomeHook value_traits derive from a generic_hook
+ //The generic_hook is configured with any_node_traits
+ //and AnyToSomeHook::value_traits with the correct
+ //node traits for the container, so use node_traits
+ //from AnyToSomeHook_ProtoValueTraits and the rest of
+ //elements from the hooktags member of the generic_hook
+ typedef AnyToSomeHook_ProtoValueTraits proto_value_traits;
+ typedef bhtraits
       < T
- , typename BaseHook::node_traits
- , tags::link_mode
- , typename tags::tag
- , tags::hook_type> type;
+ , typename proto_value_traits::node_traits
+ , proto_value_traits::hooktags::link_mode
+ , typename proto_value_traits::hooktags::tag
+ , proto_value_traits::hooktags::type
+ > type;
 };
 
 template <class BaseHook>
@@ -139,6 +158,7 @@
       ,detail::apply<SupposedValueTraits, T>
       ,detail::identity<SupposedValueTraits>
>::type supposed_value_traits;
+
    //...if it's a default hook
    typedef typename detail::eval_if_c
       < internal_base_hook_bool_is_true<supposed_value_traits>::value
@@ -183,16 +203,6 @@
 
 } //namespace detail{
 
-
-//!This type indicates that no option is being used
-//!and that the default options should be used
-struct none
-{
- template<class Base>
- struct pack : Base
- { };
-};
-
 /// @endcond
 
 //!This option setter specifies if the intrusive
@@ -314,7 +324,7 @@
     template<class Base>
     struct pack : Base
     {
- typedef ValueTraits value_traits;
+ typedef ValueTraits proto_value_traits;
     };
 /// @endcond
 };
@@ -327,7 +337,22 @@
 struct member_hook
 {
 /// @cond
- typedef detail::member_hook_traits
+/*
+ typedef typename MemberHook::hooktags::node_traits node_traits;
+ typedef typename node_traits::node node_type;
+ typedef node_type Parent::* Ptr2MemNode;
+ typedef mhtraits
+ < Parent
+ , node_traits
+ //This cast is really ugly but necessary to reduce template bloat.
+ //Since we control the layout between the hook and the node, and there is
+ //always single inheritance, the offset of the node is exactly the offset of
+ //the hook. Since the node type is shared between all member hooks, this saves
+ //quite a lot of symbol stuff.
+ , (Ptr2MemNode)PtrToMember
+ , MemberHook::hooktags::link_mode> member_value_traits;
+*/
+ typedef mhtraits
       < Parent
       , MemberHook
       , PtrToMember
@@ -335,7 +360,7 @@
    template<class Base>
    struct pack : Base
    {
- typedef member_value_traits value_traits;
+ typedef member_value_traits proto_value_traits;
    };
 /// @endcond
 };
@@ -348,12 +373,12 @@
 struct function_hook
 {
 /// @cond
- typedef detail::function_hook_traits
+ typedef fhtraits
       <Functor> function_value_traits;
    template<class Base>
    struct pack : Base
    {
- typedef function_value_traits value_traits;
+ typedef function_value_traits proto_value_traits;
    };
 /// @endcond
 };
@@ -368,7 +393,7 @@
    template<class Base>
    struct pack : Base
    {
- typedef BaseHook value_traits;
+ typedef BaseHook proto_value_traits;
    };
 /// @endcond
 };
@@ -583,6 +608,13 @@
 
 /// @cond
 
+struct none
+{
+ template<class Base>
+ struct pack : Base
+ {};
+};
+
 //To-do: pass to variadic templates
 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
 
@@ -594,25 +626,25 @@
 };
 
 template<class Prev>
-struct do_pack<Prev, none>
+struct do_pack<Prev, void>
 {
- //Avoid packing "none" to shorten template names
+ //Avoid packing "void" to shorten template names
    typedef Prev type;
 };
 
 template
    < class DefaultOptions
- , class O1 = none
- , class O2 = none
- , class O3 = none
- , class O4 = none
- , class O5 = none
- , class O6 = none
- , class O7 = none
- , class O8 = none
- , class O9 = none
- , class O10 = none
- , class O11 = none
+ , class O1 = void
+ , class O2 = void
+ , class O3 = void
+ , class O4 = void
+ , class O5 = void
+ , class O6 = void
+ , class O7 = void
+ , class O8 = void
+ , class O9 = void
+ , class O10 = void
+ , class O11 = void
>
 struct pack_options
 {
@@ -788,17 +820,15 @@
 #endif
 
 struct hook_defaults
- : public pack_options
- < none
- , void_pointer<void*>
- , link_mode<safe_link>
- , tag<default_tag>
- , optimize_size<false>
- , store_hash<false>
- , linear<false>
- , optimize_multikey<false>
- >::type
-{};
+{
+ typedef void* void_pointer;
+ static const link_mode_type link_mode = safe_link;
+ typedef default_tag tag;
+ static const bool optimize_size = false;
+ static const bool store_hash = false;
+ static const bool linear = false;
+ static const bool optimize_multikey = false;
+};
 
 /// @endcond
 

Modified: branches/release/boost/intrusive/parent_from_member.hpp
==============================================================================
--- branches/release/boost/intrusive/parent_from_member.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/parent_from_member.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2010-2012
+// (C) Copyright Ion Gaztanaga 2010-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/pointer_plus_bits.hpp
==============================================================================
--- branches/release/boost/intrusive/pointer_plus_bits.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/pointer_plus_bits.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2007-2012
+// (C) Copyright Ion Gaztanaga 2007-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at

Modified: branches/release/boost/intrusive/pointer_traits.hpp
==============================================================================
--- branches/release/boost/intrusive/pointer_traits.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/pointer_traits.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -6,7 +6,7 @@
 //
 //////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2011-2012. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2011-2013. 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)
 //
@@ -74,7 +74,7 @@
       typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT
          (boost::intrusive::detail::, Ptr, difference_type, std::ptrdiff_t) difference_type;
       //
- typedef typename boost::intrusive::detail::unvoid<element_type>::type& reference;
+ typedef typename boost::intrusive::detail::unvoid_ref<element_type>::type reference;
       //
       template <class U> struct rebind_pointer
       {
@@ -224,7 +224,7 @@
       //!shall be used instead of rebind<U> to obtain a pointer to U.
       template <class U> using rebind = U*;
    #else
- typedef typename boost::intrusive::detail::unvoid<element_type>::type& reference;
+ typedef typename boost::intrusive::detail::unvoid_ref<element_type>::type reference;
       #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
          template <class U> using rebind = U*;
       #endif

Modified: branches/release/boost/intrusive/priority_compare.hpp
==============================================================================
--- branches/release/boost/intrusive/priority_compare.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/priority_compare.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -31,6 +31,23 @@
    }
 };
 
+/// @cond
+
+template<class Less, class T>
+struct get_prio
+{
+ typedef Less type;
+};
+
+
+template<class T>
+struct get_prio<void, T>
+{
+ typedef ::boost::intrusive::priority_compare<T> type;
+};
+
+/// @endcond
+
 } //namespace intrusive
 } //namespace boost
 

Modified: branches/release/boost/intrusive/rbtree.hpp
==============================================================================
--- branches/release/boost/intrusive/rbtree.hpp Sat Aug 24 06:52:47 2013 (r85444)
+++ branches/release/boost/intrusive/rbtree.hpp 2013-08-24 07:02:18 EDT (Sat, 24 Aug 2013) (r85445)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 //
-// (C) Copyright Ion Gaztanaga 2006-2012
+// (C) Copyright Ion Gaztanaga 2006-2013
 //
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,10 +13,8 @@
 #define BOOST_INTRUSIVE_RBTREE_HPP
 
 #include <boost/intrusive/detail/config_begin.hpp>
-#include <algorithm>
 #include <cstddef>
 #include <functional>
-#include <iterator>
 #include <utility>
 
 #include <boost/intrusive/detail/assert.hpp>
@@ -24,11 +22,11 @@
 #include <boost/intrusive/intrusive_fwd.hpp>
 #include <boost/intrusive/set_hook.hpp>
 #include <boost/intrusive/detail/rbtree_node.hpp>
+#include <boost/intrusive/bstree.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/pointer_traits.hpp>
-#include <boost/intrusive/detail/clear_on_destructor_base.hpp>
 #include <boost/intrusive/detail/function_detector.hpp>
 #include <boost/intrusive/detail/utilities.hpp>
 #include <boost/intrusive/options.hpp>
@@ -41,26 +39,14 @@
 
 /// @cond
 
-template <class ValueTraits, class Compare, class SizeType, bool ConstantTimeSize>
-struct setopt
+struct rbtree_defaults
 {
- typedef ValueTraits value_traits;
- typedef Compare compare;
- typedef SizeType size_type;
- static const bool constant_time_size = ConstantTimeSize;
+ typedef detail::default_rbtree_hook proto_value_traits;
+ static const bool constant_time_size = true;
+ typedef std::size_t size_type;
+ typedef void compare;
 };
 
-template <class T>
-struct set_defaults
- : pack_options
- < none
- , base_hook<detail::default_set_hook>
- , constant_time_size<true>
- , size_type<std::size_t>
- , compare<std::less<T> >
- >::type
-{};
-
 /// @endcond
 
 //! The class template rbtree is an intrusive red-black tree container, that
@@ -79,1633 +65,395 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class Config>
+template<class ValueTraits, class VoidOrKeyComp, class SizeType, bool ConstantTimeSize>
 #endif
 class rbtree_impl
- : private detail::clear_on_destructor_base<rbtree_impl<Config> >
+ /// @cond
+ : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, RbTreeAlgorithms>
+ /// @endcond
 {
- template<class C> friend class detail::clear_on_destructor_base;
    public:
- typedef typename Config::value_traits value_traits;
+ typedef ValueTraits value_traits;
    /// @cond
- static const bool external_value_traits =
- detail::external_value_traits_bool_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;
+ typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
+ , ConstantTimeSize, RbTreeAlgorithms> tree_type;
+ typedef tree_type implementation_defined;
    /// @endcond
- typedef typename real_value_traits::pointer pointer;
- typedef typename real_value_traits::const_pointer const_pointer;
 
- typedef typename pointer_traits<pointer>::element_type value_type;
- typedef value_type key_type;
- typedef typename pointer_traits<pointer>::reference reference;
- typedef typename pointer_traits<const_pointer>::reference const_reference;
- typedef typename pointer_traits<const_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<rbtree_impl, false> iterator;
- typedef tree_iterator<rbtree_impl, true> const_iterator;
- typedef boost::intrusive::detail::reverse_iterator<iterator> reverse_iterator;
- typedef boost::intrusive::detail::reverse_iterator<const_iterator>const_reverse_iterator;
- typedef typename real_value_traits::node_traits node_traits;
- 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 rbtree_algorithms<node_traits> node_algorithms;
+ typedef typename implementation_defined::pointer pointer;
+ typedef typename implementation_defined::const_pointer const_pointer;
+ typedef typename implementation_defined::value_type value_type;
+ typedef typename implementation_defined::key_type key_type;
+ 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::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;
 
- static const bool constant_time_size = Config::constant_time_size;
- static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
+ static const bool constant_time_size = implementation_defined::constant_time_size;
    /// @cond
    private:
- typedef detail::size_holder<constant_time_size, size_type> size_traits;
 
    //noncopyable
    BOOST_MOVABLE_BUT_NOT_COPYABLE(rbtree_impl)
 
- enum { safemode_or_autounlink =
- (int)real_value_traits::link_mode == (int)auto_unlink ||
- (int)real_value_traits::link_mode == (int)safe_link };
+ /// @endcond
 
- //Constant-time size is incompatible with auto-unlink hooks!
- BOOST_STATIC_ASSERT(!(constant_time_size && ((int)real_value_traits::link_mode == (int)auto_unlink)));
+ public:
 
- struct header_plus_size : public size_traits
- { node header_; };
+ typedef typename implementation_defined::insert_commit_data insert_commit_data;
 
- 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_;
- };
+ //! @copydoc ::boost::intrusive::bstree::bstree(const value_compare &,const value_traits &)
+ explicit rbtree_impl( const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(cmp, v_traits)
+ {}
 
- struct data_t : public rbtree_impl::value_traits
- {
- typedef typename rbtree_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_;
+ //! @copydoc ::boost::intrusive::bstree::bstree(bool,Iterator,Iterator,const value_compare &,const value_traits &)
+ template<class Iterator>
+ rbtree_impl( bool unique, Iterator b, Iterator e
+ , const value_compare &cmp = value_compare()
+ , const value_traits &v_traits = value_traits())
+ : tree_type(unique, b, e, cmp, v_traits)
+ {}
 
- const value_compare &priv_comp() const
- { return data_.node_plus_pred_.get(); }
+ //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
+ rbtree_impl(BOOST_RV_REF(rbtree_impl) x)
+ : tree_type(::boost::move(static_cast<tree_type&>(x)))
+ {}
 
- value_compare &priv_comp()
- { return data_.node_plus_pred_.get(); }
+ //! @copydoc ::boost::intrusive::bstree::operator=(bstree &&)
+ rbtree_impl& operator=(BOOST_RV_REF(rbtree_impl) x)
+ { return static_cast<rbtree_impl&>(tree_type::operator=(::boost::move(static_cast<tree_type&>(x)))); }
 
- const value_traits &priv_value_traits() const
- { return data_; }
+ #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
+ //! @copydoc ::boost::intrusive::bstree::~bstree()
+ ~rbtree_impl();
 
- value_traits &priv_value_traits()
- { return data_; }
+ //! @copydoc ::boost::intrusive::bstree::begin()
+ iterator begin();
 
- node_ptr priv_header_ptr()
- { return pointer_traits<node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); }
+ //! @copydoc ::boost::intrusive::bstree::begin()const
+ const_iterator begin() const;
 
- const_node_ptr priv_header_ptr() const
- { return pointer_traits<const_node_ptr>::pointer_to(data_.node_plus_pred_.header_plus_size_.header_); }
+ //! @copydoc ::boost::intrusive::bstree::cbegin()const
+ const_iterator cbegin() const;
 
- static node_ptr uncast(const const_node_ptr & ptr)
- { return pointer_traits<node_ptr>::const_cast_from(ptr); }
+ //! @copydoc ::boost::intrusive::bstree::end()
+ iterator end();
 
- size_traits &priv_size_traits()
- { return data_.node_plus_pred_.header_plus_size_; }
+ //! @copydoc ::boost::intrusive::bstree::end()const
+ const_iterator end() const;
 
- const size_traits &priv_size_traits() const
- { return data_.node_plus_pred_.header_plus_size_; }
+ //! @copydoc ::boost::intrusive::bstree::cend()const
+ const_iterator cend() const;
 
- const real_value_traits &get_real_value_traits(detail::bool_<false>) const
- { return data_; }
+ //! @copydoc ::boost::intrusive::bstree::rbegin()
+ reverse_iterator rbegin();
 
- const real_value_traits &get_real_value_traits(detail::bool_<true>) const
- { return data_.get_value_traits(*this); }
+ //! @copydoc ::boost::intrusive::bstree::rbegin()const
+ const_reverse_iterator rbegin() const;
 
- real_value_traits &get_real_value_traits(detail::bool_<false>)
- { return data_; }
+ //! @copydoc ::boost::intrusive::bstree::crbegin()const
+ const_reverse_iterator crbegin() const;
 
- real_value_traits &get_real_value_traits(detail::bool_<true>)
- { return data_.get_value_traits(*this); }
+ //! @copydoc ::boost::intrusive::bstree::rend()
+ reverse_iterator rend();
 
- protected:
- value_compare &prot_comp()
- { return priv_comp(); }
+ //! @copydoc ::boost::intrusive::bstree::rend()const
+ const_reverse_iterator rend() const;
 
- const node &prot_header_node() const
- { return data_.node_plus_pred_.header_plus_size_.header_; }
+ //! @copydoc ::boost::intrusive::bstree::crend()const
+ const_reverse_iterator crend() const;
 
- node &prot_header_node()
- { return data_.node_plus_pred_.header_plus_size_.header_; }
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(iterator)
+ static rbtree_impl &container_from_end_iterator(iterator end_iterator);
 
- void prot_set_size(size_type s)
- { this->priv_size_traits().set_size(s); }
+ //! @copydoc ::boost::intrusive::bstree::container_from_end_iterator(const_iterator)
+ static const rbtree_impl &container_from_end_iterator(const_iterator end_iterator);
 
- /// @endcond
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(iterator)
+ static rbtree_impl &container_from_iterator(iterator it);
 
- public:
+ //! @copydoc ::boost::intrusive::bstree::container_from_iterator(const_iterator)
+ static const rbtree_impl &container_from_iterator(const_iterator it);
 
- const real_value_traits &get_real_value_traits() const
- { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+ //! @copydoc ::boost::intrusive::bstree::key_comp()const
+ key_compare key_comp() const;
 
- real_value_traits &get_real_value_traits()
- { return this->get_real_value_traits(detail::bool_<external_value_traits>()); }
+ //! @copydoc ::boost::intrusive::bstree::value_comp()const
+ value_compare value_comp() const;
 
- typedef typename node_algorithms::insert_commit_data insert_commit_data;
+ //! @copydoc ::boost::intrusive::bstree::empty()const
+ bool empty() const;
 
- //! <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 constructorof the value_compare object throws. Basic guarantee.
- explicit rbtree_impl( const value_compare &cmp = value_compare()
- , const value_traits &v_traits = value_traits())
- : data_(cmp, v_traits)
- {
- node_algorithms::init_header(this->priv_header_ptr());
- 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>
- rbtree_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(this->priv_header_ptr());
- this->priv_size_traits().set_size(size_type(0));
- if(unique)
- this->insert_unique(b, e);
- else
- this->insert_equal(b, e);
- }
+ //! @copydoc ::boost::intrusive::bstree::size()const
+ size_type size() const;
 
- //! <b>Effects</b>: to-do
- //!
- rbtree_impl(BOOST_RV_REF(rbtree_impl) x)
- : data_(::boost::move(x.priv_comp()), ::boost::move(x.priv_value_traits()))
- {
- node_algorithms::init_header(this->priv_header_ptr());
- this->priv_size_traits().set_size(size_type(0));
- this->swap(x);
- }
+ //! @copydoc ::boost::intrusive::bstree::swap
+ void swap(rbtree_impl& other);
 
- //! <b>Effects</b>: to-do
- //!
- rbtree_impl& operator=(BOOST_RV_REF(rbtree_impl) x)
- { this->swap(x); return *this; }
+ //! @copydoc ::boost::intrusive::bstree::clone_from
+ template <class Cloner, class Disposer>
+ void clone_from(const rbtree_impl &src, Cloner cloner, Disposer disposer);
 
- //! <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.
- ~rbtree_impl()
- {}
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(reference)
+ iterator insert_equal(reference value);
 
- //! <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(this->priv_header_ptr()), 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(this->priv_header_ptr()), 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 (this->priv_header_ptr(), 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(this->priv_header_ptr()), 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 rbtree.
- //!
- //! <b>Effects</b>: Returns a const reference to the rbtree associated to the end iterator
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- static rbtree_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 rbtree.
- //!
- //! <b>Effects</b>: Returns a const reference to the rbtree associated to the iterator
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Constant.
- static const rbtree_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 rbtree_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 end iterator
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Complexity</b>: Logarithmic.
- static const rbtree_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(this->priv_header_ptr()); }
-
- //! <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(this->priv_header_ptr());
- }
- }
-
- //! <b>Effects</b>: Swaps the contents of two rbtrees.
- //!
- //! <b>Complexity</b>: Constant.
- //!
- //! <b>Throws</b>: If the comparison functor's swap call throws.
- void swap(rbtree_impl& other)
- {
- //This can throw
- using std::swap;
- swap(priv_comp(), priv_comp());
- //These can't throw
- node_algorithms::swap_tree(this->priv_header_ptr(), node_ptr(other.priv_header_ptr()));
- 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, rbtree_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));
- iterator ret(node_algorithms::insert_equal_upper_bound
- (this->priv_header_ptr(), to_insert, key_node_comp), this);
- this->priv_size_traits().increment();
- return ret;
- }
-
- //! <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, rbtree_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));
- iterator ret(node_algorithms::insert_equal
- (this->priv_header_ptr(), hint.pointed_node(), to_insert, key_node_comp), this);
- this->priv_size_traits().increment();
- return ret;
- }
-
- //! <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 iend(this->end());
- for (; b != e; ++b)
- this->insert_equal(iend, *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.
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(const_iterator,reference)
+ iterator insert_equal(const_iterator hint, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_equal(Iterator,Iterator)
    template<class Iterator>
- void insert_unique(Iterator b, Iterator e)
- {
- if(this->empty()){
- iterator iend(this->end());
- for (; b != e; ++b)
- this->insert_unique(iend, *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.
+ void insert_equal(Iterator b, Iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(reference)
+ std::pair<iterator, bool> insert_unique(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(const_iterator,reference)
+ iterator insert_unique(const_iterator hint, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const KeyType&,KeyValueCompare,insert_commit_data&)
    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, rbtree_impl>
- comp(key_value_comp, this);
- std::pair<node_ptr, bool> ret =
- (node_algorithms::insert_unique_check
- (this->priv_header_ptr(), 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.
+ (const KeyType &key, KeyValueCompare key_value_comp, insert_commit_data &commit_data);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_check(const_iterator,const KeyType&,KeyValueCompare,insert_commit_data&)
    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, rbtree_impl>
- comp(key_value_comp, this);
- std::pair<node_ptr, bool> ret =
- (node_algorithms::insert_unique_check
- (this->priv_header_ptr(), 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));
- node_algorithms::insert_unique_commit
- (this->priv_header_ptr(), to_insert, commit_data);
- this->priv_size_traits().increment();
- return iterator(to_insert, this);
- }
-
- //! <b>Requires</b>: value must be an lvalue, "pos" must be
- //! a valid iterator (or end) and must be the succesor of value
- //! once inserted according to the predicate
- //!
- //! <b>Effects</b>: Inserts x into the tree before "pos".
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if "pos" is not
- //! the successor of "value" tree ordering invariant will be broken.
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- iterator insert_before(const_iterator pos, reference value)
- {
- 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_before
- (this->priv_header_ptr(), pos.pointed_node(), to_insert), this);
- }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be no less
- //! than the greatest inserted key
- //!
- //! <b>Effects</b>: Inserts x into the tree in the last position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! less than the greatest inserted key tree ordering invariant will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_back(reference value)
- {
- 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::push_back(this->priv_header_ptr(), to_insert);
- }
-
- //! <b>Requires</b>: value must be an lvalue, and it must be no greater
- //! than the minimum inserted key
- //!
- //! <b>Effects</b>: Inserts x into the tree in the first position.
- //!
- //! <b>Complexity</b>: Constant time.
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: This function does not check preconditions so if value is
- //! greater than the minimum inserted key tree ordering invariant will be broken.
- //! This function is slightly more efficient than using "insert_before".
- //! This is a low-level function to be used only for performance reasons
- //! by advanced users.
- void push_front(reference value)
- {
- 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::push_front(this->priv_header_ptr(), to_insert);
- }
-
- //! <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(this->priv_header_ptr(), 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.
+ ,KeyValueCompare key_value_comp, insert_commit_data &commit_data);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique_commit
+ iterator insert_unique_commit(reference value, const insert_commit_data &commit_data);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_unique(Iterator,Iterator)
+ template<class Iterator>
+ void insert_unique(Iterator b, Iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::insert_before
+ iterator insert_before(const_iterator pos, reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_back
+ void push_back(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::push_front
+ void push_front(reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator)
+ iterator erase(const_iterator i);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_iterator,const_iterator)
+ iterator erase(const_iterator b, const_iterator e);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const_reference)
+ size_type erase(const_reference value);
+
+ //! @copydoc ::boost::intrusive::bstree::erase(const KeyType&,KeyValueCompare)
    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;
- }
+ size_type erase(const KeyType& key, KeyValueCompare comp);
 
- #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,Disposer)
    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 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.
+ iterator erase_and_dispose(const_iterator i, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_iterator,const_iterator,Disposer)
    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 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.
+ iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const_reference, Disposer)
    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); }
+ size_type erase_and_dispose(const_reference value, Disposer 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() + N).
- //!
- //! <b>Throws</b>: Nothing.
- //!
- //! <b>Note</b>: Invalidates the iterators
- //! to the erased elements.
+ //! @copydoc ::boost::intrusive::bstree::erase_and_dispose(const KeyType&,KeyValueCompare,Disposer)
    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(this->priv_header_ptr());
- 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.
+ size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::clear
+ void clear();
+
+ //! @copydoc ::boost::intrusive::bstree::clear_and_dispose
    template<class Disposer>
- void clear_and_dispose(Disposer disposer)
- {
- node_algorithms::clear_and_dispose(this->priv_header_ptr()
- , detail::node_disposer<Disposer, rbtree_impl>(disposer, this));
- node_algorithms::init_header(this->priv_header_ptr());
- 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.
+ void clear_and_dispose(Disposer disposer);
+
+ //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
+ size_type count(const_reference value) const;
+
+ //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
    template<class KeyType, class KeyValueCompare>
- size_type