Remove trailing spaces
[libcds.git] / cds / intrusive / impl / lazy_list.h
index 1e60ecbfdcec1ba89a198ab7173edcdda9c4775a..c2c706ea91214113785cc9cf679ab6abf0e8fc4c 100644 (file)
@@ -7,7 +7,6 @@
 #include <cds/intrusive/details/lazy_list_base.h>
 #include <cds/gc/guarded_ptr.h>
 
-
 namespace cds { namespace intrusive {
 
     /// Lazy ordered single-linked list
@@ -30,80 +29,62 @@ namespace cds { namespace intrusive {
         - \p GC - Garbage collector used. Note the \p GC must be the same as the GC used for item type \p T (see lazy_list::node).
         - \p T - type to be stored in the list. The type must be based on lazy_list::node (for lazy_list::base_hook)
             or it must have a member of type lazy_list::node (for lazy_list::member_hook).
-        - \p Traits - type traits. See lazy_list::type_traits for explanation.
-
-        It is possible to declare option-based list with cds::intrusive::lazy_list::make_traits metafunction istead of \p Traits template
-        argument. For example, the following traits-based declaration of gc::HP lazy list
-        \code
-        #include <cds/intrusive/lazy_list_hp.h>
-        // Declare item stored in your list
-        struct item: public cds::intrusive::lazy_list::node< cds::gc::HP >
-        { ... };
-
-        // Declare comparator for the item
-        struct my_compare { ... }
+        - \p Traits - type traits. See lazy_list::traits for explanation.
+            It is possible to declare option-based list with cds::intrusive::lazy_list::make_traits metafunction istead of \p Traits template
+            argument. For example, the following traits-based declaration of \p gc::HP lazy list
+            \code
+            #include <cds/intrusive/lazy_list_hp.h>
+            // Declare item stored in your list
+            struct item: public cds::intrusive::lazy_list::node< cds::gc::HP >
+            { ... };
 
-        // Declare type_traits
-        struct my_traits: public cds::intrusive::lazy_list::type_traits
-        {
-            typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > >   hook;
-            typedef my_compare compare;
-        };
+            // Declare comparator for the item
+            struct my_compare { ... }
 
-        // Declare traits-based list
-        typedef cds::intrusive::LazyList< cds::gc::HP, item, my_traits >     traits_based_list;
-        \endcode
+            // Declare traits
+            struct my_traits: public cds::intrusive::lazy_list::traits
+            {
+                typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > >   hook;
+                typedef my_compare compare;
+            };
 
-        is equivalent for the following option-based list
-        \code
-        #include <cds/intrusive/lazy_list_hp.h>
+            // Declare traits-based list
+            typedef cds::intrusive::LazyList< cds::gc::HP, item, my_traits >     traits_based_list;
+            \endcode
+            is equivalent for the following option-based list
+            \code
+            #include <cds/intrusive/lazy_list_hp.h>
 
-        // item struct and my_compare are the same
+            // item struct and my_compare are the same
 
-        // Declare option-based list
-        typedef cds::intrusive::LazyList< cds::gc::HP, item,
-            typename cds::intrusive::lazy_list::make_traits<
-                cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > > >    // hook option
-                ,cds::intrusive::opt::compare< my_compare >     // item comparator option
-            >::type
-        >     option_based_list;
-        \endcode
-
-        Template argument list \p Options of cds::intrusive::lazy_list::make_traits metafunction are:
-        - opt::hook - hook used. Possible values are: lazy_list::base_hook, lazy_list::member_hook, lazy_list::traits_hook.
-            If the option is not specified, <tt>lazy_list::base_hook<></tt> and gc::HP is used.
-        - opt::compare - key comparison functor. No default functor is provided.
-            If the option is not specified, the opt::less is used.
-        - opt::less - specifies binary predicate used for key comparison. Default is \p std::less<T>.
-        - opt::back_off - back-off strategy used. If the option is not specified, the cds::backoff::Default is used.
-        - opt::disposer - the functor used for dispose removed items. Default is opt::v::empty_disposer. Due the nature
-            of GC schema the disposer may be called asynchronously.
-        - opt::link_checker - the type of node's link fields checking. Default is \ref opt::debug_check_link
-        - opt::item_counter - the type of item counting feature. Default is \ref atomicity::empty_item_counter that means no item counting.
-        - opt::allocator - an allocator needed for dummy head and tail nodes. Default is \ref CDS_DEFAULT_ALLOCATOR.
-            The option applies only to gc::HRC garbage collector.
-        - opt::memory_model - C++ memory ordering model. Can be opt::v::relaxed_ordering (relaxed memory model, the default)
-            or opt::v::sequential_consistent (sequentially consisnent memory model).
+            // Declare option-based list
+            typedef cds::intrusive::LazyList< cds::gc::HP, item,
+                typename cds::intrusive::lazy_list::make_traits<
+                    cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::HP > > >    // hook option
+                    ,cds::intrusive::opt::compare< my_compare >     // item comparator option
+                >::type
+            >     option_based_list;
+            \endcode
 
         \par Usage
         There are different specializations of this template for each garbage collecting schema used.
         You should select GC needed and include appropriate .h-file:
         - for gc::HP: \code #include <cds/intrusive/lazy_list_hp.h> \endcode
-        - for gc::PTB: \code #include <cds/intrusive/lazy_list_ptb.h> \endcode
+        - for gc::DHP: \code #include <cds/intrusive/lazy_list_dhp.h> \endcode
         - for gc::nogc: \code #include <cds/intrusive/lazy_list_nogc.h> \endcode
         - for \ref cds_urcu_type "RCU" - see \ref cds_intrusive_LazyList_rcu "LazyList RCU specialization"
 
         Then, you should incorporate lazy_list::node into your struct \p T and provide
-        appropriate lazy_list::type_traits::hook in your \p Traits template parameters. Usually, for \p Traits
-        a struct based on lazy_list::type_traits should be defined.
+        appropriate \p lazy_list::traits::hook in your \p Traits template parameters. Usually, for \p Traits
+        a struct based on \p lazy_list::traits should be defined.
 
-        Example for gc::PTB and base hook:
+        Example for gc::DHP and base hook:
         \code
         // Include GC-related lazy list specialization
-        #include <cds/intrusive/lazy_list_ptb.h>
+        #include <cds/intrusive/lazy_list_dhp.h>
 
         // Data stored in lazy list
-        struct my_data: public cds::intrusive::lazy_list::node< cds::gc::PTB >
+        struct my_data: public cds::intrusive::lazy_list::node< cds::gc::DHP >
         {
             // key field
             std::string     strKey;
@@ -130,22 +111,21 @@ namespace cds { namespace intrusive {
             }
         };
 
-
-        // Declare type_traits
-        struct my_traits: public cds::intrusive::lazy_list::type_traits
+        // Declare traits
+        struct my_traits: public cds::intrusive::lazy_list::traits
         {
-            typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::PTB > >   hook;
+            typedef cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::DHP > >   hook;
             typedef my_data_cmp compare;
         };
 
         // Declare list type
-        typedef cds::intrusive::LazyList< cds::gc::PTB, my_data, my_traits >     traits_based_list;
+        typedef cds::intrusive::LazyList< cds::gc::DHP, my_data, my_traits >     traits_based_list;
         \endcode
 
         Equivalent option-based code:
         \code
         // GC-related specialization
-        #include <cds/intrusive/lazy_list_ptb.h>
+        #include <cds/intrusive/lazy_list_dhp.h>
 
         struct my_data {
             // see above
@@ -155,10 +135,10 @@ namespace cds { namespace intrusive {
         };
 
         // Declare option-based list
-        typedef cds::intrusive::LazyList< cds::gc::PTB
+        typedef cds::intrusive::LazyList< cds::gc::DHP
             ,my_data
             , typename cds::intrusive::lazy_list::make_traits<
-                cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::PTB > > >
+                cds::intrusive::opt::hook< cds::intrusive::lazy_list::base_hook< cds::opt::gc< cds::gc::DHP > > >
                 ,cds::intrusive::opt::compare< my_data_cmp >
             >::type
         > option_based_list;
@@ -169,7 +149,7 @@ namespace cds { namespace intrusive {
         class GC
         ,typename T
 #ifdef CDS_DOXYGEN_INVOKED
-        ,class Traits = lazy_list::type_traits
+        ,class Traits = lazy_list::traits
 #else
         ,class Traits
 #endif
@@ -177,71 +157,49 @@ namespace cds { namespace intrusive {
     class LazyList
     {
     public:
-        typedef T       value_type      ;   ///< type of value stored in the list
-        typedef Traits  options         ;   ///< Traits template parameter
+        typedef GC     gc;   ///< Garbage collector
+        typedef T      value_type; ///< type of value stored in the list
+        typedef Traits traits;     ///< Traits template parameter
 
-        typedef typename options::hook      hook        ;   ///< hook type
-        typedef typename hook::node_type    node_type   ;   ///< node type
+        typedef typename traits::hook    hook;      ///< hook type
+        typedef typename hook::node_type node_type; ///< node type
 
 #   ifdef CDS_DOXYGEN_INVOKED
         typedef implementation_defined key_comparator  ;    ///< key comparison functor based on opt::compare and opt::less option setter.
 #   else
-        typedef typename opt::details::make_comparator< value_type, options >::type key_comparator;
+        typedef typename opt::details::make_comparator< value_type, traits >::type key_comparator;
 #   endif
 
-        typedef typename options::disposer  disposer    ;   ///< disposer used
-        typedef typename get_node_traits< value_type, node_type, hook>::type node_traits ;    ///< node traits
-        typedef typename lazy_list::get_link_checker< node_type, options::link_checker >::type link_checker   ;   ///< link checker
+        typedef typename traits::disposer  disposer;   ///< disposer
+        typedef typename get_node_traits< value_type, node_type, hook>::type node_traits; ///< node traits
+        typedef typename lazy_list::get_link_checker< node_type, traits::link_checker >::type link_checker; ///< link checker
 
-        typedef GC  gc          ;   ///< Garbage collector
-        typedef typename options::back_off  back_off    ;   ///< back-off strategy
-        typedef typename options::item_counter item_counter ;   ///< Item counting policy used
-        typedef typename options::memory_model  memory_model;   ///< C++ memory ordering (see lazy_list::type_traits::memory_model)
+        typedef typename traits::back_off  back_off    ;   ///< back-off strategy
+        typedef typename traits::item_counter item_counter ;   ///< Item counting policy used
+        typedef typename traits::memory_model  memory_model;   ///< C++ memory ordering (see \p lazy_list::traits::memory_model)
 
         typedef cds::gc::guarded_ptr< gc, value_type > guarded_ptr; ///< Guarded pointer
 
         //@cond
-        // Rebind options (split-list support)
+        // Rebind traits (split-list support)
         template <typename... Options>
-        struct rebind_options {
+        struct rebind_traits {
             typedef LazyList<
                 gc
                 , value_type
-                , typename cds::opt::make_options< options, Options...>::type
+                , typename cds::opt::make_options< traits, Options...>::type
             >   type;
         };
         //@endcond
 
     protected:
-        typedef typename node_type::marked_ptr          marked_node_ptr ;   ///< Node marked pointer
-        typedef node_type *     auxiliary_head   ;   ///< Auxiliary head type (for split-list support)
+        typedef typename node_type::marked_ptr marked_node_ptr;   ///< Node marked pointer
+        typedef node_type *     auxiliary_head;   ///< Auxiliary head type (for split-list support)
 
     protected:
         //@cond
-        typedef lazy_list::boundary_nodes<
-            gc
-            ,typename opt::select_default< typename options::boundary_node_type, node_type >::type
-            ,typename options::allocator
-        >   boundary_nodes;
-        boundary_nodes  m_Boundary    ;   ///< Head & tail dummy nodes
-
-        node_type *     head()
-        {
-            return m_Boundary.head();
-        }
-        node_type const * head() const
-        {
-            return m_Boundary.head();
-        }
-        node_type * tail()
-        {
-            return m_Boundary.tail();
-        }
-        node_type const * tail() const
-        {
-            return m_Boundary.tail();
-        }
-        //@endcond
+        node_type   m_Head;
+        node_type   m_Tail;
 
         item_counter    m_ItemCounter   ;   ///< Item counter
 
@@ -462,7 +420,7 @@ namespace cds { namespace intrusive {
         */
         iterator begin()
         {
-            iterator it( head() );
+            iterator it( &m_Head );
             ++it        ;   // skip dummy head
             return it;
         }
@@ -476,7 +434,7 @@ namespace cds { namespace intrusive {
         */
         iterator end()
         {
-            return iterator( tail() );
+            return iterator( &m_Tail );
         }
 
         /// Returns a forward const iterator addressing the first element in a list
@@ -485,7 +443,7 @@ namespace cds { namespace intrusive {
         {
             return get_const_begin();
         }
-        const_iterator cbegin()
+        const_iterator cbegin() const
         {
             return get_const_begin();
         }
@@ -497,7 +455,7 @@ namespace cds { namespace intrusive {
         {
             return get_const_end();
         }
-        const_iterator cend()
+        const_iterator cend() const
         {
             return get_const_end();
         }
@@ -507,13 +465,13 @@ namespace cds { namespace intrusive {
         //@cond
         const_iterator get_const_begin() const
         {
-            const_iterator it( const_cast<node_type *>( head() ));
+            const_iterator it( const_cast<node_type *>( &m_Head ));
             ++it        ;   // skip dummy head
             return it;
         }
         const_iterator get_const_end() const
         {
-            return const_iterator( const_cast<node_type *>( tail() ));
+            return const_iterator( const_cast<node_type *>(&m_Tail) );
         }
         //@endcond
 
@@ -522,17 +480,15 @@ namespace cds { namespace intrusive {
         LazyList()
         {
             static_assert( (std::is_same< gc, typename node_type::gc >::value), "GC and node_type::gc must be the same type" );
-
-            //m_pTail = cxx_allocator().New();
-            head()->m_pNext.store( marked_node_ptr( tail() ), memory_model::memory_order_relaxed );
+            m_Head.m_pNext.store( marked_node_ptr( &m_Tail ), memory_model::memory_order_relaxed );
         }
 
         /// Destroys the list object
         ~LazyList()
         {
             clear();
-            assert( head()->m_pNext.load(memory_model::memory_order_relaxed).ptr() == tail() );
-            head()->m_pNext.store( marked_node_ptr(), memory_model::memory_order_relaxed );
+            assert( m_Head.m_pNext.load( memory_model::memory_order_relaxed ).ptr() == &m_Tail );
+            m_Head.m_pNext.store( marked_node_ptr(), memory_model::memory_order_relaxed );
         }
 
         /// Inserts new node
@@ -544,7 +500,7 @@ namespace cds { namespace intrusive {
         */
         bool insert( value_type& val )
         {
-            return insert_at( head(), val );
+            return insert_at( &m_Head, val );
         }
 
         /// Inserts new node
@@ -561,14 +517,14 @@ namespace cds { namespace intrusive {
                 void func( value_type& val );
             \endcode
             where \p val is the item inserted.
-            While the functor \p f is working the item \p val is locked.
-            The user-defined functor is called only if the inserting is success and may be passed by reference
-            using \p std::ref
+            While the functor \p f is called the item \p val is locked so
+            the functor has an exclusive access to the item.
+            The user-defined functor is called only if the inserting is success.
         */
         template <typename Func>
         bool insert( value_type& val, Func f )
         {
-            return insert_at( head(), val, f );
+            return insert_at( &m_Head, val, f );
         }
 
         /// Ensures that the \p item exists in the list
@@ -589,9 +545,8 @@ namespace cds { namespace intrusive {
             refer to the same thing.
 
             The functor may change non-key fields of the \p item.
-            While the functor \p f is working the item \p item is locked.
-
-            You may pass \p func argument by reference using \p std::ref.
+            While the functor \p f is working the item \p item is locked,
+            so \p f has exclusive access to the item.
 
             Returns std::pair<bool, bool> where \p first is \p true if operation is successfull,
             \p second is \p true if new item has been added or \p false if the item with \p key
@@ -600,7 +555,7 @@ namespace cds { namespace intrusive {
         template <typename Func>
         std::pair<bool, bool> ensure( value_type& val, Func func )
         {
-            return ensure_at( head(), val, func );
+            return ensure_at( &m_Head, val, func );
         }
 
         /// Unlinks the item \p val from the list
@@ -617,19 +572,19 @@ namespace cds { namespace intrusive {
         */
         bool unlink( value_type& val )
         {
-            return unlink_at( head(), val );
+            return unlink_at( &m_Head, val );
         }
 
         /// Deletes the item from the list
         /** \anchor cds_intrusive_LazyList_hp_erase_val
-            The function searches an item with key equal to \p val in the list,
+            The function searches an item with key equal to \p key in the list,
             unlinks it from the list, and returns \p true.
-            If the item with the key equal to \p val is not found the function return \p false.
+            If the item with the key equal to \p key is not found the function return \p false.
         */
         template <typename Q>
-        bool erase( Q const& val )
+        bool erase( Q const& key )
         {
-            return erase_at( head(), val, key_comparator() );
+            return erase_at( &m_Head, key, key_comparator() );
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
@@ -640,14 +595,14 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool erase_with( Q const& val, Less pred )
+        bool erase_with( Q const& key, Less pred )
         {
-            return erase_at( head(), val, cds::opt::details::make_comparator_from_less<Less>() );
+            return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
         }
 
         /// Deletes the item from the list
         /** \anchor cds_intrusive_LazyList_hp_erase_func
-            The function searches an item with key equal to \p val in the list,
+            The function searches an item with key equal to \p key in the list,
             call \p func functor with item found, unlinks it from the list, and returns \p true.
             The \p Func interface is
             \code
@@ -655,14 +610,13 @@ namespace cds { namespace intrusive {
                 void operator()( value_type const& item );
             };
             \endcode
-            The functor may be passed by reference using <tt>boost:ref</tt>
 
-            If the item with the key equal to \p val is not found the function return \p false.
+            If \p key is not found the function return \p false.
         */
         template <typename Q, typename Func>
-        bool erase( const Q& val, Func func )
+        bool erase( const Q& key, Func func )
         {
-            return erase_at( head(), val, key_comparator(), func );
+            return erase_at( &m_Head, key, key_comparator(), func );
         }
 
         /// Deletes the item from the list using \p pred predicate for searching
@@ -673,9 +627,9 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less, typename Func>
-        bool erase_with( const Q& val, Less pred, Func func )
+        bool erase_with( const Q& key, Less pred, Func func )
         {
-            return erase_at( head(), val, cds::opt::details::make_comparator_from_less<Less>(), func );
+            return erase_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>(), func );
         }
 
         /// Extracts the item from the list with specified \p key
@@ -709,7 +663,7 @@ namespace cds { namespace intrusive {
         template <typename Q>
         bool extract( guarded_ptr& dest, Q const& key )
         {
-            return extract_at( head(), dest.guard(), key, key_comparator() );
+            return extract_at( &m_Head, dest.guard(), key, key_comparator() );
         }
 
         /// Extracts the item from the list with comparing functor \p pred
@@ -724,37 +678,32 @@ namespace cds { namespace intrusive {
         template <typename Q, typename Less>
         bool extract_with( guarded_ptr& dest, Q const& key, Less pred )
         {
-            return extract_at( head(), dest.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
+            return extract_at( &m_Head, dest.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
         }
 
-        /// Finds the key \p val
+        /// Finds the key \p key
         /** \anchor cds_intrusive_LazyList_hp_find
-            The function searches the item with key equal to \p val and calls the functor \p f for item found.
+            The function searches the item with key equal to \p key and calls the functor \p f for item found.
             The interface of \p Func functor is:
             \code
             struct functor {
-                void operator()( value_type& item, Q& val );
+                void operator()( value_type& item, Q& key );
             };
             \endcode
-            where \p item is the item found, \p val is the <tt>find</tt> function argument.
-
-            You may pass \p f argument by reference using \p std::ref.
+            where \p item is the item found, \p key is the <tt>find</tt> function argument.
 
             The functor may change non-key fields of \p item.
             While the functor \p f is calling the item \p item is locked.
 
-            The \p val argument is non-const since it can be used as \p f functor destination i.e., the functor
-            may modify both arguments.
-
-            The function returns \p true if \p val is found, \p false otherwise.
+            The function returns \p true if \p key is found, \p false otherwise.
         */
         template <typename Q, typename Func>
-        bool find( Q& val, Func f )
+        bool find( Q& key, Func f )
         {
-            return find_at( head(), val, key_comparator(), f );
+            return find_at( &m_Head, key, key_comparator(), f );
         }
 
-        /// Finds the key \p val using \p pred predicate for searching
+        /// Finds the key \p key using \p pred predicate for searching
         /**
             The function is an analog of \ref cds_intrusive_LazyList_hp_find "find(Q&, Func)"
             but \p pred is used for key comparing.
@@ -762,60 +711,23 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less, typename Func>
-        bool find_with( Q& val, Less pred, Func f )
+        bool find_with( Q& key, Less pred, Func f )
         {
-            return find_at( head(), val, cds::opt::details::make_comparator_from_less<Less>(), f );
+            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>(), f );
         }
 
-        /// Finds the key \p val
-        /** \anchor cds_intrusive_LazyList_hp_find_const
-            The function searches the item with key equal to \p val and calls the functor \p f for item found.
-            The interface of \p Func functor is:
-            \code
-            struct functor {
-                void operator()( value_type& item, Q const& val );
-            };
-            \endcode
-            where \p item is the item found, \p val is the \p find function argument.
-
-            You may pass \p f argument by reference using \p std::ref.
-
-            The functor may change non-key fields of \p item.
-            While the functor \p f is calling the item \p item is locked.
-
-            The function returns \p true if \p val is found, \p false otherwise.
-        */
-        template <typename Q, typename Func>
-        bool find( Q const& val, Func f )
-        {
-            return find_at( head(), val, key_comparator(), f );
-        }
-
-        /// Finds the key \p val using \p pred predicate for searching
-        /**
-            The function is an analog of \ref cds_intrusive_LazyList_hp_find_const "find(Q const&, Func)"
-            but \p pred is used for key comparing.
-            \p Less functor has the interface like \p std::less.
-            \p pred must imply the same element order as the comparator used for building the list.
-        */
-        template <typename Q, typename Less, typename Func>
-        bool find_with( Q const& val, Less pred, Func f )
-        {
-            return find_at( head(), val, cds::opt::details::make_comparator_from_less<Less>(), f );
-        }
-
-        /// Finds the key \p val
+        /// Finds the key \p key
         /** \anchor cds_intrusive_LazyList_hp_find_val
-            The function searches the item with key equal to \p val
+            The function searches the item with key equal to \p key
             and returns \p true if it is found, and \p false otherwise
         */
         template <typename Q>
-        bool find( Q const & val )
+        bool find( Q const & key )
         {
-            return find_at( head(), val, key_comparator() );
+            return find_at( &m_Head, key, key_comparator() );
         }
 
-        /// Finds the key \p val using \p pred predicate for searching
+        /// Finds \p key using \p pred predicate for searching
         /**
             The function is an analog of \ref cds_intrusive_LazyList_hp_find_val "find(Q const&)"
             but \p pred is used for key comparing.
@@ -823,17 +735,17 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool find_with( Q const& val, Less pred )
+        bool find_with( Q const& key, Less pred )
         {
-            return find_at( head(), val, cds::opt::details::make_comparator_from_less<Less>() );
+            return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
         }
 
-        /// Finds the key \p val and return the item found
+        /// Finds \p key and return the item found
         /** \anchor cds_intrusive_LazyList_hp_get
-            The function searches the item with key equal to \p val
+            The function searches the item with key equal to \p key
             and assigns the item found to guarded pointer \p ptr.
-            The function returns \p true if \p val is found, and \p false otherwise.
-            If \p val is not found the \p ptr parameter is not changed.
+            The function returns \p true if \p key is found, and \p false otherwise.
+            If \p key is not found the \p ptr parameter is not changed.
 
             The \ref disposer specified in \p Traits class template parameter is called
             by garbage collector \p GC automatically when returned \ref guarded_ptr object
@@ -859,12 +771,12 @@ namespace cds { namespace intrusive {
             should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
-        bool get( guarded_ptr& ptr, Q const& val )
+        bool get( guarded_ptr& ptr, Q const& key )
         {
-            return get_at( head(), ptr.guard(), val, key_comparator() );
+            return get_at( &m_Head, ptr.guard(), key, key_comparator() );
         }
 
-        /// Finds the key \p val and return the item found
+        /// Finds \p key and return the item found
         /**
             The function is an analog of \ref cds_intrusive_LazyList_hp_get "get( guarded_ptr& ptr, Q const&)"
             but \p pred is used for comparing the keys.
@@ -874,30 +786,27 @@ namespace cds { namespace intrusive {
             \p pred must imply the same element order as the comparator used for building the list.
         */
         template <typename Q, typename Less>
-        bool get_with( guarded_ptr& ptr, Q const& val, Less pred )
+        bool get_with( guarded_ptr& ptr, Q const& key, Less pred )
         {
-            return get_at( head(), ptr.guard(), val, cds::opt::details::make_comparator_from_less<Less>() );
+            return get_at( &m_Head, ptr.guard(), key, cds::opt::details::make_comparator_from_less<Less>() );
         }
 
         /// Clears the list
-        /**
-            The function unlink all items from the list.
-        */
         void clear()
         {
             typename gc::Guard guard;
             marked_node_ptr h;
             while ( !empty() ) {
-                h = head()->m_pNext.load(memory_model::memory_order_relaxed);
+                h = m_Head.m_pNext.load( memory_model::memory_order_relaxed );
                 guard.assign( node_traits::to_value_ptr( h.ptr() ));
-                if ( head()->m_pNext.load(memory_model::memory_order_acquire) == h ) {
-                    head()->m_Lock.lock();
+                if ( m_Head.m_pNext.load(memory_model::memory_order_acquire) == h ) {
+                    m_Head.m_Lock.lock();
                     h->m_Lock.lock();
 
-                    unlink_node( head(), h.ptr(), head() );
+                    unlink_node( &m_Head, h.ptr(), &m_Head );
 
                     h->m_Lock.unlock();
-                    head()->m_Lock.unlock();
+                    m_Head.m_Lock.unlock();
 
                     retire_node( h.ptr() ) ; // free node
                 }
@@ -907,16 +816,16 @@ namespace cds { namespace intrusive {
         /// Checks if the list is empty
         bool empty() const
         {
-            return head()->m_pNext.load(memory_model::memory_order_relaxed).ptr() == tail();
+            return m_Head.m_pNext.load( memory_model::memory_order_relaxed ).ptr() == &m_Tail;
         }
 
         /// Returns list's item count
         /**
-            The value returned depends on opt::item_counter option. For atomicity::empty_item_counter,
+            The value returned depends on item counter provided by \p Traits. For \p atomicity::empty_item_counter,
             this function always returns 0.
 
-            <b>Warning</b>: even if you use real item counter and it returns 0, this fact is not mean that the list
-            is empty. To check list emptyness use \ref empty() method.
+            @note Even if you use real item counter and it returns 0, this fact does not mean that the list
+            is empty. To check list emptyness use \p empty() method.
         */
         size_t size() const
         {
@@ -928,7 +837,7 @@ namespace cds { namespace intrusive {
         // split-list support
         bool insert_aux_node( node_type * pNode )
         {
-            return insert_aux_node( head(), pNode );
+            return insert_aux_node( &m_Head, pNode );
         }
 
         // split-list support
@@ -937,8 +846,8 @@ namespace cds { namespace intrusive {
             assert( pNode != nullptr );
 
             // Hack: convert node_type to value_type.
-            // In principle, auxiliary node can be non-reducible to value_type
-            // We assume that comparator can correctly distinguish aux and regular node.
+            // In principle, auxiliary node cannot be reducible to value_type
+            // We assume that internal comparator can correctly distinguish aux and regular node.
             return insert_at( pHead, *node_traits::to_value_ptr( pNode ) );
         }
 
@@ -953,7 +862,7 @@ namespace cds { namespace intrusive {
                 {
                     auto_lock_position alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
-                        if ( pos.pCur != tail() && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
+                        if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // failed: key already in list
                             return false;
                         }
@@ -979,7 +888,7 @@ namespace cds { namespace intrusive {
                 {
                     auto_lock_position alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
-                        if ( pos.pCur != tail() && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
+                        if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // failed: key already in list
                             return false;
                         }
@@ -1005,7 +914,7 @@ namespace cds { namespace intrusive {
                 {
                     auto_lock_position alp( pos );
                     if ( validate( pos.pPred, pos.pCur )) {
-                        if ( pos.pCur != tail() && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
+                        if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                             // key already in the list
 
                             func( false, *node_traits::to_value_ptr( *pos.pCur ) , val );
@@ -1037,7 +946,7 @@ namespace cds { namespace intrusive {
                     {
                         auto_lock_position alp( pos );
                         if ( validate( pos.pPred, pos.pCur ) ) {
-                            if ( pos.pCur != tail()
+                            if ( pos.pCur != &m_Tail
                                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0
                                 && node_traits::to_value_ptr( pos.pCur ) == &val )
                             {
@@ -1071,7 +980,7 @@ namespace cds { namespace intrusive {
                     {
                         auto_lock_position alp( pos );
                         if ( validate( pos.pPred, pos.pCur )) {
-                            if ( pos.pCur != tail() && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
+                            if ( pos.pCur != &m_Tail && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 ) {
                                 // key found
                                 unlink_node( pos.pPred, pos.pCur, pHead );
                                 f( *node_traits::to_value_ptr( *pos.pCur ) );
@@ -1125,7 +1034,7 @@ namespace cds { namespace intrusive {
             position pos;
 
             search( pHead, val, pos, cmp );
-            if ( pos.pCur != tail() ) {
+            if ( pos.pCur != &m_Tail ) {
                 std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
                 if ( !pos.pCur->is_marked()
                     && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
@@ -1143,7 +1052,7 @@ namespace cds { namespace intrusive {
             position pos;
 
             search( pHead, val, pos, cmp );
-            return pos.pCur != tail()
+            return pos.pCur != &m_Tail
                 && !pos.pCur->is_marked()
                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0;
         }
@@ -1154,7 +1063,7 @@ namespace cds { namespace intrusive {
             position pos;
 
             search( pHead, val, pos, cmp );
-            if ( pos.pCur != tail()
+            if ( pos.pCur != &m_Tail
                 && !pos.pCur->is_marked()
                 && cmp( *node_traits::to_value_ptr( *pos.pCur ), val ) == 0 )
             {
@@ -1171,7 +1080,7 @@ namespace cds { namespace intrusive {
         template <typename Q, typename Compare>
         void search( node_type * pHead, const Q& key, position& pos, Compare cmp )
         {
-            const node_type * pTail = tail();
+            const node_type * pTail = &m_Tail;
 
             marked_node_ptr pCur( pHead );
             marked_node_ptr pPrev( pHead );