Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CDSLIB_INTRUSIVE_IMPL_FELDMAN_HASHSET_H
// slot value has been changed - retry
stats().onSlotChanged();
}
-
- if ( slot.ptr()) {
+ else if ( slot.ptr()) {
if ( cmp( hash, hash_accessor()( *slot.ptr())) == 0 ) {
// the item with that hash value already exists
stats().onInsertFailed();
- If hash value is not found and \p bInsert is \p false then the set is unchanged,
the function returns <tt> std::pair<false, false> </tt>
- Returns <tt> std::pair<bool, bool> </tt> where \p first is \p true if operation is successfull
+ Returns <tt> std::pair<bool, bool> </tt> where \p first is \p true if operation is successful
(i.e. the item has been inserted or updated),
\p second is \p true if new item has been added or \p false if the set contains that hash.
*/
*/
guarded_ptr extract( hash_type const& hash )
{
- guarded_ptr gp;
- {
- typename gc::Guard guard;
- value_type * p = do_erase( hash, guard, []( value_type const&) -> bool {return true;} );
-
- // p is guarded by HP
- if ( p )
- gp.reset( p );
- }
- return gp;
+ typename gc::Guard guard;
+ if ( do_erase( hash, guard, []( value_type const&) -> bool {return true;} ))
+ return guarded_ptr( std::move( guard ));
+ return guarded_ptr();
}
/// Finds an item by it's \p hash
*/
guarded_ptr get( hash_type const& hash )
{
- guarded_ptr gp;
- {
- typename gc::Guard guard;
- gp.reset( search( hash, guard ));
- }
- return gp;
+ typename gc::Guard guard;
+ if ( search( hash, guard ))
+ return guarded_ptr( std::move( guard ));
+ return guarded_ptr();
}
/// Clears the set (non-atomic)
using base_class::array_node_size;
/// Collects tree level statistics into \p stat
- /**
+ /**
The function traverses the set and collects statistics for each level of the tree
into \p feldman_hashset::level_statistics struct. The element of \p stat[i]
represents statistics for level \p i, level 0 is head array.