Fixed doxygen 1.8.10 incompabilities
[libcds.git] / cds / container / lazy_kvlist_nogc.h
index f05fc4446fb94f2cbd3ff1fd8fdddcd66c9e377d..77d38897bfdbc008763c8e83bad1bd7b8015d6aa 100644 (file)
@@ -1,54 +1,29 @@
 //$$CDS-header$$
 
-#ifndef __CDS_CONTAINER_LAZY_KVLIST_NOGC_H
-#define __CDS_CONTAINER_LAZY_KVLIST_NOGC_H
+#ifndef CDSLIB_CONTAINER_LAZY_KVLIST_NOGC_H
+#define CDSLIB_CONTAINER_LAZY_KVLIST_NOGC_H
 
 #include <memory>
 #include <cds/container/details/lazy_list_base.h>
 #include <cds/intrusive/lazy_list_nogc.h>
 #include <cds/container/details/make_lazy_kvlist.h>
-#include <cds/details/functor_wrapper.h>
 
 namespace cds { namespace container {
 
-    //@cond
-    namespace details {
-
-        template <typename K, typename T, class Traits>
-        struct make_lazy_kvlist_nogc: public make_lazy_kvlist<gc::nogc, K, T, Traits>
-        {
-            typedef make_lazy_kvlist<cds::gc::nogc, K, T, Traits>  base_maker;
-            typedef typename base_maker::node_type node_type;
-
-            struct type_traits: public base_maker::type_traits
-            {
-                typedef typename base_maker::node_deallocator    disposer;
-            };
-
-            typedef intrusive::LazyList<cds::gc::nogc, node_type, type_traits>  type;
-        };
-
-    }   // namespace details
-    //@endcond
-
     /// Lazy ordered list (key-value pair, template specialization for gc::nogc)
     /** @ingroup cds_nonintrusive_list
+        @anchor cds_nonintrusive_LazyKVList_nogc
 
-        This specialization is intended for so-called persistent usage when no item
-        reclamation may be performed. The class does not support deleting of list item.
-
-        Usually, ordered single-linked list is used as a building block for the hash table implementation.
-        The complexity of searching is <tt>O(N)</tt>.
-
-        See \ref cds_nonintrusive_LazyList_gc "LazyList" for description of template parameters.
+        This specialization is append-only list when no item
+        reclamation may be performed. The class does not support deleting of list's item.
 
-        The interface of the specialization is a little different.
+        See @ref cds_nonintrusive_LazyList_gc "cds::container::LazyList<cds::gc::nogc, T, Traits>"
     */
     template <
         typename Key,
         typename Value,
 #ifdef CDS_DOXYGEN_INVOKED
-        typename Traits = lazy_list::type_traits
+        typename Traits = lazy_list::traits
 #else
         typename Traits
 #endif
@@ -57,38 +32,39 @@ namespace cds { namespace container {
 #ifdef CDS_DOXYGEN_INVOKED
         protected intrusive::LazyList< gc::nogc, implementation_defined, Traits >
 #else
-        protected details::make_lazy_kvlist_nogc< Key, Value, Traits >::type
+        protected details::make_lazy_kvlist< cds::gc::nogc, Key, Value, Traits >::type
 #endif
     {
         //@cond
-        typedef details::make_lazy_kvlist_nogc< Key, Value, Traits > options;
-        typedef typename options::type  base_class;
+        typedef details::make_lazy_kvlist< cds::gc::nogc, Key, Value, Traits > maker;
+        typedef typename maker::type  base_class;
         //@endcond
 
     public:
+        typedef Traits traits;    ///< List traits
+        typedef cds::gc::nogc gc; ///< Garbage collector
 #ifdef CDS_DOXYGEN_INVOKED
         typedef Key                                 key_type        ;   ///< Key type
         typedef Value                               mapped_type     ;   ///< Type of value stored in the list
         typedef std::pair<key_type const, mapped_type> value_type   ;   ///< key/value pair stored in the list
 #else
-        typedef typename options::key_type          key_type;
-        typedef typename options::value_type        mapped_type;
-        typedef typename options::pair_type         value_type;
+        typedef typename maker::key_type    key_type;
+        typedef typename maker::mapped_type mapped_type;
+        typedef typename maker::value_type  value_type;
 #endif
-        typedef typename base_class::gc             gc              ;   ///< Garbage collector used
-        typedef typename base_class::back_off       back_off        ;   ///< Back-off strategy used
-        typedef typename options::allocator_type    allocator_type  ;   ///< Allocator type used for allocate/deallocate the nodes
-        typedef typename base_class::item_counter   item_counter    ;   ///< Item counting policy used
-        typedef typename options::key_comparator    key_comparator  ;   ///< key comparison functor
-        typedef typename base_class::memory_model   memory_model    ;   ///< Memory ordering. See cds::opt::memory_model option
+        typedef typename base_class::back_off     back_off;       ///< Back-off strategy used
+        typedef typename maker::allocator_type    allocator_type; ///< Allocator type used for allocate/deallocate the nodes
+        typedef typename base_class::item_counter item_counter;   ///< Item counting policy used
+        typedef typename maker::key_comparator    key_comparator; ///< key comparison functor
+        typedef typename base_class::memory_model memory_model;   ///< Memory ordering. See cds::opt::memory_model option
+        static CDS_CONSTEXPR bool const c_bSort = base_class::c_bSort; ///< List type: ordered (\p true) or unordered (\p false)
 
     protected:
         //@cond
         typedef typename base_class::value_type     node_type;
-        typedef typename options::cxx_allocator     cxx_allocator;
-        typedef typename options::node_deallocator  node_deallocator;
-        typedef typename options::type_traits::compare  intrusive_key_comparator;
-
+        typedef typename maker::cxx_allocator       cxx_allocator;
+        typedef typename maker::node_deallocator    node_deallocator;
+        typedef typename base_class::key_comparator intrusive_key_comparator;
         typedef typename base_class::node_type      head_type;
         //@endcond
 
@@ -288,7 +264,7 @@ namespace cds { namespace container {
             ++it ;  // skip dummy head
             return it;
         }
-        const_iterator cbegin()
+        const_iterator cbegin() const
         {
             const_iterator it( head() );
             ++it ;  // skip dummy head
@@ -302,7 +278,7 @@ namespace cds { namespace container {
         {
             return const_iterator( tail());
         }
-        const_iterator cend()
+        const_iterator cend() const
         {
             return const_iterator( tail());
         }
@@ -320,16 +296,10 @@ namespace cds { namespace container {
 
     public:
         /// Default constructor
-        /**
-            Initialize empty list
-        */
         LazyKVList()
         {}
 
-        /// List desctructor
-        /**
-            Clears the list
-        */
+        /// Desctructor clears the list
         ~LazyKVList()
         {
             clear();
@@ -385,10 +355,7 @@ namespace cds { namespace container {
 
             The argument \p item of user-defined functor \p func is the reference
             to the list's item inserted. <tt>item.second</tt> is a reference to item's value that may be changed.
-            User-defined functor \p func should guarantee that during changing item's value no any other changes
-            could be made on this list's item by concurrent threads.
-            The user-defined functor can be passed by reference using <tt>boost::ref</tt>
-            and it is called only if the inserting is successful.
+            The user-defined functor is called only if the inserting is successful.
 
             The key_type should be constructible from value of type \p K.
 
@@ -403,9 +370,9 @@ namespace cds { namespace container {
             Returns an iterator pointed to inserted value, or \p end() if inserting is failed
         */
         template <typename K, typename Func>
-        iterator insert_key( const K& key, Func func )
+        iterator insert_with( const K& key, Func func )
         {
-            return node_to_iterator( insert_key_at( head(), key, func ));
+            return node_to_iterator( insert_with_at( head(), key, func ));
         }
 
         /// Ensures that the key \p key exists in the list
@@ -446,17 +413,31 @@ namespace cds { namespace container {
             return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ) );
         }
 
-        /// Finds the key \p val using \p pred predicate for searching
+        /// Finds the key \p val using \p pred predicate for searching (for ordered list only)
         /**
             The function is an analog of \ref cds_nonintrusive_LazyKVList_nogc_find "find(Q const&)"
             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>
-        iterator find_with( Q const& key, Less pred )
+        template <typename Q, typename Less, bool Sort = c_bSort>
+        typename std::enable_if<Sort, iterator>::type find_with( Q const& key, Less pred )
+        {
+            CDS_UNUSED( pred );
+            return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );
+        }
+
+        /// Finds the key \p val using \p equal predicate for searching (for unordered list only)
+        /**
+            The function is an analog of \ref cds_nonintrusive_LazyKVList_nogc_find "find(Q const&)"
+            but \p equal is used for key comparing.
+            \p Equal functor has the interface like \p std::equal_to.
+        */
+        template <typename Q, typename Equal, bool Sort = c_bSort>
+        typename std::enable_if<!Sort, iterator>::type find_with( Q const& key, Equal equal )
         {
-            return node_to_iterator( find_at( head(), key, typename options::template less_wrapper<Less>::type() ) );
+            CDS_UNUSED( equal );
+            return node_to_iterator( find_at( head(), key, typename maker::template equal_to_wrapper<Equal>::type() ) );
         }
 
         /// Check if the list is empty
@@ -470,7 +451,7 @@ namespace cds { namespace container {
             The value returned depends on opt::item_counter option. For 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
+            @note 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.
         */
         size_t size() const
@@ -512,12 +493,12 @@ namespace cds { namespace container {
         }
 
         template <typename K, typename Func>
-        node_type * insert_key_at( head_type& refHead, const K& key, Func f )
+        node_type * insert_with_at( head_type& refHead, const K& key, Func f )
         {
             scoped_node_ptr pNode( alloc_node( key ));
 
             if ( base_class::insert_at( &refHead, *pNode )) {
-                cds::unref(f)( pNode->m_Data );
+                f( pNode->m_Data );
                 return pNode.release();
             }
 
@@ -555,7 +536,7 @@ namespace cds { namespace container {
         template <typename K, typenam Compare, typename Func>
         bool find_at( head_type& refHead, K& key, Compare cmp, Func f )
         {
-            return base_class::find_at( &refHead, key, cmp, [&f]( node_type& node, K const& ){ cds::unref(f)( node.m_Data ); });
+            return base_class::find_at( &refHead, key, cmp, [&f]( node_type& node, K const& ){ f( node.m_Data ); });
         }
         */
         //@endcond
@@ -563,4 +544,4 @@ namespace cds { namespace container {
 
 }} // namespace cds::container
 
-#endif // #ifndef __CDS_CONTAINER_LAZY_KVLIST_NOGC_H
+#endif // #ifndef CDSLIB_CONTAINER_LAZY_KVLIST_NOGC_H