Chris@16: ///////////////////////////////////////////////////////////////////////////// Chris@16: // Chris@16: // (C) Copyright Olaf Krzikalla 2004-2006. Chris@101: // (C) Copyright Ion Gaztanaga 2006-2014 Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. Chris@16: // (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // See http://www.boost.org/libs/intrusive for documentation. Chris@16: // Chris@16: ///////////////////////////////////////////////////////////////////////////// Chris@16: Chris@16: #ifndef BOOST_INTRUSIVE_SLIST_HPP Chris@16: #define BOOST_INTRUSIVE_SLIST_HPP Chris@16: Chris@16: #include Chris@101: #include Chris@101: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: Chris@101: #include Chris@101: #include Chris@101: Chris@101: #include //std::less Chris@16: #include //std::size_t Chris@101: #include //std::pair Chris@101: Chris@101: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@101: # pragma once Chris@101: #endif Chris@16: Chris@16: namespace boost { Chris@16: namespace intrusive { Chris@16: Chris@16: /// @cond Chris@16: Chris@101: template Chris@101: struct header_holder_plus_last Chris@16: { Chris@101: HeaderHolder header_holder_; Chris@16: NodePtr last_; Chris@16: }; Chris@16: Chris@101: template Chris@101: struct header_holder_plus_last Chris@16: { Chris@101: HeaderHolder header_holder_; Chris@16: }; Chris@16: Chris@101: struct default_slist_hook_applier Chris@101: { template struct apply{ typedef typename T::default_slist_hook type; }; }; Chris@101: Chris@101: template<> Chris@101: struct is_default_hook_tag Chris@101: { static const bool value = true; }; Chris@101: Chris@16: struct slist_defaults Chris@16: { Chris@101: typedef default_slist_hook_applier proto_value_traits; Chris@16: static const bool constant_time_size = true; Chris@16: static const bool linear = false; Chris@16: typedef std::size_t size_type; Chris@16: static const bool cache_last = false; Chris@101: typedef void header_holder_type; Chris@16: }; Chris@16: Chris@16: struct slist_bool_flags Chris@16: { Chris@16: static const std::size_t linear_pos = 1u; Chris@16: static const std::size_t constant_time_size_pos = 2u; Chris@16: static const std::size_t cache_last_pos = 4u; Chris@16: }; Chris@16: Chris@16: Chris@16: /// @endcond Chris@16: Chris@16: //! The class template slist is an intrusive container, that encapsulates Chris@16: //! a singly-linked list. You can use such a list to squeeze the last bit Chris@16: //! of performance from your application. Unfortunately, the little gains Chris@16: //! come with some huge drawbacks. A lot of member functions can't be Chris@16: //! implemented as efficiently as for standard containers. To overcome Chris@16: //! this limitation some other member functions with rather unusual semantics Chris@16: //! have to be introduced. Chris@16: //! Chris@16: //! The template parameter \c T is the type to be managed by the container. Chris@16: //! The user can specify additional options and if no options are provided Chris@16: //! default options are used. Chris@16: //! Chris@16: //! The container supports the following options: Chris@16: //! \c base_hook<>/member_hook<>/value_traits<>, Chris@16: //! \c constant_time_size<>, \c size_type<>, Chris@16: //! \c linear<> and \c cache_last<>. Chris@16: //! Chris@16: //! The iterators of slist are forward iterators. slist provides a static Chris@16: //! function called "previous" to compute the previous iterator of a given iterator. Chris@16: //! This function has linear complexity. To improve the usability esp. with Chris@16: //! the '*_after' functions, ++end() == begin() and previous(begin()) == end() Chris@16: //! are defined. An new special function "before_begin()" is defined, which returns Chris@16: //! an iterator that points one less the beginning of the list: ++before_begin() == begin() Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: class slist_impl Chris@16: { Chris@16: //Public typedefs Chris@16: public: Chris@16: typedef ValueTraits value_traits; Chris@101: typedef typename value_traits::pointer pointer; Chris@101: typedef typename value_traits::const_pointer const_pointer; Chris@16: typedef typename pointer_traits::element_type value_type; Chris@16: typedef typename pointer_traits::reference reference; Chris@16: typedef typename pointer_traits::reference const_reference; Chris@16: typedef typename pointer_traits::difference_type difference_type; Chris@16: typedef SizeType size_type; Chris@101: typedef slist_iterator iterator; Chris@101: typedef slist_iterator const_iterator; Chris@101: typedef typename value_traits::node_traits node_traits; Chris@16: typedef typename node_traits::node node; Chris@16: typedef typename node_traits::node_ptr node_ptr; Chris@16: typedef typename node_traits::const_node_ptr const_node_ptr; Chris@101: typedef typename detail::get_header_holder_type Chris@101: < value_traits, HeaderHolder >::type header_holder_type; Chris@16: Chris@16: static const bool constant_time_size = 0 != (BoolFlags & slist_bool_flags::constant_time_size_pos); Chris@101: static const bool stateful_value_traits = detail::is_stateful_value_traits::value; Chris@16: static const bool linear = 0 != (BoolFlags & slist_bool_flags::linear_pos); Chris@16: static const bool cache_last = 0 != (BoolFlags & slist_bool_flags::cache_last_pos); Chris@101: static const bool has_container_from_iterator = Chris@101: detail::is_same< header_holder_type, detail::default_header_holder< node_traits > >::value; Chris@16: Chris@16: typedef typename detail::if_c Chris@16: < linear Chris@16: , linear_slist_algorithms Chris@16: , circular_slist_algorithms Chris@16: >::type node_algorithms; Chris@16: Chris@16: /// @cond Chris@16: private: Chris@16: typedef detail::size_holder size_traits; Chris@16: Chris@16: //noncopyable Chris@16: BOOST_MOVABLE_BUT_NOT_COPYABLE(slist_impl) Chris@16: Chris@101: static const bool safemode_or_autounlink = is_safe_autounlink::value; Chris@16: Chris@16: //Constant-time size is incompatible with auto-unlink hooks! Chris@101: BOOST_STATIC_ASSERT(!(constant_time_size && ((int)value_traits::link_mode == (int)auto_unlink))); Chris@16: //Linear singly linked lists are incompatible with auto-unlink hooks! Chris@101: BOOST_STATIC_ASSERT(!(linear && ((int)value_traits::link_mode == (int)auto_unlink))); Chris@16: //A list with cached last node is incompatible with auto-unlink hooks! Chris@101: BOOST_STATIC_ASSERT(!(cache_last && ((int)value_traits::link_mode == (int)auto_unlink))); Chris@16: Chris@16: node_ptr get_end_node() Chris@16: { return node_ptr(linear ? node_ptr() : this->get_root_node()); } Chris@16: Chris@16: const_node_ptr get_end_node() const Chris@16: { Chris@16: return const_node_ptr Chris@16: (linear ? const_node_ptr() : this->get_root_node()); } Chris@16: Chris@16: node_ptr get_root_node() Chris@101: { return data_.root_plus_size_.header_holder_.get_node(); } Chris@16: Chris@16: const_node_ptr get_root_node() const Chris@101: { return data_.root_plus_size_.header_holder_.get_node(); } Chris@16: Chris@16: node_ptr get_last_node() Chris@16: { return this->get_last_node(detail::bool_()); } Chris@16: Chris@16: const_node_ptr get_last_node() const Chris@16: { return this->get_last_node(detail::bool_()); } Chris@16: Chris@16: void set_last_node(const node_ptr &n) Chris@16: { return this->set_last_node(n, detail::bool_()); } Chris@16: Chris@16: static node_ptr get_last_node(detail::bool_) Chris@16: { Chris@16: //This function shall not be used if cache_last is not true Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last); Chris@16: return node_ptr(); Chris@16: } Chris@16: Chris@16: static void set_last_node(const node_ptr &, detail::bool_) Chris@16: { Chris@16: //This function shall not be used if cache_last is not true Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last); Chris@16: } Chris@16: Chris@16: node_ptr get_last_node(detail::bool_) Chris@16: { return node_ptr(data_.root_plus_size_.last_); } Chris@16: Chris@16: const_node_ptr get_last_node(detail::bool_) const Chris@16: { return const_node_ptr(data_.root_plus_size_.last_); } Chris@16: Chris@16: void set_last_node(const node_ptr & n, detail::bool_) Chris@16: { data_.root_plus_size_.last_ = n; } Chris@16: Chris@16: void set_default_constructed_state() Chris@16: { Chris@16: node_algorithms::init_header(this->get_root_node()); Chris@16: this->priv_size_traits().set_size(size_type(0)); Chris@16: if(cache_last){ Chris@16: this->set_last_node(this->get_root_node()); Chris@16: } Chris@16: } Chris@16: Chris@101: typedef header_holder_plus_last header_holder_plus_last_t; Chris@16: struct root_plus_size Chris@16: : public size_traits Chris@101: , public header_holder_plus_last_t Chris@16: {}; Chris@16: Chris@16: struct data_t Chris@16: : public slist_impl::value_traits Chris@16: { Chris@16: typedef typename slist_impl::value_traits value_traits; Chris@16: explicit data_t(const value_traits &val_traits) Chris@16: : value_traits(val_traits) Chris@16: {} Chris@16: Chris@16: root_plus_size root_plus_size_; Chris@16: } data_; Chris@16: Chris@16: size_traits &priv_size_traits() Chris@16: { return data_.root_plus_size_; } Chris@16: Chris@16: const size_traits &priv_size_traits() const Chris@16: { return data_.root_plus_size_; } Chris@16: Chris@16: const value_traits &priv_value_traits() const Chris@16: { return data_; } Chris@16: Chris@16: value_traits &priv_value_traits() Chris@16: { return data_; } Chris@16: Chris@101: typedef typename boost::intrusive::value_traits_pointers Chris@101: ::const_value_traits_ptr const_value_traits_ptr; Chris@16: Chris@101: const_value_traits_ptr priv_value_traits_ptr() const Chris@101: { return pointer_traits::pointer_to(this->priv_value_traits()); } Chris@16: Chris@16: /// @endcond Chris@16: Chris@16: public: Chris@16: Chris@16: ///@cond Chris@16: Chris@16: //! Requires: f and before_l belong to another slist. Chris@16: //! Chris@16: //! Effects: Transfers the range [f, before_l] to this Chris@16: //! list, after the element pointed by prev_pos. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements transferred Chris@16: //! if constant_time_size is true. Constant-time otherwise. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: //! Chris@16: //! Warning: Experimental function, don't use it! Chris@16: slist_impl( const node_ptr & f, const node_ptr & before_l Chris@16: , size_type n, const value_traits &v_traits = value_traits()) Chris@16: : data_(v_traits) Chris@16: { Chris@16: if(n){ Chris@16: this->priv_size_traits().set_size(n); Chris@16: if(cache_last){ Chris@16: this->set_last_node(before_l); Chris@16: } Chris@16: node_traits::set_next(this->get_root_node(), f); Chris@16: node_traits::set_next(before_l, this->get_end_node()); Chris@16: } Chris@16: else{ Chris@16: this->set_default_constructed_state(); Chris@16: } Chris@16: } Chris@16: Chris@16: ///@endcond Chris@16: Chris@16: //! Effects: constructs an empty list. Chris@16: //! Chris@16: //! Complexity: Constant Chris@16: //! Chris@16: //! Throws: If value_traits::node_traits::node Chris@16: //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). Chris@16: explicit slist_impl(const value_traits &v_traits = value_traits()) Chris@16: : data_(v_traits) Chris@16: { this->set_default_constructed_state(); } Chris@16: Chris@16: //! Requires: Dereferencing iterator must yield an lvalue of type value_type. Chris@16: //! Chris@16: //! Effects: Constructs a list equal to [b ,e). Chris@16: //! Chris@101: //! Complexity: Linear in distance(b, e). No copy constructors are called. Chris@16: //! Chris@16: //! Throws: If value_traits::node_traits::node Chris@16: //! constructor throws (this does not happen with predefined Boost.Intrusive hooks). Chris@16: template Chris@16: slist_impl(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) Chris@16: : data_(v_traits) Chris@16: { Chris@16: this->set_default_constructed_state(); Chris@101: //nothrow, no need to rollback to release elements on exception Chris@16: this->insert_after(this->cbefore_begin(), b, e); Chris@16: } Chris@16: Chris@16: //! Effects: to-do Chris@16: //! Chris@16: slist_impl(BOOST_RV_REF(slist_impl) x) Chris@16: : data_(::boost::move(x.priv_value_traits())) Chris@16: { Chris@16: this->priv_size_traits().set_size(size_type(0)); Chris@16: node_algorithms::init_header(this->get_root_node()); Chris@101: //nothrow, no need to rollback to release elements on exception Chris@16: this->swap(x); Chris@16: } Chris@16: Chris@16: //! Effects: to-do Chris@16: //! Chris@16: slist_impl& operator=(BOOST_RV_REF(slist_impl) x) Chris@16: { this->swap(x); return *this; } Chris@16: Chris@16: //! Effects: If it's a safe-mode Chris@16: //! or auto-unlink value, the destructor does nothing Chris@16: //! (ie. no code is generated). Otherwise it detaches all elements from this. Chris@16: //! In this case the objects in the list are not deleted (i.e. no destructors Chris@16: //! are called), but the hooks according to the value_traits template parameter Chris@16: //! are set to their default value. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements in the list, if Chris@16: //! it's a safe-mode or auto-unlink value. Otherwise constant. Chris@16: ~slist_impl() Chris@101: { Chris@101: if(is_safe_autounlink::value){ Chris@101: this->clear(); Chris@101: node_algorithms::init(this->get_root_node()); Chris@101: } Chris@101: } Chris@16: Chris@16: //! Effects: Erases all the elements of the container. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements of the list. Chris@16: //! if it's a safe-mode or auto-unlink value_type. Constant time otherwise. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the erased elements. Chris@16: void clear() Chris@16: { Chris@16: if(safemode_or_autounlink){ Chris@16: this->clear_and_dispose(detail::null_disposer()); Chris@16: } Chris@16: else{ Chris@16: this->set_default_constructed_state(); Chris@16: } Chris@16: } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Erases all the elements of the container Chris@16: //! Disposer::operator()(pointer) is called for the removed elements. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements of the list. Chris@16: //! Chris@16: //! Note: Invalidates the iterators to the erased elements. Chris@16: template Chris@16: void clear_and_dispose(Disposer disposer) Chris@16: { Chris@16: const_iterator it(this->begin()), itend(this->end()); Chris@16: while(it != itend){ Chris@16: node_ptr to_erase(it.pointed_node()); Chris@16: ++it; Chris@16: if(safemode_or_autounlink) Chris@16: node_algorithms::init(to_erase); Chris@101: disposer(priv_value_traits().to_value_ptr(to_erase)); Chris@16: } Chris@16: this->set_default_constructed_state(); Chris@16: } Chris@16: Chris@16: //! Requires: value must be an lvalue. Chris@16: //! Chris@16: //! Effects: Inserts the value in the front of the list. Chris@16: //! No copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: void push_front(reference value) Chris@16: { Chris@101: node_ptr to_insert = priv_value_traits().to_node_ptr(value); Chris@16: if(safemode_or_autounlink) Chris@16: BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(to_insert)); Chris@16: if(cache_last){ Chris@16: if(this->empty()){ Chris@16: this->set_last_node(to_insert); Chris@16: } Chris@16: } Chris@16: node_algorithms::link_after(this->get_root_node(), to_insert); Chris@16: this->priv_size_traits().increment(); Chris@16: } Chris@16: Chris@16: //! Requires: value must be an lvalue. Chris@16: //! Chris@16: //! Effects: Inserts the value in the back of the list. Chris@16: //! No copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: //! This function is only available is cache_last<> is true. Chris@16: void push_back(reference value) Chris@16: { Chris@16: BOOST_STATIC_ASSERT((cache_last)); Chris@101: node_ptr n = priv_value_traits().to_node_ptr(value); Chris@16: if(safemode_or_autounlink) Chris@16: BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(n)); Chris@16: node_algorithms::link_after(this->get_last_node(), n); Chris@16: if(cache_last){ Chris@16: this->set_last_node(n); Chris@16: } Chris@16: this->priv_size_traits().increment(); Chris@16: } Chris@16: Chris@16: //! Effects: Erases the first element of the list. Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the erased element. Chris@16: void pop_front() Chris@16: { return this->pop_front_and_dispose(detail::null_disposer()); } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Erases the first element of the list. Chris@16: //! Disposer::operator()(pointer) is called for the removed element. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Invalidates the iterators to the erased element. Chris@16: template Chris@16: void pop_front_and_dispose(Disposer disposer) Chris@16: { Chris@16: node_ptr to_erase = node_traits::get_next(this->get_root_node()); Chris@16: node_algorithms::unlink_after(this->get_root_node()); Chris@16: this->priv_size_traits().decrement(); Chris@16: if(safemode_or_autounlink) Chris@16: node_algorithms::init(to_erase); Chris@101: disposer(priv_value_traits().to_value_ptr(to_erase)); Chris@16: if(cache_last){ Chris@16: if(this->empty()){ Chris@16: this->set_last_node(this->get_root_node()); Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: //! Effects: Returns a reference to the first element of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: reference front() Chris@101: { return *this->priv_value_traits().to_value_ptr(node_traits::get_next(this->get_root_node())); } Chris@16: Chris@16: //! Effects: Returns a const_reference to the first element of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_reference front() const Chris@101: { return *this->priv_value_traits().to_value_ptr(detail::uncast(node_traits::get_next(this->get_root_node()))); } Chris@16: Chris@16: //! Effects: Returns a reference to the last element of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: //! This function is only available is cache_last<> is true. Chris@16: reference back() Chris@16: { Chris@16: BOOST_STATIC_ASSERT((cache_last)); Chris@101: return *this->priv_value_traits().to_value_ptr(this->get_last_node()); Chris@16: } Chris@16: Chris@16: //! Effects: Returns a const_reference to the last element of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: //! This function is only available is cache_last<> is true. Chris@16: const_reference back() const Chris@16: { Chris@16: BOOST_STATIC_ASSERT((cache_last)); Chris@101: return *this->priv_value_traits().to_value_ptr(this->get_last_node()); Chris@16: } Chris@16: Chris@16: //! Effects: Returns an iterator to the first element contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: iterator begin() Chris@101: { return iterator (node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns a const_iterator to the first element contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_iterator begin() const Chris@101: { return const_iterator (node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns a const_iterator to the first element contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_iterator cbegin() const Chris@101: { return const_iterator(node_traits::get_next(this->get_root_node()), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns an iterator to the end of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: iterator end() Chris@101: { return iterator(this->get_end_node(), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns a const_iterator to the end of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_iterator end() const Chris@101: { return const_iterator(detail::uncast(this->get_end_node()), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns a const_iterator to the end of the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_iterator cend() const Chris@16: { return this->end(); } Chris@16: Chris@16: //! Effects: Returns an iterator that points to a position Chris@16: //! before the first element. Equivalent to "end()" Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: iterator before_begin() Chris@101: { return iterator(this->get_root_node(), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns an iterator that points to a position Chris@16: //! before the first element. Equivalent to "end()" Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_iterator before_begin() const Chris@101: { return const_iterator(detail::uncast(this->get_root_node()), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Effects: Returns an iterator that points to a position Chris@16: //! before the first element. Equivalent to "end()" Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: const_iterator cbefore_begin() const Chris@16: { return this->before_begin(); } Chris@16: Chris@16: //! Effects: Returns an iterator to the last element contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: This function is present only if cached_last<> option is true. Chris@16: iterator last() Chris@16: { Chris@16: //This function shall not be used if cache_last is not true Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last); Chris@101: return iterator (this->get_last_node(), this->priv_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Effects: Returns a const_iterator to the last element contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: This function is present only if cached_last<> option is true. Chris@16: const_iterator last() const Chris@16: { Chris@16: //This function shall not be used if cache_last is not true Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT(cache_last); Chris@101: return const_iterator (this->get_last_node(), this->priv_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Effects: Returns a const_iterator to the last element contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: This function is present only if cached_last<> option is true. Chris@16: const_iterator clast() const Chris@101: { return const_iterator(this->get_last_node(), this->priv_value_traits_ptr()); } Chris@16: Chris@16: //! Precondition: end_iterator must be a valid end iterator Chris@16: //! of slist. Chris@16: //! Chris@16: //! Effects: Returns a const reference to the slist associated to the end iterator Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: static slist_impl &container_from_end_iterator(iterator end_iterator) Chris@16: { return slist_impl::priv_container_from_end_iterator(end_iterator); } Chris@16: Chris@16: //! Precondition: end_iterator must be a valid end const_iterator Chris@16: //! of slist. Chris@16: //! Chris@16: //! Effects: Returns a const reference to the slist associated to the end iterator Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: static const slist_impl &container_from_end_iterator(const_iterator end_iterator) Chris@16: { return slist_impl::priv_container_from_end_iterator(end_iterator); } Chris@16: Chris@16: //! Effects: Returns the number of the elements contained in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements contained in the list. Chris@16: //! if constant_time_size is false. Constant time otherwise. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: size_type size() const Chris@16: { Chris@16: if(constant_time_size) Chris@16: return this->priv_size_traits().get_size(); Chris@16: else Chris@16: return node_algorithms::count(this->get_root_node()) - 1; Chris@16: } Chris@16: Chris@16: //! Effects: Returns true if the list contains no elements. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: bool empty() const Chris@16: { return node_algorithms::unique(this->get_root_node()); } Chris@16: Chris@16: //! Effects: Swaps the elements of x and *this. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements of both lists. Chris@16: //! Constant-time if linear<> and/or cache_last<> options are used. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: void swap(slist_impl& other) Chris@16: { Chris@16: if(cache_last){ Chris@16: priv_swap_cache_last(this, &other); Chris@16: } Chris@16: else{ Chris@16: this->priv_swap_lists(this->get_root_node(), other.get_root_node(), detail::bool_()); Chris@16: } Chris@16: if(constant_time_size){ Chris@16: size_type backup = this->priv_size_traits().get_size(); Chris@16: this->priv_size_traits().set_size(other.priv_size_traits().get_size()); Chris@16: other.priv_size_traits().set_size(backup); Chris@16: } Chris@16: } Chris@16: Chris@16: //! Effects: Moves backwards all the elements, so that the first Chris@16: //! element becomes the second, the second becomes the third... Chris@16: //! the last element becomes the first one. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements plus the number shifts. Chris@16: //! Chris@16: //! Note: Iterators Does not affect the validity of iterators and references. Chris@16: void shift_backwards(size_type n = 1) Chris@16: { this->priv_shift_backwards(n, detail::bool_()); } Chris@16: Chris@16: //! Effects: Moves forward all the elements, so that the second Chris@16: //! element becomes the first, the third becomes the second... Chris@16: //! the first element becomes the last one. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements plus the number shifts. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: void shift_forward(size_type n = 1) Chris@16: { this->priv_shift_forward(n, detail::bool_()); } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Cloner should yield to nodes equivalent to the original nodes. Chris@16: //! Chris@16: //! Effects: Erases all the elements from *this Chris@16: //! calling Disposer::operator()(pointer), clones all the Chris@16: //! elements from src calling Cloner::operator()(const_reference ) Chris@16: //! and inserts them on *this. Chris@16: //! Chris@16: //! If cloner throws, all cloned elements are unlinked and disposed Chris@16: //! calling Disposer::operator()(pointer). Chris@16: //! Chris@16: //! Complexity: Linear to erased plus inserted elements. Chris@16: //! Chris@16: //! Throws: If cloner throws. Chris@16: template Chris@16: void clone_from(const slist_impl &src, Cloner cloner, Disposer disposer) Chris@16: { Chris@16: this->clear_and_dispose(disposer); Chris@16: detail::exception_disposer Chris@16: rollback(*this, disposer); Chris@16: const_iterator prev(this->cbefore_begin()); Chris@16: const_iterator b(src.begin()), e(src.end()); Chris@16: for(; b != e; ++b){ Chris@16: prev = this->insert_after(prev, *cloner(*b)); Chris@16: } Chris@16: rollback.release(); Chris@16: } Chris@16: Chris@16: //! Requires: value must be an lvalue and prev_p must point to an element Chris@16: //! contained by the list or to end(). Chris@16: //! Chris@16: //! Effects: Inserts the value after the position pointed by prev_p. Chris@16: //! No copy constructor is called. Chris@16: //! Chris@16: //! Returns: An iterator to the inserted element. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: iterator insert_after(const_iterator prev_p, reference value) Chris@16: { Chris@101: node_ptr n = priv_value_traits().to_node_ptr(value); Chris@16: if(safemode_or_autounlink) Chris@16: BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(n)); Chris@16: node_ptr prev_n(prev_p.pointed_node()); Chris@16: node_algorithms::link_after(prev_n, n); Chris@16: if(cache_last && (this->get_last_node() == prev_n)){ Chris@16: this->set_last_node(n); Chris@16: } Chris@16: this->priv_size_traits().increment(); Chris@101: return iterator (n, this->priv_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Requires: Dereferencing iterator must yield Chris@16: //! an lvalue of type value_type and prev_p must point to an element Chris@16: //! contained by the list or to the end node. Chris@16: //! Chris@16: //! Effects: Inserts the [f, l) Chris@16: //! after the position prev_p. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements inserted. Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: template Chris@16: void insert_after(const_iterator prev_p, Iterator f, Iterator l) Chris@16: { Chris@16: //Insert first nodes avoiding cache and size checks Chris@16: size_type count = 0; Chris@16: node_ptr prev_n(prev_p.pointed_node()); Chris@16: for (; f != l; ++f, ++count){ Chris@101: const node_ptr n = priv_value_traits().to_node_ptr(*f); Chris@16: if(safemode_or_autounlink) Chris@16: BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::inited(n)); Chris@16: node_algorithms::link_after(prev_n, n); Chris@16: prev_n = n; Chris@16: } Chris@16: //Now fix special cases if needed Chris@16: if(cache_last && (this->get_last_node() == prev_p.pointed_node())){ Chris@16: this->set_last_node(prev_n); Chris@16: } Chris@16: if(constant_time_size){ Chris@16: this->priv_size_traits().increase(count); Chris@16: } Chris@16: } Chris@16: Chris@16: //! Requires: value must be an lvalue and p must point to an element Chris@16: //! contained by the list or to end(). Chris@16: //! Chris@16: //! Effects: Inserts the value before the position pointed by p. Chris@16: //! No copy constructor is called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements before p. Chris@16: //! Constant-time if cache_last<> is true and p == end(). Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: iterator insert(const_iterator p, reference value) Chris@16: { return this->insert_after(this->previous(p), value); } Chris@16: Chris@16: //! Requires: Dereferencing iterator must yield Chris@16: //! an lvalue of type value_type and p must point to an element Chris@16: //! contained by the list or to the end node. Chris@16: //! Chris@16: //! Effects: Inserts the pointed by b and e Chris@16: //! before the position p. No copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements inserted plus linear Chris@16: //! to the elements before b. Chris@16: //! Linear to the number of elements to insert if cache_last<> option is true and p == end(). Chris@16: //! Chris@16: //! Note: Does not affect the validity of iterators and references. Chris@16: template Chris@16: void insert(const_iterator p, Iterator b, Iterator e) Chris@16: { return this->insert_after(this->previous(p), b, e); } Chris@16: Chris@16: //! Effects: Erases the element after the element pointed by prev of Chris@16: //! the list. No destructors are called. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased element. Chris@16: iterator erase_after(const_iterator prev) Chris@16: { return this->erase_after_and_dispose(prev, detail::null_disposer()); } Chris@16: Chris@16: //! Effects: Erases the range (before_f, l) from Chris@16: //! the list. No destructors are called. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of erased elements if it's a safe-mode Chris@16: //! , auto-unlink value or constant-time size is activated. Constant time otherwise. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased element. Chris@16: iterator erase_after(const_iterator before_f, const_iterator l) Chris@16: { Chris@16: if(safemode_or_autounlink || constant_time_size){ Chris@16: return this->erase_after_and_dispose(before_f, l, detail::null_disposer()); Chris@16: } Chris@16: else{ Chris@16: const node_ptr bfp = before_f.pointed_node(); Chris@16: const node_ptr lp = l.pointed_node(); Chris@16: if(cache_last){ Chris@16: if(lp == this->get_end_node()){ Chris@16: this->set_last_node(bfp); Chris@16: } Chris@16: } Chris@16: node_algorithms::unlink_after(bfp, lp); Chris@16: return l.unconst(); Chris@16: } Chris@16: } Chris@16: Chris@16: //! Effects: Erases the range (before_f, l) from Chris@101: //! the list. n must be distance(before_f, l) - 1. Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: constant-time if link_mode is normal_link. Chris@16: //! Linear to the elements (l - before_f) otherwise. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased element. Chris@16: iterator erase_after(const_iterator before_f, const_iterator l, size_type n) Chris@16: { Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance((++const_iterator(before_f)).pointed_node(), l.pointed_node()) == n); Chris@16: if(safemode_or_autounlink){ Chris@16: return this->erase_after(before_f, l); Chris@16: } Chris@16: else{ Chris@16: const node_ptr bfp = before_f.pointed_node(); Chris@16: const node_ptr lp = l.pointed_node(); Chris@16: if(cache_last){ Chris@16: if((lp == this->get_end_node())){ Chris@16: this->set_last_node(bfp); Chris@16: } Chris@16: } Chris@16: node_algorithms::unlink_after(bfp, lp); Chris@16: if(constant_time_size){ Chris@16: this->priv_size_traits().decrease(n); Chris@16: } Chris@16: return l.unconst(); Chris@16: } Chris@16: } Chris@16: Chris@16: //! Effects: Erases the element pointed by i of the list. Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed element, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the elements before i. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased element. Chris@16: iterator erase(const_iterator i) Chris@16: { return this->erase_after(this->previous(i)); } Chris@16: Chris@16: //! Requires: f and l must be valid iterator to elements in *this. Chris@16: //! Chris@16: //! Effects: Erases the range pointed by b and e. Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the elements before l. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased elements. Chris@16: iterator erase(const_iterator f, const_iterator l) Chris@16: { return this->erase_after(this->previous(f), l); } Chris@16: Chris@16: //! Effects: Erases the range [f, l) from Chris@101: //! the list. n must be distance(f, l). Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: linear to the elements before f if link_mode is normal_link Chris@16: //! and constant_time_size is activated. Linear to the elements before l otherwise. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased element. Chris@16: iterator erase(const_iterator f, const_iterator l, size_type n) Chris@16: { return this->erase_after(this->previous(f), l, n); } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Erases the element after the element pointed by prev of Chris@16: //! the list. Chris@16: //! Disposer::operator()(pointer) is called for the removed element. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Invalidates the iterators to the erased element. Chris@16: template Chris@16: iterator erase_after_and_dispose(const_iterator prev, Disposer disposer) Chris@16: { Chris@16: const_iterator it(prev); Chris@16: ++it; Chris@16: node_ptr to_erase(it.pointed_node()); Chris@16: ++it; Chris@16: node_ptr prev_n(prev.pointed_node()); Chris@16: node_algorithms::unlink_after(prev_n); Chris@16: if(cache_last && (to_erase == this->get_last_node())){ Chris@16: this->set_last_node(prev_n); Chris@16: } Chris@16: if(safemode_or_autounlink) Chris@16: node_algorithms::init(to_erase); Chris@101: disposer(priv_value_traits().to_value_ptr(to_erase)); Chris@16: this->priv_size_traits().decrement(); Chris@16: return it.unconst(); Chris@16: } Chris@16: Chris@16: /// @cond Chris@16: Chris@16: template Chris@16: static iterator s_erase_after_and_dispose(const_iterator prev, Disposer disposer) Chris@16: { Chris@16: BOOST_STATIC_ASSERT(((!cache_last)&&(!constant_time_size)&&(!stateful_value_traits))); Chris@16: const_iterator it(prev); Chris@16: ++it; Chris@16: node_ptr to_erase(it.pointed_node()); Chris@16: ++it; Chris@16: node_ptr prev_n(prev.pointed_node()); Chris@16: node_algorithms::unlink_after(prev_n); Chris@16: if(safemode_or_autounlink) Chris@16: node_algorithms::init(to_erase); Chris@101: disposer(value_traits::to_value_ptr(to_erase)); Chris@16: return it.unconst(); Chris@16: } Chris@16: Chris@16: static iterator s_erase_after(const_iterator prev) Chris@16: { return s_erase_after_and_dispose(prev, detail::null_disposer()); } Chris@16: Chris@16: /// @endcond Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Erases the range (before_f, l) from Chris@16: //! the list. Chris@16: //! Disposer::operator()(pointer) is called for the removed elements. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Lineal to the elements (l - before_f + 1). Chris@16: //! Chris@16: //! Note: Invalidates the iterators to the erased element. Chris@16: template Chris@16: iterator erase_after_and_dispose(const_iterator before_f, const_iterator l, Disposer disposer) Chris@16: { Chris@16: node_ptr bfp(before_f.pointed_node()), lp(l.pointed_node()); Chris@16: node_ptr fp(node_traits::get_next(bfp)); Chris@16: node_algorithms::unlink_after(bfp, lp); Chris@16: while(fp != lp){ Chris@16: node_ptr to_erase(fp); Chris@16: fp = node_traits::get_next(fp); Chris@16: if(safemode_or_autounlink) Chris@16: node_algorithms::init(to_erase); Chris@101: disposer(priv_value_traits().to_value_ptr(to_erase)); Chris@16: this->priv_size_traits().decrement(); Chris@16: } Chris@16: if(cache_last && (node_traits::get_next(bfp) == this->get_end_node())){ Chris@16: this->set_last_node(bfp); Chris@16: } Chris@16: return l.unconst(); Chris@16: } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Erases the element pointed by i of the list. Chris@16: //! No destructors are called. Chris@16: //! Disposer::operator()(pointer) is called for the removed element. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed element, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the elements before i. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased element. Chris@16: template Chris@16: iterator erase_and_dispose(const_iterator i, Disposer disposer) Chris@16: { return this->erase_after_and_dispose(this->previous(i), disposer); } Chris@16: Chris@16: #if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: iterator erase_and_dispose(iterator i, Disposer disposer) Chris@16: { return this->erase_and_dispose(const_iterator(i), disposer); } Chris@16: #endif Chris@16: Chris@16: //! Requires: f and l must be valid iterator to elements in *this. Chris@16: //! Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Erases the range pointed by b and e. Chris@16: //! No destructors are called. Chris@16: //! Disposer::operator()(pointer) is called for the removed elements. Chris@16: //! Chris@16: //! Returns: the first element remaining beyond the removed elements, Chris@16: //! or end() if no such element exists. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of erased elements plus linear Chris@16: //! to the elements before f. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) to the Chris@16: //! erased elements. Chris@16: template Chris@16: iterator erase_and_dispose(const_iterator f, const_iterator l, Disposer disposer) Chris@16: { return this->erase_after_and_dispose(this->previous(f), l, disposer); } Chris@16: Chris@16: //! Requires: Dereferencing iterator must yield Chris@16: //! an lvalue of type value_type. Chris@16: //! Chris@16: //! Effects: Clears the list and inserts the range pointed by b and e. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements inserted plus Chris@16: //! linear to the elements contained in the list if it's a safe-mode Chris@16: //! or auto-unlink value. Chris@16: //! Linear to the number of elements inserted in the list otherwise. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) Chris@16: //! to the erased elements. Chris@16: template Chris@16: void assign(Iterator b, Iterator e) Chris@16: { Chris@16: this->clear(); Chris@16: this->insert_after(this->cbefore_begin(), b, e); Chris@16: } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Requires: Dereferencing iterator must yield Chris@16: //! an lvalue of type value_type. Chris@16: //! Chris@16: //! Effects: Clears the list and inserts the range pointed by b and e. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Disposer::operator()(pointer) is called for the removed elements. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements inserted plus Chris@16: //! linear to the elements contained in the list. Chris@16: //! Chris@16: //! Note: Invalidates the iterators (but not the references) Chris@16: //! to the erased elements. Chris@16: template Chris@16: void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) Chris@16: { Chris@16: this->clear_and_dispose(disposer); Chris@16: this->insert_after(this->cbefore_begin(), b, e, disposer); Chris@16: } Chris@16: Chris@16: //! Requires: prev must point to an element contained by this list or Chris@16: //! to the before_begin() element Chris@16: //! Chris@16: //! Effects: Transfers all the elements of list x to this list, after the Chris@16: //! the element pointed by prev. No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Returns: Nothing. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: In general, linear to the elements contained in x. Chris@16: //! Constant-time if cache_last<> option is true and also constant-time if Chris@16: //! linear<> option is true "this" is empty and "l" is not used. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: //! Chris@16: //! Additional note: If the optional parameter "l" is provided, it will be Chris@16: //! assigned to the last spliced element or prev if x is empty. Chris@16: //! This iterator can be used as new "prev" iterator for a new splice_after call. Chris@16: //! that will splice new values after the previously spliced values. Chris@16: void splice_after(const_iterator prev, slist_impl &x, const_iterator *l = 0) Chris@16: { Chris@16: if(x.empty()){ Chris@16: if(l) *l = prev; Chris@16: } Chris@16: else if(linear && this->empty()){ Chris@16: this->swap(x); Chris@16: if(l) *l = this->previous(this->cend()); Chris@16: } Chris@16: else{ Chris@16: const_iterator last_x(x.previous(x.end())); //<- constant time if cache_last is active Chris@16: node_ptr prev_n(prev.pointed_node()); Chris@16: node_ptr last_x_n(last_x.pointed_node()); Chris@16: if(cache_last){ Chris@16: x.set_last_node(x.get_root_node()); Chris@16: if(node_traits::get_next(prev_n) == this->get_end_node()){ Chris@16: this->set_last_node(last_x_n); Chris@16: } Chris@16: } Chris@16: node_algorithms::transfer_after( prev_n, x.before_begin().pointed_node(), last_x_n); Chris@16: this->priv_size_traits().increase(x.priv_size_traits().get_size()); Chris@16: x.priv_size_traits().set_size(size_type(0)); Chris@16: if(l) *l = last_x; Chris@16: } Chris@16: } Chris@16: Chris@16: //! Requires: prev must point to an element contained by this list or Chris@16: //! to the before_begin() element. prev_ele must point to an element contained in list Chris@16: //! x or must be x.before_begin(). Chris@16: //! Chris@16: //! Effects: Transfers the element after prev_ele, from list x to this list, Chris@16: //! after the element pointed by prev. No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator prev_ele) Chris@16: { Chris@16: const_iterator elem = prev_ele; Chris@16: this->splice_after(prev_pos, x, prev_ele, ++elem, 1); Chris@16: } Chris@16: Chris@16: //! Requires: prev_pos must be a dereferenceable iterator in *this or be Chris@16: //! before_begin(), and before_f and before_l belong to x and Chris@16: //! ++before_f != x.end() && before_l != x.end(). Chris@16: //! Chris@16: //! Effects: Transfers the range (before_f, before_l] from list x to this Chris@16: //! list, after the element pointed by prev_pos. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements transferred Chris@16: //! if constant_time_size is true. Constant-time otherwise. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l) Chris@16: { Chris@16: if(constant_time_size) Chris@101: this->splice_after(prev_pos, x, before_f, before_l, node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node())); Chris@16: else Chris@16: this->priv_splice_after Chris@16: (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node()); Chris@16: } Chris@16: Chris@16: //! Requires: prev_pos must be a dereferenceable iterator in *this or be Chris@16: //! before_begin(), and before_f and before_l belong to x and Chris@16: //! ++before_f != x.end() && before_l != x.end() and Chris@101: //! n == distance(before_f, before_l). Chris@16: //! Chris@16: //! Effects: Transfers the range (before_f, before_l] from list x to this Chris@16: //! list, after the element pointed by p. No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant time. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: void splice_after(const_iterator prev_pos, slist_impl &x, const_iterator before_f, const_iterator before_l, size_type n) Chris@16: { Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(node_algorithms::distance(before_f.pointed_node(), before_l.pointed_node()) == n); Chris@16: this->priv_splice_after Chris@16: (prev_pos.pointed_node(), x, before_f.pointed_node(), before_l.pointed_node()); Chris@16: if(constant_time_size){ Chris@16: this->priv_size_traits().increase(n); Chris@16: x.priv_size_traits().decrease(n); Chris@16: } Chris@16: } Chris@16: Chris@16: //! Requires: it is an iterator to an element in *this. Chris@16: //! Chris@16: //! Effects: Transfers all the elements of list x to this list, before the Chris@16: //! the element pointed by it. No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Returns: Nothing. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the elements contained in x plus linear to Chris@16: //! the elements before it. Chris@16: //! Linear to the elements before it if cache_last<> option is true. Chris@16: //! Constant-time if cache_last<> option is true and it == end(). Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: //! Chris@16: //! Additional note: If the optional parameter "l" is provided, it will be Chris@16: //! assigned to the last spliced element or prev if x is empty. Chris@16: //! This iterator can be used as new "prev" iterator for a new splice_after call. Chris@16: //! that will splice new values after the previously spliced values. Chris@16: void splice(const_iterator it, slist_impl &x, const_iterator *l = 0) Chris@16: { this->splice_after(this->previous(it), x, l); } Chris@16: Chris@16: //! Requires: it p must be a valid iterator of *this. Chris@16: //! elem must point to an element contained in list Chris@16: //! x. Chris@16: //! Chris@16: //! Effects: Transfers the element elem, from list x to this list, Chris@16: //! before the element pointed by pos. No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the elements before pos and before elem. Chris@16: //! Linear to the elements before elem if cache_last<> option is true and pos == end(). Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: void splice(const_iterator pos, slist_impl &x, const_iterator elem) Chris@16: { return this->splice_after(this->previous(pos), x, x.previous(elem)); } Chris@16: Chris@16: //! Requires: pos must be a dereferenceable iterator in *this Chris@16: //! and f and f belong to x and f and f a valid range on x. Chris@16: //! Chris@16: //! Effects: Transfers the range [f, l) from list x to this Chris@16: //! list, before the element pointed by pos. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the sum of elements before pos, f, and l Chris@16: //! plus linear to the number of elements transferred if constant_time_size is true. Chris@16: //! Linear to the sum of elements before f, and l Chris@16: //! plus linear to the number of elements transferred if constant_time_size is true Chris@16: //! if cache_last<> is true and pos == end() Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: void splice(const_iterator pos, slist_impl &x, const_iterator f, const_iterator l) Chris@16: { return this->splice_after(this->previous(pos), x, x.previous(f), x.previous(l)); } Chris@16: Chris@16: //! Requires: pos must be a dereferenceable iterator in *this Chris@16: //! and f and l belong to x and f and l a valid range on x. Chris@101: //! n == distance(f, l). Chris@16: //! Chris@16: //! Effects: Transfers the range [f, l) from list x to this Chris@16: //! list, before the element pointed by pos. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the sum of elements before pos, f, and l. Chris@16: //! Linear to the sum of elements before f and l Chris@16: //! if cache_last<> is true and pos == end(). Chris@16: //! Chris@16: //! Note: Iterators of values obtained from list x now point to elements of this Chris@16: //! list. Iterators of this list and all the references are not invalidated. Chris@16: void splice(const_iterator pos, slist_impl &x, const_iterator f, const_iterator l, size_type n) Chris@16: { return this->splice_after(this->previous(pos), x, x.previous(f), x.previous(l), n); } Chris@16: Chris@16: //! Effects: This function sorts the list *this according to std::less. Chris@16: //! The sort is stable, that is, the relative order of equivalent elements is preserved. Chris@16: //! Chris@16: //! Throws: If value_traits::node_traits::node Chris@16: //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) Chris@16: //! or the predicate throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: The number of comparisons is approximately N log N, where N Chris@16: //! is the list's size. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated Chris@16: template Chris@16: void sort(Predicate p) Chris@16: { Chris@16: if (node_traits::get_next(node_traits::get_next(this->get_root_node())) Chris@16: != this->get_root_node()) { Chris@16: Chris@16: slist_impl carry(this->priv_value_traits()); Chris@16: detail::array_initializer counter(this->priv_value_traits()); Chris@16: int fill = 0; Chris@16: const_iterator last_inserted; Chris@16: while(!this->empty()){ Chris@16: last_inserted = this->cbegin(); Chris@16: carry.splice_after(carry.cbefore_begin(), *this, this->cbefore_begin()); Chris@16: int i = 0; Chris@16: while(i < fill && !counter[i].empty()) { Chris@16: carry.swap(counter[i]); Chris@16: carry.merge(counter[i++], p, &last_inserted); Chris@16: } Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT(counter[i].empty()); Chris@16: const_iterator last_element(carry.previous(last_inserted, carry.end())); Chris@16: Chris@16: if(constant_time_size){ Chris@16: counter[i].splice_after( counter[i].cbefore_begin(), carry Chris@16: , carry.cbefore_begin(), last_element Chris@16: , carry.size()); Chris@16: } Chris@16: else{ Chris@16: counter[i].splice_after( counter[i].cbefore_begin(), carry Chris@16: , carry.cbefore_begin(), last_element); Chris@16: } Chris@16: if(i == fill) Chris@16: ++fill; Chris@16: } Chris@16: Chris@16: for (int i = 1; i < fill; ++i) Chris@16: counter[i].merge(counter[i-1], p, &last_inserted); Chris@16: --fill; Chris@16: const_iterator last_element(counter[fill].previous(last_inserted, counter[fill].end())); Chris@16: if(constant_time_size){ Chris@16: this->splice_after( cbefore_begin(), counter[fill], counter[fill].cbefore_begin() Chris@16: , last_element, counter[fill].size()); Chris@16: } Chris@16: else{ Chris@16: this->splice_after( cbefore_begin(), counter[fill], counter[fill].cbefore_begin() Chris@16: , last_element); Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: //! Requires: p must be a comparison function that induces a strict weak Chris@16: //! ordering and both *this and x must be sorted according to that ordering Chris@16: //! The lists x and *this must be distinct. Chris@16: //! Chris@16: //! Effects: This function removes all of x's elements and inserts them Chris@16: //! in order into *this. The merge is stable; that is, if an element from *this is Chris@16: //! equivalent to one from x, then the element from *this will precede the one from x. Chris@16: //! Chris@16: //! Throws: If value_traits::node_traits::node Chris@16: //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) Chris@16: //! or std::less throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: This function is linear time: it performs at most Chris@16: //! size() + x.size() - 1 comparisons. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated. Chris@16: void sort() Chris@16: { this->sort(std::less()); } Chris@16: Chris@16: //! Requires: p must be a comparison function that induces a strict weak Chris@16: //! ordering and both *this and x must be sorted according to that ordering Chris@16: //! The lists x and *this must be distinct. Chris@16: //! Chris@16: //! Effects: This function removes all of x's elements and inserts them Chris@16: //! in order into *this. The merge is stable; that is, if an element from *this is Chris@16: //! equivalent to one from x, then the element from *this will precede the one from x. Chris@16: //! Chris@16: //! Returns: Nothing. Chris@16: //! Chris@16: //! Throws: If the predicate throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: This function is linear time: it performs at most Chris@16: //! size() + x.size() - 1 comparisons. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated. Chris@16: //! Chris@16: //! Additional note: If optional "l" argument is passed, it is assigned Chris@16: //! to an iterator to the last transferred value or end() is x is empty. Chris@16: template Chris@16: void merge(slist_impl& x, Predicate p, const_iterator *l = 0) Chris@16: { Chris@16: const_iterator e(this->cend()), ex(x.cend()), bb(this->cbefore_begin()), Chris@16: bb_next; Chris@16: if(l) *l = e.unconst(); Chris@16: while(!x.empty()){ Chris@16: const_iterator ibx_next(x.cbefore_begin()), ibx(ibx_next++); Chris@16: while (++(bb_next = bb) != e && !p(*ibx_next, *bb_next)){ Chris@16: bb = bb_next; Chris@16: } Chris@16: if(bb_next == e){ Chris@16: //Now transfer the rest to the end of the container Chris@16: this->splice_after(bb, x, l); Chris@16: break; Chris@16: } Chris@16: else{ Chris@16: size_type n(0); Chris@16: do{ Chris@16: ibx = ibx_next; ++n; Chris@16: } while(++(ibx_next = ibx) != ex && p(*ibx_next, *bb_next)); Chris@16: this->splice_after(bb, x, x.before_begin(), ibx, n); Chris@16: if(l) *l = ibx; Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: //! Effects: This function removes all of x's elements and inserts them Chris@16: //! in order into *this according to std::less. The merge is stable; Chris@16: //! that is, if an element from *this is equivalent to one from x, then the element Chris@16: //! from *this will precede the one from x. Chris@16: //! Chris@16: //! Throws: if std::less throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: This function is linear time: it performs at most Chris@16: //! size() + x.size() - 1 comparisons. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated Chris@16: void merge(slist_impl& x) Chris@16: { this->merge(x, std::less()); } Chris@16: Chris@16: //! Effects: Reverses the order of elements in the list. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: This function is linear to the contained elements. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated Chris@16: void reverse() Chris@16: { Chris@16: if(cache_last && !this->empty()){ Chris@16: this->set_last_node(node_traits::get_next(this->get_root_node())); Chris@16: } Chris@16: this->priv_reverse(detail::bool_()); Chris@16: } Chris@16: Chris@16: //! Effects: Removes all the elements that compare equal to value. Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Throws: If std::equal_to throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time. It performs exactly size() comparisons for equality. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. This function is Chris@16: //! linear time: it performs exactly size() comparisons for equality. Chris@16: void remove(const_reference value) Chris@16: { this->remove_if(detail::equal_to_value(value)); } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Removes all the elements that compare equal to value. Chris@16: //! Disposer::operator()(pointer) is called for every removed element. Chris@16: //! Chris@16: //! Throws: If std::equal_to throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time. It performs exactly size() comparisons for equality. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: template Chris@16: void remove_and_dispose(const_reference value, Disposer disposer) Chris@16: { this->remove_and_dispose_if(detail::equal_to_value(value), disposer); } Chris@16: Chris@16: //! Effects: Removes all the elements for which a specified Chris@16: //! predicate is satisfied. No destructors are called. Chris@16: //! Chris@16: //! Throws: If pred throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time. It performs exactly size() calls to the predicate. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: template Chris@16: void remove_if(Pred pred) Chris@101: { Chris@101: const node_ptr bbeg = this->get_root_node(); Chris@101: typename node_algorithms::stable_partition_info info; Chris@101: node_algorithms::stable_partition Chris@101: (bbeg, this->get_end_node(), detail::key_nodeptr_comp(pred, &this->priv_value_traits()), info); Chris@101: //After cache last is set, slist invariants are preserved... Chris@101: if(cache_last){ Chris@101: this->set_last_node(info.new_last_node); Chris@101: } Chris@101: //...so erase can be safely called Chris@101: this->erase_after( const_iterator(bbeg, this->priv_value_traits_ptr()) Chris@101: , const_iterator(info.beg_2st_partition, this->priv_value_traits_ptr()) Chris@101: , info.num_1st_partition); Chris@101: } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Removes all the elements for which a specified Chris@16: //! predicate is satisfied. Chris@16: //! Disposer::operator()(pointer) is called for every removed element. Chris@16: //! Chris@16: //! Throws: If pred throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time. It performs exactly size() comparisons for equality. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: template Chris@16: void remove_and_dispose_if(Pred pred, Disposer disposer) Chris@16: { Chris@101: const node_ptr bbeg = this->get_root_node(); Chris@101: typename node_algorithms::stable_partition_info info; Chris@101: node_algorithms::stable_partition Chris@101: (bbeg, this->get_end_node(), detail::key_nodeptr_comp(pred, &this->priv_value_traits()), info); Chris@101: //After cache last is set, slist invariants are preserved... Chris@101: if(cache_last){ Chris@101: this->set_last_node(info.new_last_node); Chris@16: } Chris@101: //...so erase can be safely called Chris@101: this->erase_after_and_dispose( const_iterator(bbeg, this->priv_value_traits_ptr()) Chris@101: , const_iterator(info.beg_2st_partition, this->priv_value_traits_ptr()) Chris@101: , disposer); Chris@16: } Chris@16: Chris@16: //! Effects: Removes adjacent duplicate elements or adjacent Chris@16: //! elements that are equal from the list. No destructors are called. Chris@16: //! Chris@16: //! Throws: If std::equal_to throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time (size()-1) comparisons calls to pred()). Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: void unique() Chris@16: { this->unique_and_dispose(std::equal_to(), detail::null_disposer()); } Chris@16: Chris@16: //! Effects: Removes adjacent duplicate elements or adjacent Chris@16: //! elements that satisfy some binary predicate from the list. Chris@16: //! No destructors are called. Chris@16: //! Chris@16: //! Throws: If the predicate throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time (size()-1) comparisons equality comparisons. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: template Chris@16: void unique(BinaryPredicate pred) Chris@16: { this->unique_and_dispose(pred, detail::null_disposer()); } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Removes adjacent duplicate elements or adjacent Chris@16: //! elements that satisfy some binary predicate from the list. Chris@16: //! Disposer::operator()(pointer) is called for every removed element. Chris@16: //! Chris@16: //! Throws: If std::equal_to throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time (size()-1) comparisons equality comparisons. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: template Chris@16: void unique_and_dispose(Disposer disposer) Chris@16: { this->unique(std::equal_to(), disposer); } Chris@16: Chris@16: //! Requires: Disposer::operator()(pointer) shouldn't throw. Chris@16: //! Chris@16: //! Effects: Removes adjacent duplicate elements or adjacent Chris@16: //! elements that satisfy some binary predicate from the list. Chris@16: //! Disposer::operator()(pointer) is called for every removed element. Chris@16: //! Chris@16: //! Throws: If the predicate throws. Basic guarantee. Chris@16: //! Chris@16: //! Complexity: Linear time (size()-1) comparisons equality comparisons. Chris@16: //! Chris@16: //! Note: The relative order of elements that are not removed is unchanged, Chris@16: //! and iterators to elements that are not removed remain valid. Chris@16: template Chris@16: void unique_and_dispose(BinaryPredicate pred, Disposer disposer) Chris@16: { Chris@16: const_iterator end_n(this->cend()); Chris@16: const_iterator bcur(this->cbegin()); Chris@16: if(bcur != end_n){ Chris@16: const_iterator cur(bcur); Chris@16: ++cur; Chris@16: while(cur != end_n) { Chris@16: if (pred(*bcur, *cur)){ Chris@16: cur = this->erase_after_and_dispose(bcur, disposer); Chris@16: } Chris@16: else{ Chris@16: bcur = cur; Chris@16: ++cur; Chris@16: } Chris@16: } Chris@16: if(cache_last){ Chris@16: this->set_last_node(bcur.pointed_node()); Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: //! Requires: value must be a reference to a value inserted in a list. Chris@16: //! Chris@16: //! Effects: This function returns a const_iterator pointing to the element Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant time. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated. Chris@16: //! This static function is available only if the value traits Chris@16: //! is stateless. Chris@16: static iterator s_iterator_to(reference value) Chris@16: { Chris@16: BOOST_STATIC_ASSERT((!stateful_value_traits)); Chris@101: return iterator (value_traits::to_node_ptr(value), const_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Requires: value must be a const reference to a value inserted in a list. Chris@16: //! Chris@16: //! Effects: This function returns an iterator pointing to the element. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant time. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated. Chris@16: //! This static function is available only if the value traits Chris@16: //! is stateless. Chris@16: static const_iterator s_iterator_to(const_reference value) Chris@16: { Chris@16: BOOST_STATIC_ASSERT((!stateful_value_traits)); Chris@101: reference r =*detail::uncast(pointer_traits::pointer_to(value)); Chris@101: return const_iterator(value_traits::to_node_ptr(r), const_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Requires: value must be a reference to a value inserted in a list. Chris@16: //! Chris@16: //! Effects: This function returns a const_iterator pointing to the element Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant time. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated. Chris@16: iterator iterator_to(reference value) Chris@16: { Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(linear || !node_algorithms::inited(this->priv_value_traits().to_node_ptr(value))); Chris@101: return iterator (this->priv_value_traits().to_node_ptr(value), this->priv_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Requires: value must be a const reference to a value inserted in a list. Chris@16: //! Chris@16: //! Effects: This function returns an iterator pointing to the element. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant time. Chris@16: //! Chris@16: //! Note: Iterators and references are not invalidated. Chris@16: const_iterator iterator_to(const_reference value) const Chris@16: { Chris@101: reference r =*detail::uncast(pointer_traits::pointer_to(value)); Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT (linear || !node_algorithms::inited(this->priv_value_traits().to_node_ptr(r))); Chris@101: return const_iterator(this->priv_value_traits().to_node_ptr(r), this->priv_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: //! Returns: The iterator to the element before i in the list. Chris@16: //! Returns the end-iterator, if either i is the begin-iterator or the Chris@16: //! list is empty. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements before i. Chris@16: //! Constant if cache_last<> is true and i == end(). Chris@16: iterator previous(iterator i) Chris@16: { return this->previous(this->cbefore_begin(), i); } Chris@16: Chris@16: //! Returns: The const_iterator to the element before i in the list. Chris@16: //! Returns the end-const_iterator, if either i is the begin-const_iterator or Chris@16: //! the list is empty. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements before i. Chris@16: //! Constant if cache_last<> is true and i == end(). Chris@16: const_iterator previous(const_iterator i) const Chris@16: { return this->previous(this->cbefore_begin(), i); } Chris@16: Chris@16: //! Returns: The iterator to the element before i in the list, Chris@16: //! starting the search on element after prev_from. Chris@16: //! Returns the end-iterator, if either i is the begin-iterator or the Chris@16: //! list is empty. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements before i. Chris@16: //! Constant if cache_last<> is true and i == end(). Chris@16: iterator previous(const_iterator prev_from, iterator i) Chris@16: { return this->previous(prev_from, const_iterator(i)).unconst(); } Chris@16: Chris@16: //! Returns: The const_iterator to the element before i in the list, Chris@16: //! starting the search on element after prev_from. Chris@16: //! Returns the end-const_iterator, if either i is the begin-const_iterator or Chris@16: //! the list is empty. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements before i. Chris@16: //! Constant if cache_last<> is true and i == end(). Chris@16: const_iterator previous(const_iterator prev_from, const_iterator i) const Chris@16: { Chris@16: if(cache_last && (i.pointed_node() == this->get_end_node())){ Chris@101: return const_iterator(detail::uncast(this->get_last_node()), this->priv_value_traits_ptr()); Chris@16: } Chris@16: return const_iterator Chris@16: (node_algorithms::get_previous_node Chris@101: (prev_from.pointed_node(), i.pointed_node()), this->priv_value_traits_ptr()); Chris@16: } Chris@16: Chris@16: ///@cond Chris@16: Chris@16: //! Requires: prev_pos must be a dereferenceable iterator in *this or be Chris@16: //! before_begin(), and f and before_l belong to another slist. Chris@16: //! Chris@16: //! Effects: Transfers the range [f, before_l] to this Chris@16: //! list, after the element pointed by prev_pos. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Linear to the number of elements transferred Chris@16: //! if constant_time_size is true. Constant-time otherwise. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from the list that owned f and before_l now Chris@16: //! point to elements of this list. Iterators of this list and all the references are not invalidated. Chris@16: //! Chris@16: //! Warning: Experimental function, don't use it! Chris@16: void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l) Chris@16: { Chris@16: if(constant_time_size) Chris@101: this->incorporate_after(prev_pos, f, before_l, node_algorithms::distance(f.pointed_node(), before_l.pointed_node())+1); Chris@16: else Chris@16: this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l); Chris@16: } Chris@16: Chris@16: //! Requires: prev_pos must be a dereferenceable iterator in *this or be Chris@16: //! before_begin(), and f and before_l belong to another slist. Chris@101: //! n == distance(f, before_l) + 1. Chris@16: //! Chris@16: //! Effects: Transfers the range [f, before_l] to this Chris@16: //! list, after the element pointed by prev_pos. Chris@16: //! No destructors or copy constructors are called. Chris@16: //! Chris@16: //! Throws: Nothing. Chris@16: //! Chris@16: //! Complexity: Constant time. Chris@16: //! Chris@16: //! Note: Iterators of values obtained from the list that owned f and before_l now Chris@16: //! point to elements of this list. Iterators of this list and all the references are not invalidated. Chris@16: //! Chris@16: //! Warning: Experimental function, don't use it! Chris@16: void incorporate_after(const_iterator prev_pos, const node_ptr & f, const node_ptr & before_l, size_type n) Chris@16: { Chris@16: if(n){ Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT(n > 0); Chris@16: BOOST_INTRUSIVE_INVARIANT_ASSERT Chris@101: (size_type(boost::intrusive::iterator_distance Chris@101: ( iterator(f, this->priv_value_traits_ptr()) Chris@101: , iterator(before_l, this->priv_value_traits_ptr()))) Chris@16: +1 == n); Chris@16: this->priv_incorporate_after(prev_pos.pointed_node(), f, before_l); Chris@16: if(constant_time_size){ Chris@16: this->priv_size_traits().increase(n); Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: ///@endcond Chris@16: Chris@101: //! Effects: Asserts the integrity of the container. Chris@101: //! Chris@101: //! Complexity: Linear time. Chris@101: //! Chris@101: //! Note: The method has no effect when asserts are turned off (e.g., with NDEBUG). Chris@101: //! Experimental function, interface might change in future versions. Chris@101: void check() const Chris@101: { Chris@101: const_node_ptr header_ptr = get_root_node(); Chris@101: // header's next is never null Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(node_traits::get_next(header_ptr)); Chris@101: if (node_traits::get_next(header_ptr) == header_ptr) Chris@101: { Chris@101: if (constant_time_size) Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == 0); Chris@101: return; Chris@101: } Chris@101: size_t node_count = 0; Chris@101: const_node_ptr p = header_ptr; Chris@101: while (true) Chris@101: { Chris@101: const_node_ptr next_p = node_traits::get_next(p); Chris@101: if (!linear) Chris@101: { Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(next_p); Chris@101: } Chris@101: else Chris@101: { Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(next_p != header_ptr); Chris@101: } Chris@101: if ((!linear && next_p == header_ptr) || (linear && !next_p)) Chris@101: { Chris@101: if (cache_last) Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(get_last_node() == p); Chris@101: break; Chris@101: } Chris@101: p = next_p; Chris@101: ++node_count; Chris@101: } Chris@101: if (constant_time_size) Chris@101: BOOST_INTRUSIVE_INVARIANT_ASSERT(this->priv_size_traits().get_size() == node_count); Chris@101: } Chris@101: Chris@16: private: Chris@16: void priv_splice_after(const node_ptr & prev_pos_n, slist_impl &x, const node_ptr & before_f_n, const node_ptr & before_l_n) Chris@16: { Chris@16: if (cache_last && (before_f_n != before_l_n)){ Chris@16: if(prev_pos_n == this->get_last_node()){ Chris@16: this->set_last_node(before_l_n); Chris@16: } Chris@16: if(&x != this && node_traits::get_next(before_l_n) == x.get_end_node()){ Chris@16: x.set_last_node(before_f_n); Chris@16: } Chris@16: } Chris@16: node_algorithms::transfer_after(prev_pos_n, before_f_n, before_l_n); Chris@16: } Chris@16: Chris@16: void priv_incorporate_after(const node_ptr & prev_pos_n, const node_ptr & first_n, const node_ptr & before_l_n) Chris@16: { Chris@16: if(cache_last){ Chris@16: if(prev_pos_n == this->get_last_node()){ Chris@16: this->set_last_node(before_l_n); Chris@16: } Chris@16: } Chris@16: node_algorithms::incorporate_after(prev_pos_n, first_n, before_l_n); Chris@16: } Chris@16: Chris@16: void priv_reverse(detail::bool_) Chris@16: { node_algorithms::reverse(this->get_root_node()); } Chris@16: Chris@16: void priv_reverse(detail::bool_) Chris@16: { Chris@16: node_ptr new_first = node_algorithms::reverse Chris@16: (node_traits::get_next(this->get_root_node())); Chris@16: node_traits::set_next(this->get_root_node(), new_first); Chris@16: } Chris@16: Chris@16: void priv_shift_backwards(size_type n, detail::bool_) Chris@16: { Chris@16: node_ptr l = node_algorithms::move_forward(this->get_root_node(), (std::size_t)n); Chris@16: if(cache_last && l){ Chris@16: this->set_last_node(l); Chris@16: } Chris@16: } Chris@16: Chris@16: void priv_shift_backwards(size_type n, detail::bool_) Chris@16: { Chris@16: std::pair ret( Chris@16: node_algorithms::move_first_n_forward Chris@16: (node_traits::get_next(this->get_root_node()), (std::size_t)n)); Chris@16: if(ret.first){ Chris@16: node_traits::set_next(this->get_root_node(), ret.first); Chris@16: if(cache_last){ Chris@16: this->set_last_node(ret.second); Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: void priv_shift_forward(size_type n, detail::bool_) Chris@16: { Chris@16: node_ptr l = node_algorithms::move_backwards(this->get_root_node(), (std::size_t)n); Chris@16: if(cache_last && l){ Chris@16: this->set_last_node(l); Chris@16: } Chris@16: } Chris@16: Chris@16: void priv_shift_forward(size_type n, detail::bool_) Chris@16: { Chris@16: std::pair ret( Chris@16: node_algorithms::move_first_n_backwards Chris@16: (node_traits::get_next(this->get_root_node()), (std::size_t)n)); Chris@16: if(ret.first){ Chris@16: node_traits::set_next(this->get_root_node(), ret.first); Chris@16: if(cache_last){ Chris@16: this->set_last_node(ret.second); Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: static void priv_swap_cache_last(slist_impl *this_impl, slist_impl *other_impl) Chris@16: { Chris@16: bool other_was_empty = false; Chris@16: if(this_impl->empty()){ Chris@16: //Check if both are empty or Chris@16: if(other_impl->empty()) Chris@16: return; Chris@16: //If this is empty swap pointers Chris@16: slist_impl *tmp = this_impl; Chris@16: this_impl = other_impl; Chris@16: other_impl = tmp; Chris@16: other_was_empty = true; Chris@16: } Chris@16: else{ Chris@16: other_was_empty = other_impl->empty(); Chris@16: } Chris@16: Chris@16: //Precondition: this is not empty Chris@16: node_ptr other_old_last(other_impl->get_last_node()); Chris@16: node_ptr other_bfirst(other_impl->get_root_node()); Chris@16: node_ptr this_bfirst(this_impl->get_root_node()); Chris@16: node_ptr this_old_last(this_impl->get_last_node()); Chris@16: Chris@16: //Move all nodes from this to other's beginning Chris@16: node_algorithms::transfer_after(other_bfirst, this_bfirst, this_old_last); Chris@16: other_impl->set_last_node(this_old_last); Chris@16: Chris@16: if(other_was_empty){ Chris@16: this_impl->set_last_node(this_bfirst); Chris@16: } Chris@16: else{ Chris@16: //Move trailing nodes from other to this Chris@16: node_algorithms::transfer_after(this_bfirst, this_old_last, other_old_last); Chris@16: this_impl->set_last_node(other_old_last); Chris@16: } Chris@16: } Chris@16: Chris@16: //circular version Chris@16: static void priv_swap_lists(const node_ptr & this_node, const node_ptr & other_node, detail::bool_) Chris@16: { node_algorithms::swap_nodes(this_node, other_node); } Chris@16: Chris@16: //linear version Chris@16: static void priv_swap_lists(const node_ptr & this_node, const node_ptr & other_node, detail::bool_) Chris@16: { node_algorithms::swap_trailing_nodes(this_node, other_node); } Chris@16: Chris@16: static slist_impl &priv_container_from_end_iterator(const const_iterator &end_iterator) Chris@16: { Chris@16: //Obtaining the container from the end iterator is not possible with linear Chris@16: //singly linked lists (because "end" is represented by the null pointer) Chris@16: BOOST_STATIC_ASSERT(!linear); Chris@101: BOOST_STATIC_ASSERT((has_container_from_iterator)); Chris@101: node_ptr p = end_iterator.pointed_node(); Chris@101: header_holder_type* h = header_holder_type::get_holder(p); Chris@101: header_holder_plus_last_t* hpl = detail::parent_from_member< header_holder_plus_last_t, header_holder_type> Chris@101: (h, &header_holder_plus_last_t::header_holder_); Chris@101: root_plus_size* r = static_cast< root_plus_size* >(hpl); Chris@16: data_t *d = detail::parent_from_member Chris@16: ( r, &data_t::root_plus_size_); Chris@16: slist_impl *s = detail::parent_from_member(d, &slist_impl::data_); Chris@16: return *s; Chris@16: } Chris@16: }; Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: inline bool operator< Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (const slist_impl &x, const slist_impl &y) Chris@16: #else Chris@101: ( const slist_impl &x Chris@101: , const slist_impl &y) Chris@16: #endif Chris@101: { return ::boost::intrusive::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); } Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: bool operator== Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (const slist_impl &x, const slist_impl &y) Chris@16: #else Chris@101: ( const slist_impl &x Chris@101: , const slist_impl &y) Chris@16: #endif Chris@16: { Chris@101: typedef slist_impl slist_type; Chris@16: const bool C = slist_type::constant_time_size; Chris@16: if(C && x.size() != y.size()){ Chris@16: return false; Chris@16: } Chris@101: return ::boost::intrusive::algo_equal(x.cbegin(), x.cend(), y.cbegin(), y.cend()); Chris@16: } Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: inline bool operator!= Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (const slist_impl &x, const slist_impl &y) Chris@16: #else Chris@101: ( const slist_impl &x Chris@101: , const slist_impl &y) Chris@16: #endif Chris@16: { return !(x == y); } Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: inline bool operator> Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (const slist_impl &x, const slist_impl &y) Chris@16: #else Chris@101: ( const slist_impl &x Chris@101: , const slist_impl &y) Chris@16: #endif Chris@16: { return y < x; } Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: inline bool operator<= Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (const slist_impl &x, const slist_impl &y) Chris@16: #else Chris@101: ( const slist_impl &x Chris@101: , const slist_impl &y) Chris@16: #endif Chris@16: { return !(y < x); } Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: inline bool operator>= Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (const slist_impl &x, const slist_impl &y) Chris@16: #else Chris@101: ( const slist_impl &x Chris@101: , const slist_impl &y) Chris@16: #endif Chris@16: { return !(x < y); } Chris@16: Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: inline void swap Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) Chris@16: (slist_impl &x, slist_impl &y) Chris@16: #else Chris@101: ( slist_impl &x Chris@101: , slist_impl &y) Chris@16: #endif Chris@16: { x.swap(y); } Chris@16: Chris@16: //! Helper metafunction to define a \c slist that yields to the same type when the Chris@16: //! same options (either explicitly or implicitly) are used. Chris@16: #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) Chris@16: template Chris@16: #else Chris@101: template Chris@16: #endif Chris@16: struct make_slist Chris@16: { Chris@16: /// @cond Chris@16: typedef typename pack_options Chris@16: < slist_defaults, Chris@16: #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) Chris@101: O1, O2, O3, O4, O5, O6 Chris@16: #else Chris@16: Options... Chris@16: #endif Chris@16: >::type packed_options; Chris@101: Chris@16: typedef typename detail::get_value_traits Chris@16: ::type value_traits; Chris@16: typedef slist_impl Chris@16: < value_traits Chris@16: , typename packed_options::size_type Chris@16: , (std::size_t(packed_options::linear)*slist_bool_flags::linear_pos) Chris@16: |(std::size_t(packed_options::constant_time_size)*slist_bool_flags::constant_time_size_pos) Chris@16: |(std::size_t(packed_options::cache_last)*slist_bool_flags::cache_last_pos) Chris@101: , typename packed_options::header_holder_type Chris@16: > implementation_defined; Chris@16: /// @endcond Chris@16: typedef implementation_defined type; Chris@16: }; Chris@16: Chris@16: Chris@16: #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED Chris@16: Chris@16: #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES) Chris@101: template Chris@16: #else Chris@16: template Chris@16: #endif Chris@16: class slist Chris@16: : public make_slist::type Chris@16: { Chris@16: typedef typename make_slist Chris@16: ::type Base; Chris@16: //Assert if passed value traits are compatible with the type Chris@101: BOOST_STATIC_ASSERT((detail::is_same::value)); Chris@16: BOOST_MOVABLE_BUT_NOT_COPYABLE(slist) Chris@16: Chris@16: public: Chris@16: typedef typename Base::value_traits value_traits; Chris@16: typedef typename Base::iterator iterator; Chris@16: typedef typename Base::const_iterator const_iterator; Chris@16: typedef typename Base::size_type size_type; Chris@16: typedef typename Base::node_ptr node_ptr; Chris@16: Chris@16: explicit slist(const value_traits &v_traits = value_traits()) Chris@16: : Base(v_traits) Chris@16: {} Chris@16: Chris@16: struct incorporate_t{}; Chris@16: Chris@16: slist( const node_ptr & f, const node_ptr & before_l Chris@16: , size_type n, const value_traits &v_traits = value_traits()) Chris@16: : Base(f, before_l, n, v_traits) Chris@16: {} Chris@16: Chris@16: template Chris@16: slist(Iterator b, Iterator e, const value_traits &v_traits = value_traits()) Chris@16: : Base(b, e, v_traits) Chris@16: {} Chris@16: Chris@16: slist(BOOST_RV_REF(slist) x) Chris@101: : Base(BOOST_MOVE_BASE(Base, x)) Chris@16: {} Chris@16: Chris@16: slist& operator=(BOOST_RV_REF(slist) x) Chris@101: { return static_cast(this->Base::operator=(BOOST_MOVE_BASE(Base, x))); } Chris@16: Chris@16: static slist &container_from_end_iterator(iterator end_iterator) Chris@16: { return static_cast(Base::container_from_end_iterator(end_iterator)); } Chris@16: Chris@16: static const slist &container_from_end_iterator(const_iterator end_iterator) Chris@16: { return static_cast(Base::container_from_end_iterator(end_iterator)); } Chris@16: }; Chris@16: Chris@16: #endif Chris@16: Chris@16: } //namespace intrusive Chris@16: } //namespace boost Chris@16: Chris@16: #include Chris@16: Chris@16: #endif //BOOST_INTRUSIVE_SLIST_HPP