projects
/
libcds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed -Wshadow warnings
[libcds.git]
/
cds
/
container
/
michael_map_nogc.h
diff --git
a/cds/container/michael_map_nogc.h
b/cds/container/michael_map_nogc.h
index 049307ff0af57888e47f3b724c6aa1d188d9868f..610eef33901a96f15683d7c8f86f2db061c543fa 100644
(file)
--- a/
cds/container/michael_map_nogc.h
+++ b/
cds/container/michael_map_nogc.h
@@
-1,11
+1,11
@@
/*
This file is a part of libcds - Concurrent Data Structures library
/*
This file is a part of libcds - Concurrent Data Structures library
- (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-201
6
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-201
7
Source code repo: http://github.com/khizmax/libcds/
Download: http://sourceforge.net/projects/libcds/files/
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:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@
-79,10
+79,6
@@
namespace cds { namespace container {
// GC and OrderedList::gc must be the same
static_assert(std::is_same<gc, typename ordered_list::gc>::value, "GC and OrderedList::gc must be the same");
// GC and OrderedList::gc must be the same
static_assert(std::is_same<gc, typename ordered_list::gc>::value, "GC and OrderedList::gc must be the same");
- // atomicity::empty_item_counter is not allowed as a item counter
- static_assert(!std::is_same<item_counter, atomicity::empty_item_counter>::value,
- "cds::atomicity::empty_item_counter is not allowed as a item counter");
-
protected:
//@cond
typedef typename ordered_list::template select_stat_wrapper< typename ordered_list::stat > bucket_stat;
protected:
//@cond
typedef typename ordered_list::template select_stat_wrapper< typename ordered_list::stat > bucket_stat;
@@
-107,10
+103,10
@@
namespace cds { namespace container {
protected:
//@cond
const size_t m_nHashBitmask;
protected:
//@cond
const size_t m_nHashBitmask;
- item_counter m_ItemCounter; ///< Item counter
- hash m_HashFunctor; ///< Hash functor
+ hash m_HashFunctor; ///< Hash functor
internal_bucket_type* m_Buckets; ///< bucket table
internal_bucket_type* m_Buckets; ///< bucket table
- stat m_Stat; ///< Internal statistics
+ item_counter m_ItemCounter; ///< Item counter
+ stat m_Stat; ///< Internal statistics
//@endcond
protected:
//@endcond
protected:
@@
-249,7
+245,7
@@
namespace cds { namespace container {
*/
iterator begin()
{
*/
iterator begin()
{
- return iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count()
);
+ return iterator( m_Buckets[0].begin(), m_Buckets, m_Buckets + bucket_count());
}
/// Returns an iterator that addresses the location succeeding the last element in a set
}
/// Returns an iterator that addresses the location succeeding the last element in a set
@@
-260,7
+256,7
@@
namespace cds { namespace container {
*/
iterator end()
{
*/
iterator end()
{
- return iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count()
);
+ return iterator( m_Buckets[bucket_count() - 1].end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count());
}
/// Returns a forward const iterator addressing the first element in a set
}
/// Returns a forward const iterator addressing the first element in a set
@@
-315,7
+311,7
@@
namespace cds { namespace container {
clear();
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
it->~internal_bucket_type();
clear();
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
it->~internal_bucket_type();
- bucket_table_allocator().deallocate( m_Buckets, bucket_count()
);
+ bucket_table_allocator().deallocate( m_Buckets, bucket_count());
}
/// Inserts new node with key and default value
}
/// Inserts new node with key and default value
@@
-335,9
+331,9
@@
namespace cds { namespace container {
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert( key );
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert( key );
- if ( it != refBucket.end()
) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count()
);
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
}
return end();
@@
-360,9
+356,9
@@
namespace cds { namespace container {
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert( key, val );
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert( key, val );
- if ( it != refBucket.end()
) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count()
);
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
}
return end();
@@
-404,9
+400,9
@@
namespace cds { namespace container {
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert_with( key, func );
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert_with( key, func );
- if ( it != refBucket.end()
) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count()
);
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
}
return end();
@@
-424,9
+420,9
@@
namespace cds { namespace container {
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.emplace( std::forward<K>(key), std::forward<Args>(args)... );
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.emplace( std::forward<K>(key), std::forward<Args>(args)... );
- if ( it != refBucket.end()
) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count()
);
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
}
return end();
@@
-455,9
+451,9
@@
namespace cds { namespace container {
if ( ret.second )
++m_ItemCounter;
if ( ret.second )
++m_ItemCounter;
- else if ( ret.first == refBucket.end()
)
+ else if ( ret.first == refBucket.end())
return std::make_pair( end(), false );
return std::make_pair( end(), false );
- return std::make_pair( iterator( ret.first, &refBucket, m_Buckets + bucket_count()
), ret.second );
+ return std::make_pair( iterator( ret.first, &refBucket, m_Buckets + bucket_count()), ret.second );
}
//@cond
template <typename K>
}
//@cond
template <typename K>
@@
-479,8
+475,8
@@
namespace cds { namespace container {
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.contains( key );
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.contains( key );
- if ( it != refBucket.end()
)
- return iterator( it, &refBucket, m_Buckets + bucket_count()
);
+ if ( it != refBucket.end())
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
return end();
}
return end();
}
@@
-506,8
+502,8
@@
namespace cds { namespace container {
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.contains( key, pred );
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.contains( key, pred );
- if ( it != refBucket.end()
)
- return iterator( it, &refBucket, m_Buckets + bucket_count()
);
+ if ( it != refBucket.end())
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
return end();
}
return end();
}
@@
-530,8
+526,8
@@
namespace cds { namespace container {
/// Checks whether the map is empty
/**
/// Checks whether the map is empty
/**
- Emptiness is checked by item counting: if item count is zero then the map is empty.
-
Thus, the correct item counting feature is an important part of Michael's map implementation
.
+ @warning If you use \p atomicity::empty_item_counter in \p traits::item_counter,
+
the function always returns \p true
.
*/
bool empty() const
{
*/
bool empty() const
{
@@
-539,6
+535,10
@@
namespace cds { namespace container {
}
/// Returns item count in the map
}
/// Returns item count in the map
+ /**
+ If you use \p atomicity::empty_item_counter in \p traits::item_counter,
+ the function always returns 0.
+ */
size_t size() const
{
return m_ItemCounter;
size_t size() const
{
return m_ItemCounter;
@@
-582,23
+582,23
@@
namespace cds { namespace container {
//@cond
const_iterator get_const_begin() const
{
//@cond
const_iterator get_const_begin() const
{
- return const_iterator( const_cast<internal_bucket_type const&>(m_Buckets[0]).begin(), m_Buckets, m_Buckets + bucket_count()
);
+ return const_iterator( const_cast<internal_bucket_type const&>(m_Buckets[0]).begin(), m_Buckets, m_Buckets + bucket_count());
}
const_iterator get_const_end() const
{
}
const_iterator get_const_end() const
{
- return const_iterator( const_cast<internal_bucket_type const&>(m_Buckets[bucket_count() - 1]).end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count()
);
+ return const_iterator( const_cast<internal_bucket_type const&>(m_Buckets[bucket_count() - 1]).end(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count());
}
template <typename Stat>
}
template <typename Stat>
- typename std::enable_if< Stat::empty >::type construct_bucket( internal_bucket_type* b
ucket
)
+ typename std::enable_if< Stat::empty >::type construct_bucket( internal_bucket_type* b )
{
{
- new (b
ucket
) internal_bucket_type;
+ new (b) internal_bucket_type;
}
template <typename Stat>
}
template <typename Stat>
- typename std::enable_if< !Stat::empty >::type construct_bucket( internal_bucket_type* b
ucket
)
+ typename std::enable_if< !Stat::empty >::type construct_bucket( internal_bucket_type* b )
{
{
- new (b
ucket
) internal_bucket_type( m_Stat );
+ new (b) internal_bucket_type( m_Stat );
}
//@endcond
};
}
//@endcond
};