Removed unused vars
[libcds.git] / cds / container / striped_set.h
index 13a1be434cee354f1aca9cec7d3452b16384f4a3..1eae6b91010a4da8db07670308b845f2ccf01dd0 100644 (file)
@@ -33,34 +33,33 @@ namespace cds { namespace container {
         among \p Options template arguments.
 
         The \p Options are:
-            - opt::mutex_policy - concurrent access policy.
-                Available policies: intrusive::striped_set::striping, intrusive::striped_set::refinable.
-                Default is %striped_set::striping.
-            - opt::hash - hash functor. Default option value see opt::v::hash_selector<opt::none> which selects default hash functor for
-                your compiler.
-            - 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::item_counter - item counter type. Default is \p atomicity::item_counter since some operation on the counter is performed
-                without locks. Note that item counting is an essential part of the set algorithm, so dummy type like atomicity::empty_item_counter
-                is not suitable.
-            - opt::allocator - the allocator type using for memory allocation of bucket table and lock array. Default is CDS_DEFAULT_ALLOCATOR.
-            - opt::resizing_policy - the resizing policy that is a functor that decides when to resize the hash set.
+            - \p opt::mutex_policy - concurrent access policy.
+                Available policies: \p intrusive::striped_set::striping, \p intrusive::striped_set::refinable.
+                Default is \p %striped_set::striping.
+            - \p opt::hash - hash functor. Default option value see <tt>opt::v::hash_selector<opt::none> </tt> 
+                which selects default hash functor for your compiler.
+            - \p opt::compare - key comparison functor. No default functor is provided.
+                If the option is not specified, the \p %opt::less is used.
+            - \p opt::less - specifies binary predicate used for key comparison. Default is \p std::less<T>.
+            - \p opt::item_counter - item counter type. Default is \p atomicity::item_counter since some operation on the counter is performed
+                without locks. Note that item counting is an essential part of the set algorithm, so dummy counter 
+                like as \p atomicity::empty_item_counter is not suitable.
+            - \p opt::allocator - the allocator type using for memory allocation of bucket table and lock array. Default is \ref CDS_DEFAULT_ALLOCATOR.
+            - \p opt::resizing_policy - the resizing policy that is a functor that decides when to resize the hash set.
                 Default option value depends on bucket container type:
-                    for sequential containers like \p std::list, \p std::vector the resizing policy is striped_set::load_factor_resizing<4>;
-                    for other type of containers like \p std::set, \p std::unordered_set the resizing policy is striped_set::no_resizing.
-                See \ref striped_set namespace for list of all possible types of the option.
+                    for sequential containers like \p std::list, \p std::vector the resizing policy is <tt>striped_set::load_factor_resizing<4> </tt>;
+                    for other type of containers like \p std::set, \p std::unordered_set the resizing policy is \p striped_set::no_resizing.
+                See \ref cds_striped_resizing_policy "available resizing policy".
                 Note that the choose of resizing policy depends of \p Container type:
                 for sequential containers like \p std::list, \p std::vector and so on, right choosing of the policy can
                 significantly improve performance.
-                For other, non-sequential types of \p Container (like a \p std::set)
-                the resizing policy is not so important.
-            - opt::copy_policy - the copy policy which is used to copy items from the old set to the new one when resizing.
+                For other, non-sequential types of \p Container (like a \p std::set) the resizing policy is not so important.
+            - \p opt::copy_policy - the copy policy which is used to copy items from the old set to the new one when resizing.
                 The policy can be optionally used in adapted bucket container for performance reasons of resizing.
                 The detail of copy algorithm depends on type of bucket container and explains below.
 
-            opt::compare or opt::less options are used in some \p Container class for searching an item.
-            opt::compare option has the highest priority: if opt::compare is specified, opt::less is not used.
+            \p %opt::compare or \p %opt::less options are used in some \p Container class for searching an item.
+            \p %opt::compare option has the highest priority: if \p %opt::compare is specified, \p %opt::less is not used.
 
         You can pass other option that would be passed to <tt>adapt</tt> metafunction, see below.
 
@@ -74,7 +73,7 @@ namespace cds { namespace container {
             All you need is to include a right header before <tt>striped_hash_set.h</tt>.
 
             By default, <tt>striped_set::adapt<AnyContainer, Options...> </tt> metafunction does not make any wrapping to \p AnyContainer,
-            so, the result <tt>%striped_set::adapt<AnyContainer, Options...>::type </tt> is the same as \p AnyContainer.
+            so, the result <tt>striped_set::adapt<AnyContainer, Options...>::type </tt> is the same as \p AnyContainer.
             However, there are a lot of specializations of <tt>striped_set::adapt</tt> for well-known containers, see table below.
             Any of this specialization wraps corresponding container making it suitable for the set's bucket.
             Remember, you should include the proper header file for \p adapt <b>before</b> including <tt>striped_hash_set.h</tt>.
@@ -116,7 +115,7 @@ namespace cds { namespace container {
                     </td>
                     <td>
                         The vector is ordered.
-                        Template argument pack \p Options <b>must</b> contain cds::opt::less or cds::opt::compare for type \p T stored in the list
+                        Template argument pack \p Options <b>must</b> contain \p cds::opt::less or \p cds::opt::compare for type \p T stored in the list
                     </td>
                 </tr>
                 <tr>
@@ -149,28 +148,7 @@ namespace cds { namespace container {
                     \endcode
                     </td>
                     <td>
-                        You should provide two different hash function \p h1 and \p h2 - one for std::unordered_set and other for \p %StripedSet.
-                        For the best result, \p h1 and \p h2 must be orthogonal i.e. <tt> h1(X) != h2(X) </tt> for any value \p X.
-                    </td>
-                </tr>
-                <tr>
-                    <td>\p stdext::hash_set (only for MS VC++ 2008)</td>
-                    <td><tt><cds/container/striped_set/std_hash_set.h></tt></td>
-                    <td>\code
-                        #include <cds/container/striped_set/std_hash_set.h>
-                        #include <cds/container/striped_hash_set.h>
-                        typedef cds::container::StripedSet<
-                            stdext::hash_set< T,
-                                stdext::hash_compare<
-                                    T,
-                                    std::less<T>
-                                >
-                            >
-                        > striped_set;
-                    \endcode
-                    </td>
-                    <td>
-                        You should provide two different hash function \p h1 and \p h2 - one for stdext::hash_set and other for \p %StripedSet.
+                        You should provide two different hash function \p h1 and \p h2 - one for \p std::unordered_set and other for \p %StripedSet.
                         For the best result, \p h1 and \p h2 must be orthogonal i.e. <tt> h1(X) != h2(X) </tt> for any value \p X.
                     </td>
                 </tr>
@@ -187,7 +165,7 @@ namespace cds { namespace container {
                     </td>
                     <td>
                         The list is ordered.
-                        \p Options <b>must</b> contain cds::opt::less or cds::opt::compare.
+                        \p Options <b>must</b> contain \p cds::opt::less or \p cds::opt::compare.
                     </td>
                 </tr>
                 <tr>
@@ -203,7 +181,7 @@ namespace cds { namespace container {
                     </td>
                     <td>
                         The list is ordered.
-                        \p Options <b>must</b> contain cds::opt::less or cds::opt::compare.
+                        \p Options <b>must</b> contain \p cds::opt::less or \p cds::opt::compare.
                     </td>
                 </tr>
                 <tr>
@@ -220,7 +198,7 @@ namespace cds { namespace container {
                     </td>
                     <td>
                         The vector is ordered.
-                        Template argument pack \p Options <b>must</b> contain cds::opt::less or cds::opt::compare for type \p T stored in the list
+                        Template argument pack \p Options <b>must</b> contain \p cds::opt::less or \p cds::opt::compare for type \p T stored in the vector
                     </td>
                 </tr>
                 <tr>
@@ -237,7 +215,7 @@ namespace cds { namespace container {
                     </td>
                     <td>
                         The vector is ordered.
-                        Template argument pack \p Options <b>must</b> contain cds::opt::less or cds::opt::compare for type \p T stored in the list
+                        Template argument pack \p Options <b>must</b> contain \p cds::opt::less or \p cds::opt::compare for type \p T stored in the vector
                     </td>
                 </tr>
                 <tr>
@@ -284,7 +262,7 @@ namespace cds { namespace container {
                     \endcode
                     </td>
                     <td>
-                        You should provide two different hash function \p h1 and \p h2 - one for boost::unordered_set and other for \p %StripedSet.
+                        You should provide two different hash function \p h1 and \p h2 - one for \p boost::unordered_set and other for \p %StripedSet.
                         For the best result, \p h1 and \p h2 must be orthogonal i.e. <tt> h1(X) != h2(X) </tt> for any value \p X.
                     </td>
                 </tr>
@@ -362,7 +340,6 @@ namespace cds { namespace container {
                     <td>
                         - \p std::set
                         - \p std::unordered_set
-                        - \p stdext::hash_set (only for MS VC++ 2008)
                     </td>
                     <td>\code
                         struct copy_item {
@@ -415,7 +392,7 @@ namespace cds { namespace container {
 
         <b>Advanced functions</b>
 
-            <b>libcds</b> provides some advanced functions like \p erase_with, \p find_with,
+            <b>libcds</b> provides some advanced functions like \p erase_with(), \p find_with(),
             that cannot be supported by all underlying containers.
             The table below shows whether underlying container supports those functions
             (the sign "+" means "container supports the function"):
@@ -446,11 +423,6 @@ namespace cds { namespace container {
                     <td>-</td>
                     <td>-</td>
                 </tr>
-                <tr>
-                    <td>\p stdext::hash_set (only for MS VC++ 2008)</td>
-                    <td>-</td>
-                    <td>-</td>
-                </tr>
                 <tr>
                     <td> \p boost::container::slist</td>
                     <td>+</td>
@@ -488,11 +460,11 @@ namespace cds { namespace container {
                 </tr>
             </table>
     */
-    template <class Container, CDS_DECL_OPTIONS9>
-    class StripedSet: protected intrusive::StripedSet<Container, CDS_OPTIONS9>
+    template <class Container, typename... Options>
+    class StripedSet: protected intrusive::StripedSet<Container, Options...>
     {
         //@cond
-        typedef intrusive::StripedSet<Container, CDS_OPTIONS9>  base_class;
+        typedef intrusive::StripedSet<Container, Options...>  base_class;
         //@endcond
     public:
         //@cond
@@ -517,27 +489,6 @@ namespace cds { namespace container {
         typedef typename base_class::scoped_resize_lock scoped_resize_lock;
         //@endcond
 
-    protected:
-        //@cond
-#   ifndef CDS_CXX11_LAMBDA_SUPPORT
-        struct empty_insert_functor {
-            void operator()( value_type& )
-            {}
-        };
-
-        struct empty_erase_functor  {
-            void operator()( value_type const& )
-            {}
-        };
-
-        struct empty_find_functor {
-            template <typename Q>
-            void operator()( value_type& item, Q& val )
-            {}
-        };
-#   endif
-        //@endcond
-
     public:
         /// Default ctor. The initial capacity is 16.
         StripedSet()
@@ -582,19 +533,15 @@ namespace cds { namespace container {
             and then inserts the node created into the set.
 
             The type \p Q should contain as minimum the complete key for the node.
-            The object of \ref value_type should be constructible from a value of type \p Q.
-            In trivial case, \p Q is equal to \ref value_type.
+            The object of \p value_type should be constructible from a value of type \p Q.
+            In trivial case, \p Q is equal to \p value_type.
 
             Returns \p true if \p val is inserted into the set, \p false otherwise.
         */
         template <typename Q>
         bool insert( Q const& val )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
             return insert( val, []( value_type& ) {} );
-#       else
-            return insert( val, empty_insert_functor() );
-#       endif
         }
 
         /// Inserts new node
@@ -610,11 +557,10 @@ namespace cds { namespace container {
             \endcode
             where \p item is the item inserted.
 
-            The type \p Q can differ from \ref value_type of items storing in the set.
+            The type \p Q can differ from \p value_type of items storing in the set.
             Therefore, the \p value_type should be constructible from type \p Q.
 
-            The user-defined functor is called only if the inserting is success. It can be passed by reference
-            using <tt>boost::ref</tt>
+            The user-defined functor is called only if the inserting is success.
         */
         template <typename Q, typename Func>
         bool insert( Q const& val, Func f )
@@ -683,8 +629,6 @@ namespace cds { namespace container {
 
             The functor can change non-key fields of the \p item.
 
-            You can pass \p func argument by value or by reference using <tt>boost::ref</tt>.
-
             Returns <tt> std::pair<bool, bool> </tt> where \p first is true if operation is successfull,
             \p second is true if new item has been added or \p false if the item with \p val key
             already exists.
@@ -718,11 +662,7 @@ namespace cds { namespace container {
         template <typename Q>
         bool erase( Q const& key )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
             return erase( key, [](value_type const&) {} );
-#       else
-            return erase( key, empty_erase_functor() );
-#       endif
         }
 
         /// Deletes the item from the set using \p pred predicate for searching
@@ -740,11 +680,7 @@ namespace cds { namespace container {
             ,typename Bucket = bucket_type, typename = typename std::enable_if< Bucket::has_erase_with >::type >
         bool erase_with( Q const& key, Less pred )
         {
-#       ifdef CDS_CXX11_LAMBDA_SUPPORT
             return erase_with( key, pred, [](value_type const&) {} );
-#       else
-            return erase_with( key, pred, empty_erase_functor() );
-#       endif
         }
 
         /// Delete \p key from the set
@@ -759,7 +695,6 @@ namespace cds { namespace container {
                 void operator()(value_type const& val);
             };
             \endcode
-            The functor can be passed by value or by reference using <tt>boost:ref</tt>
 
             Return \p true if key is found and deleted, \p false otherwise
         */
@@ -821,13 +756,11 @@ namespace cds { namespace container {
             \endcode
             where \p item is the item found, \p val is the <tt>find</tt> function argument.
 
-            You can pass \p f argument by value or by reference using <tt>boost::ref</tt> or cds::ref.
-
             The functor can change non-key fields of \p item.
             The \p val argument is non-const since it can be used as \p f functor destination i.e., the functor
             can modify both arguments.
 
-            The type \p Q can differ from \ref value_type of items storing in the container.
+            The type \p Q can differ from \p value_type of items storing in the container.
             Therefore, the \p value_type should be comparable with type \p Q.
 
             The function returns \p true if \p val is found, \p false otherwise.
@@ -868,11 +801,9 @@ namespace cds { namespace container {
             \endcode
             where \p item is the item found, \p val is the <tt>find</tt> function argument.
 
-            You can pass \p f argument by value or by reference using <tt>boost::ref</tt> or cds::ref.
-
             The functor can change non-key fields of \p item.
 
-            The type \p Q can differ from \ref value_type of items storing in the container.
+            The type \p Q can differ from \p value_type of items storing in the container.
             Therefore, the \p value_type should be comparable with type \p Q.
 
             The function returns \p true if \p val is found, \p false otherwise.
@@ -908,7 +839,7 @@ namespace cds { namespace container {
             and returns \p true if it is found, and \p false otherwise.
 
             Note the hash functor specified for class \p Traits template parameter
-            should accept a parameter of type \p Q that can be not the same as \ref value_type.
+            should accept a parameter of type \p Q that can be not the same as \p value_type.
         */
         template <typename Q>
         bool find( Q const& val )