Merge branch 'check' into dev
authorkhizmax <libcds.dev@gmail.com>
Tue, 18 Nov 2014 06:47:02 +0000 (09:47 +0300)
committerkhizmax <libcds.dev@gmail.com>
Tue, 18 Nov 2014 06:47:02 +0000 (09:47 +0300)
1  2 
cds/container/impl/ellen_bintree_map.h
cds/container/impl/ellen_bintree_set.h

index 7f0b6451388ecb0e6a166f9e873d6686399fc8ec,d38de89116d81d41e5733a09323c2c248bf74dec..654b21abe27b2061c9207db67850c3a1753b50a6
@@@ -278,6 -278,7 +278,7 @@@ namespace cds { namespace container 
          template <typename K, typename Less>
          bool erase_with( K const& key, Less pred )
          {
+             CDS_UNUSED( pred );
              return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >());
          }
  
          template <typename K, typename Less, typename Func>
          bool erase_with( K const& key, Less pred, Func f )
          {
+             CDS_UNUSED( pred );
              return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(),
                  [&f]( leaf_node& node) { f( node.m_Value ); } );
          }
  
          /// Extracts an item with minimal key from the map
          /**
 -            If the map is not empty, the function returns \p true, \p result contains a pointer to minimum value.
 -            If the map is empty, the function returns \p false, \p result is left unchanged.
 +            If the map is not empty, the function returns an guarded pointer to minimum value.
 +            If the map is empty, the function returns an empty \p guarded_ptr.
  
              @note Due the concurrent nature of the map, the function extracts <i>nearly</i> minimum key.
              It means that the function gets leftmost leaf of the tree and tries to unlink it.
              During unlinking, a concurrent thread may insert an item with key less than leftmost item's key.
              So, the function returns the item with minimum key at the moment of tree traversing.
  
 -            The guarded pointer \p result prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
 -        bool extract_min( guarded_ptr& result )
 +        guarded_ptr extract_min()
          {
 -            return base_class::extract_min_( result.guard() );
 +            guarded_ptr gp;
 +            base_class::extract_min_( gp.guard() );
 +            return gp;
          }
  
          /// Extracts an item with maximal key from the map
          /**
 -            If the map is not empty, the function returns \p true, \p result contains a pointer to maximal value.
 -            If the map is empty, the function returns \p false, \p result is left unchanged.
 +            If the map is not empty, the function returns a guarded pointer to maximal value.
 +            If the map is empty, the function returns an empty \p guarded_ptr.
  
              @note Due the concurrent nature of the map, the function extracts <i>nearly</i> maximal key.
              It means that the function gets rightmost leaf of the tree and tries to unlink it.
              During unlinking, a concurrent thread may insert an item with key great than leftmost item's key.
              So, the function returns the item with maximum key at the moment of tree traversing.
  
 -            The guarded pointer \p result prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
 -        bool extract_max( guarded_ptr& result )
 +        guarded_ptr extract_max()
          {
 -            return base_class::extract_max_( result.guard() );
 +            guarded_ptr gp;
 +            base_class::extract_max_( gp.guard() );
 +            return gp;
          }
  
          /// Extracts an item from the tree
          /** \anchor cds_nonintrusive_EllenBinTreeMap_extract
              The function searches an item with key equal to \p key in the tree,
 -            unlinks it, and returns pointer to an item found in \p result parameter.
 -            If the item  is not found the function returns \p false.
 +            unlinks it, and returns a guarded pointer to an item found.
 +            If the item  is not found the function returns an empty \p guarded_ptr.
  
 -            The guarded pointer \p result prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
          template <typename Q>
 -        bool extract( guarded_ptr& result, Q const& key )
 +        guarded_ptr extract( Q const& key )
          {
 -            return base_class::extract_( result.guard(), key );
 +            guarded_ptr gp;
 +            base_class::extract_( gp.guard(), key );
 +            return gp;
          }
  
          /// Extracts an item from the map using \p pred for searching
          /**
 -            The function is an analog of \ref cds_nonintrusive_EllenBinTreeMap_extract "extract(guarded_ptr&, Q const&)"
 +            The function is an analog of \ref cds_nonintrusive_EllenBinTreeMap_extract "extract(Q const&)"
              but \p pred is used for key compare.
              \p Less has the interface like \p std::less.
              \p pred must imply the same element order as the comparator used for building the map.
          */
          template <typename Q, typename Less>
 -        bool extract_with( guarded_ptr& result, Q const& key, Less pred )
 +        guarded_ptr extract_with( Q const& key, Less pred )
          {
 -            return base_class::extract_with_( result.guard(), key,
+             CDS_UNUSED( pred );
 +            guarded_ptr gp;
 +            base_class::extract_with_( gp.guard(), key,
                  cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >());
 +            return gp;
          }
  
          /// Find the key \p key
          template <typename K, typename Less, typename Func>
          bool find_with( K const& key, Less pred, Func f )
          {
+             CDS_UNUSED( pred );
              return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >(),
                  [&f](leaf_node& item, K const& ) { f( item.m_Value );});
          }
          template <typename K, typename Less>
          bool find_with( K const& key, Less pred )
          {
+             CDS_UNUSED( pred );
              return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
          }
  
          /// Finds \p key and returns the item found
          /** @anchor cds_nonintrusive_EllenBinTreeMap_get
 -            The function searches the item with key equal to \p key and returns the item found in \p result parameter.
 -            The function returns \p true if \p key is found, \p false otherwise.
 +            The function searches the item with key equal to \p key and returns the item found as a guarded pointer.
 +            If \p key is not foudn the function returns an empty \p guarded_ptr.
  
 -            The guarded pointer \p result prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
          template <typename Q>
 -        bool get( guarded_ptr& result, Q const& key )
 +        guarded_ptr get( Q const& key )
          {
 -            return base_class::get_( result.guard(), key );
 +            guarded_ptr gp;
 +            base_class::get_( gp.guard(), key );
 +            return gp;
          }
  
          /// Finds \p key with predicate \p pred and returns the item found
          /**
 -            The function is an analog of \ref cds_nonintrusive_EllenBinTreeMap_get "get(guarded_ptr&, Q const&)"
 +            The function is an analog of \ref cds_nonintrusive_EllenBinTreeMap_get "get(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 map.
          */
          template <typename Q, typename Less>
 -        bool get_with( guarded_ptr& result, Q const& key, Less pred )
 +        guarded_ptr get_with( Q const& key, Less pred )
          {
 -            return base_class::get_with_( result.guard(), key,
+             CDS_UNUSED( pred );
 +            guarded_ptr gp;
 +            base_class::get_with_( gp.guard(), key,
                  cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
 +            return gp;
          }
  
          /// Clears the map (not atomic)
index 72c5f4ecd3e8bc29e7b922e91fb4bbe1286c9732,6c8290c83051140cd5d6c52ef5eb60bd0aad6ef4..410a70d2098a4f4812954fb493cf3290631e9310
@@@ -287,6 -287,7 +287,7 @@@ namespace cds { namespace container 
          template <typename Q, typename Less>
          bool erase_with( Q const& key, Less pred )
          {
+             CDS_UNUSED( pred );
              return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
          }
  
          template <typename Q, typename Less, typename Func>
          bool erase_with( Q const& key, Less pred, Func f )
          {
+             CDS_UNUSED( pred );
              return base_class::erase_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
                  [&f]( leaf_node const& node) { f( node.m_Value ); } );
          }
  
          /// Extracts an item with minimal key from the set
          /**
 -            If the set is not empty, the function returns \p true, \p result contains a pointer to minimum value.
 -            If the set is empty, the function returns \p false, \p result is left unchanged.
 +            If the set is not empty, the function returns a guarded pointer to minimum value.
 +            If the set is empty, the function returns an empty \p guarded_ptr.
  
              @note Due the concurrent nature of the set, the function extracts <i>nearly</i> minimum key.
              It means that the function gets leftmost leaf of the tree and tries to unlink it.
              During unlinking, a concurrent thread may insert an item with key less than leftmost item's key.
              So, the function returns the item with minimum key at the moment of tree traversing.
  
 -            The guarded pointer \p dest prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
 -        bool extract_min( guarded_ptr& result )
 +        guarded_ptr extract_min()
          {
 -            return base_class::extract_min_( result.guard() );
 +            guarded_ptr gp;
 +            base_class::extract_min_( gp.guard() );
 +            return gp;
          }
  
          /// Extracts an item with maximal key from the set
          /**
 -            If the set is not empty, the function returns \p true, \p result contains a pointer to maximal value.
 -            If the set is empty, the function returns \p false, \p result is left unchanged.
 +            If the set is not empty, the function returns a guarded pointer to maximal value.
 +            If the set is empty, the function returns an empty \p guarded_ptr.
  
              @note Due the concurrent nature of the set, the function extracts <i>nearly</i> maximal key.
              It means that the function gets rightmost leaf of the tree and tries to unlink it.
              During unlinking, a concurrent thread may insert an item with key great than leftmost item's key.
              So, the function returns the item with maximum key at the moment of tree traversing.
  
 -            The guarded pointer \p dest prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
 -        bool extract_max( guarded_ptr& result )
 +        guarded_ptr extract_max()
          {
 -            return base_class::extract_max_( result.guard() );
 +            guarded_ptr gp;
 +            base_class::extract_max_( gp.guard() );
 +            return gp;
          }
  
          /// Extracts an item from the tree
          /** \anchor cds_nonintrusive_EllenBinTreeSet_extract
              The function searches an item with key equal to \p key in the tree,
 -            unlinks it, and returns pointer to an item found in \p result parameter.
 -            If the item  is not found the function returns \p false.
 +            unlinks it, and returns an guarded pointer to it.
 +            If the item  is not found the function returns an empty \p guarded_ptr.
  
 -            The guarded pointer \p dest prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
          template <typename Q>
 -        bool extract( guarded_ptr& result, Q const& key )
 +        guarded_ptr extract( Q const& key )
          {
 -            return base_class::extract_( result.guard(), key );
 +            guarded_ptr gp;
 +            base_class::extract_( gp.guard(), key );
 +            return gp;
          }
  
          /// Extracts an item from the set using \p pred for searching
          /**
 -            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_extract "extract(guarded_ptr& dest, Q const&)"
 +            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_extract "extract(Q const&)"
              but \p pred is used for key compare.
              \p Less has the interface like \p std::less.
              \p pred must imply the same element order as the comparator used for building the set.
          */
          template <typename Q, typename Less>
 -        bool extract_with( guarded_ptr& result, Q const& key, Less pred )
 +        guarded_ptr extract_with( Q const& key, Less pred )
          {
 -            return base_class::extract_with_( result.guard(), key,
+             CDS_UNUSED( pred );
 +            guarded_ptr gp;
 +            base_class::extract_with_( gp.guard(), key,
                  cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
 +            return gp;
          }
  
          /// Find the key \p key
          template <typename Q, typename Less, typename Func>
          bool find_with( Q& key, Less pred, Func f )
          {
+             CDS_UNUSED( pred );
              return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
                  [&f]( leaf_node& node, Q& v ) { f( node.m_Value, v ); } );
          }
          template <typename Q, typename Less, typename Func>
          bool find_with( Q const& key, Less pred, Func f )
          {
+             CDS_UNUSED( pred );
              return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >(),
                                            [&f]( leaf_node& node, Q const& v ) { f( node.m_Value, v ); } );
          }
          template <typename Q, typename Less>
          bool find_with( Q const& key, Less pred )
          {
+             CDS_UNUSED( pred );
              return base_class::find_with( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
          }
  
          /// Finds \p key and returns the item found
          /** @anchor cds_nonintrusive_EllenBinTreeSet_get
 -            The function searches the item with key equal to \p key and returns the item found in \p result parameter.
 +            The function searches the item with key equal to \p key and returns the item found as an guarded pointer.
              The function returns \p true if \p key is found, \p false otherwise.
  
 -            The guarded pointer \p dest prevents deallocation of returned item,
 -            see cds::gc::guarded_ptr for explanation.
 +            The guarded pointer prevents deallocation of returned item,
 +            see \p cds::gc::guarded_ptr for explanation.
              @note Each \p guarded_ptr object uses the GC's guard that can be limited resource.
          */
          template <typename Q>
 -        bool get( guarded_ptr& result, Q const& key )
 +        guarded_ptr get( Q const& key )
          {
 -            return base_class::get_( result.guard(), key );
 +            guarded_ptr gp;
 +            base_class::get_( gp.guard(), key );
 +            return gp;
          }
  
          /// Finds \p key with predicate \p pred and returns the item found
          /**
 -            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_get "get(guarded_ptr&, Q const&)"
 +            The function is an analog of \ref cds_nonintrusive_EllenBinTreeSet_get "get(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 set.
          */
          template <typename Q, typename Less>
 -        bool get_with( guarded_ptr& result, Q const& key, Less pred )
 +        guarded_ptr get_with( Q const& key, Less pred )
          {
 -            CDS_UNUSED( pred );
 -            return base_class::get_with_( result.guard(), key,
++            CDS_UNUSED(pred);
 +            guarded_ptr gp;
 +            base_class::get_with_( gp.guard(), key,
                  cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() );
 +            return gp;
          }
  
          /// Clears the set (not atomic)