{}
template <typename Predicate>
- bool operator()(Predicate pr) const CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()() ))
+ bool operator()(Predicate pr) const CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()()))
{
return pr();
}
}
template <typename Predicate>
- bool operator()(Predicate pr) const CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()() ))
+ bool operator()(Predicate pr) const CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()()))
{
- if ( pr() )
+ if ( pr())
return true;
operator()();
return false;
}
template <typename Predicate>
- bool operator()(Predicate pr) const CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()() ))
+ bool operator()(Predicate pr) const CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()()))
{
- if ( pr() )
+ if ( pr())
return true;
operator()();
return false;
}
template <typename Predicate>
- bool operator()(Predicate pr) const CDS_NOEXCEPT_(noexcept(std::declval<Predicate>()() ))
+ bool operator()(Predicate pr) const CDS_NOEXCEPT_(noexcept(std::declval<Predicate>()()))
{
- if ( pr() )
+ if ( pr())
return true;
operator()();
return false;
}
template <typename Predicate>
- bool operator()( Predicate pr ) CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()()) && noexcept(std::declval<spin_backoff>()()) && noexcept(std::declval<yield_backoff>()() ))
+ bool operator()( Predicate pr ) CDS_NOEXCEPT_( noexcept(std::declval<Predicate>()()) && noexcept(std::declval<spin_backoff>()()) && noexcept(std::declval<yield_backoff>()()))
{
if ( m_nExpCur <= m_nExpMax ) {
for ( size_t n = 0; n < m_nExpCur; ++n ) {
- if ( m_bkSpin(pr) )
+ if ( m_bkSpin(pr))
return true;
}
m_nExpCur *= 2;
return false;
}
- void reset() CDS_NOEXCEPT_( noexcept( std::declval<spin_backoff>().reset() ) && noexcept( std::declval<yield_backoff>().reset() ))
+ void reset() CDS_NOEXCEPT_( noexcept( std::declval<spin_backoff>().reset()) && noexcept( std::declval<yield_backoff>().reset()))
{
m_nExpCur = m_nExpMin;
m_bkSpin.reset();
bool operator()(Predicate pr) const
{
for ( unsigned int i = 0; i < m_nTimeout; i += 2 ) {
- if ( pr() )
+ if ( pr())
return true;
std::this_thread::sleep_for( duration_type( 2 ));
}
/// Marks publication record for the current thread as empty
void release_record( publication_record_type * pRec )
{
- assert( pRec->is_done() );
+ assert( pRec->is_done());
pRec->nRequest.store( req_EmptyRecord, memory_model::memory_order_release );
}
/// Marks \p rec as executed
/**
This function should be called by container if \p batch_combine mode is used.
- For usual combining (see \p combine() ) this function is excess.
+ For usual combining (see \p combine()) this function is excess.
*/
void operation_done( publication_record& rec )
{
pRec->nState.store( active, memory_model::memory_order_release );
// Insert record to publication list
- if ( m_pHead != static_cast<publication_record *>(pRec) ) {
+ if ( m_pHead != static_cast<publication_record *>(pRec)) {
publication_record * p = m_pHead->pNext.load(memory_model::memory_order_relaxed);
if ( p != static_cast<publication_record *>( pRec )) {
do {
template <class Container>
void try_combining( Container& owner, publication_record_type* pRec )
{
- if ( m_Mutex.try_lock() ) {
+ if ( m_Mutex.try_lock()) {
// The thread becomes a combiner
- lock_guard l( m_Mutex, std::adopt_lock_t() );
+ lock_guard l( m_Mutex, std::adopt_lock_t());
// The record pRec can be excluded from publication list. Re-publish it
republish( pRec );
}
else {
// There is another combiner, wait while it executes our request
- if ( !wait_for_combining( pRec ) ) {
+ if ( !wait_for_combining( pRec )) {
// The thread becomes a combiner
- lock_guard l( m_Mutex, std::adopt_lock_t() );
+ lock_guard l( m_Mutex, std::adopt_lock_t());
// The record pRec can be excluded from publication list. Re-publish it
republish( pRec );
template <class Container>
void try_batch_combining( Container& owner, publication_record_type * pRec )
{
- if ( m_Mutex.try_lock() ) {
+ if ( m_Mutex.try_lock()) {
// The thread becomes a combiner
- lock_guard l( m_Mutex, std::adopt_lock_t() );
+ lock_guard l( m_Mutex, std::adopt_lock_t());
// The record pRec can be excluded from publication list. Re-publish it
republish( pRec );
}
else {
// There is another combiner, wait while it executes our request
- if ( !wait_for_combining( pRec ) ) {
+ if ( !wait_for_combining( pRec )) {
// The thread becomes a combiner
- lock_guard l( m_Mutex, std::adopt_lock_t() );
+ lock_guard l( m_Mutex, std::adopt_lock_t());
// The record pRec can be excluded from publication list. Re-publish it
republish( pRec );
void combining( Container& owner )
{
// The thread is a combiner
- assert( !m_Mutex.try_lock() );
+ assert( !m_Mutex.try_lock());
unsigned int const nCurAge = m_nCount.fetch_add( 1, memory_model::memory_order_relaxed ) + 1;
case active:
if ( p->op() >= req_Operation ) {
p->nAge.store( nCurAge, memory_model::memory_order_release );
- owner.fc_apply( static_cast<publication_record_type*>(p) );
+ owner.fc_apply( static_cast<publication_record_type*>(p));
operation_done( *p );
bOpDone = true;
}
void batch_combining( Container& owner )
{
// The thread is a combiner
- assert( !m_Mutex.try_lock() );
+ assert( !m_Mutex.try_lock());
unsigned int const nCurAge = m_nCount.fetch_add( 1, memory_model::memory_order_relaxed ) + 1;
for ( unsigned int nPass = 0; nPass < m_nCombinePassCount; ++nPass )
- owner.fc_process( begin(), end() );
+ owner.fc_process( begin(), end());
combining_pass( owner, nCurAge );
m_Stat.onCombining();
if ( m_waitStrategy.wait( *this, *pRec ))
m_Stat.onWakeupByNotifying();
- if ( m_Mutex.try_lock() ) {
+ if ( m_Mutex.try_lock()) {
if ( pRec->op( memory_model::memory_order_acquire ) == req_Response ) {
// Operation is done
m_Mutex.unlock();
*/
uint_type cut( size_t nBits )
{
- assert( !eos() );
+ assert( !eos());
assert( nBits <= c_nBitPerInt );
assert( m_offset + nBits <= c_nBitPerHash );
# ifdef _DEBUG
*/
uint_type safe_cut( size_t nBits )
{
- if ( eos() )
+ if ( eos())
return 0;
assert( nBits <= sizeof(uint_type) * c_nBitPerByte );
x |= x >> 16;
uint64_t nRes;
- asm __volatile__( "popcnt %0=%1\n\t" : "=r" (nRes) : "r" (x) );
+ asm __volatile__( "popcnt %0=%1\n\t" : "=r" (nRes) : "r" (x));
return (int) nRes;
}
// Alignment macro
#if CDS_OS_INTERFACE == CDS_OSI_WINDOWS
-# define CDS_TYPE_ALIGNMENT(n) __declspec( align(n) )
-# define CDS_DATA_ALIGNMENT(n) __declspec( align(n) )
-# define CDS_CLASS_ALIGNMENT(n) __declspec( align(n) )
+# define CDS_TYPE_ALIGNMENT(n) __declspec( align(n))
+# define CDS_DATA_ALIGNMENT(n) __declspec( align(n))
+# define CDS_CLASS_ALIGNMENT(n) __declspec( align(n))
#else
# define CDS_TYPE_ALIGNMENT(n) __attribute__ ((aligned (n)))
# define CDS_CLASS_ALIGNMENT(n) __attribute__ ((aligned (n)))
return expected == prev;
# else
// VC 2008
- unsigned int * pnDest = (unsigned int *)( ((unsigned __int64) pDest) & ~(unsigned __int64(3)) );
+ unsigned int * pnDest = (unsigned int *)( ((unsigned __int64) pDest) & ~(unsigned __int64(3)));
unsigned int nOffset = ((unsigned __int64) pDest) & 3;
unsigned int nExpected;
unsigned int nDesired;
static inline T * exchange_ptr( T * volatile * pDest, T * v, memory_order /*order*/ ) CDS_NOEXCEPT
{
static_assert( sizeof(T *) == sizeof(void *), "Illegal size of operand" );
- return (T *) _InterlockedExchangePointer( (void * volatile *) pDest, reinterpret_cast<void *>(v) );
+ return (T *) _InterlockedExchangePointer( (void * volatile *) pDest, reinterpret_cast<void *>(v));
}
template <typename T>
// *************************************************
// Alignment macro
-#define CDS_TYPE_ALIGNMENT(n) __declspec( align(n) )
-#define CDS_DATA_ALIGNMENT(n) __declspec( align(n) )
-#define CDS_CLASS_ALIGNMENT(n) __declspec( align(n) )
+#define CDS_TYPE_ALIGNMENT(n) __declspec( align(n))
+#define CDS_DATA_ALIGNMENT(n) __declspec( align(n))
+#define CDS_CLASS_ALIGNMENT(n) __declspec( align(n))
// Attributes
#if CDS_COMPILER_VERSION >= CDS_COMPILER_MSVC14
{
static_assert( sizeof(T *) == sizeof(void *), "Illegal operand size" );
return (T *) _InterlockedExchange( (long volatile *) pDest, (uintptr_t) v );
- //return (T *) _InterlockedExchangePointer( (void * volatile *) pDest, reinterpret_cast<void *>(v) );
+ //return (T *) _InterlockedExchangePointer( (void * volatile *) pDest, reinterpret_cast<void *>(v));
}
template <typename T>
bool enqueue( value_type&& val )
{
scoped_node_ptr p( alloc_node_move( std::move( val )));
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( p->m_value );
if ( base_class::enqueue( *p )) {
p.release();
template <typename K>
node_type( K const& key )
- : m_val( std::make_pair( key_type(key), mapped_type() ))
+ : m_val( std::make_pair( key_type(key), mapped_type()))
{}
template <typename K, typename Q>
node_type( K const& key, Q const& v )
- : m_val( std::make_pair( key_type(key), mapped_type(v) ))
+ : m_val( std::make_pair( key_type(key), mapped_type(v)))
{}
template <typename K, typename... Args>
node_type( K&& key, Args&&... args )
- : m_val( std::forward<K>(key), std::move( mapped_type(std::forward<Args>(args)...)) )
+ : m_val( std::forward<K>(key), std::move( mapped_type(std::forward<Args>(args)...)))
{}
};
CuckooMap(
hash_tuple_type&& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : base_class( std::forward<hash_tuple_type>(h) )
+ : base_class( std::forward<hash_tuple_type>(h))
{}
/// Constructs a map with given probe set properties and hash functor tuple (move semantics)
, unsigned int nProbesetThreshold ///< probe set threshold, <tt>nProbesetThreshold < nProbesetSize</tt>. If 0, nProbesetThreshold = nProbesetSize - 1
, hash_tuple_type&& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : base_class( nInitialSize, nProbesetSize, nProbesetThreshold, std::forward<hash_tuple_type>(h) )
+ : base_class( nInitialSize, nProbesetSize, nProbesetThreshold, std::forward<hash_tuple_type>(h))
{}
/// Destructor clears the map
bool erase_with( K const& key, Predicate pred, Func f )
{
CDS_UNUSED( pred );
- node_type * pNode = base_class::erase_with( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>() );
+ node_type * pNode = base_class::erase_with( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>());
if ( pNode ) {
f( pNode->m_val );
free_node( pNode );
bool contains( K const& key, Predicate pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>() );
+ return base_class::contains( key, cds::details::predicate_wrapper<node_type, Predicate, key_accessor>());
}
//@cond
template <typename K, typename Predicate>
/// Clears the map
void clear()
{
- base_class::clear_and_dispose( node_disposer() );
+ base_class::clear_and_dispose( node_disposer());
}
/// Checks if the map is empty
CuckooSet(
hash_tuple_type&& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : base_class( std::forward<hash_tuple_type>(h) )
+ : base_class( std::forward<hash_tuple_type>(h))
{}
/// Constructs the set object with given probe set properties and hash functor tuple (move semantics)
, unsigned int nProbesetThreshold ///< probe set threshold, <tt>nProbesetThreshold < nProbesetSize</tt>. If 0, nProbesetThreshold = nProbesetSize - 1
, hash_tuple_type&& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : base_class( nInitialSize, nProbesetSize, nProbesetThreshold, std::forward<hash_tuple_type>(h) )
+ : base_class( nInitialSize, nProbesetSize, nProbesetThreshold, std::forward<hash_tuple_type>(h))
{}
/// Destructor clears the set
bool erase_with( Q const& key, Predicate pred )
{
CDS_UNUSED( pred );
- node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>() );
+ node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>());
if ( pNode ) {
free_node( pNode );
return true;
bool erase_with( Q const& key, Predicate pred, Func f )
{
CDS_UNUSED( pred );
- node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>() );
+ node_type * pNode = base_class::erase_with( key, typename maker::template predicate_wrapper<Predicate, bool>());
if ( pNode ) {
f( pNode->m_val );
free_node( pNode );
*/
void clear()
{
- return base_class::clear_and_dispose( node_disposer() );
+ return base_class::clear_and_dispose( node_disposer());
}
/// Checks if the set is empty
void wait_until_shrink_completed( atomics::memory_order order ) const
{
BackOff bkoff;
- while ( is_shrinking( order ) )
+ while ( is_shrinking( order ))
bkoff();
}
template <typename Q>
node( Q&& key )
: base_class()
- , m_key( std::forward<Q>( key ) )
+ , m_key( std::forward<Q>( key ))
, m_pNextRemoved( nullptr )
{}
template <typename Q>
node( Q&& key, int nHeight, version_type version, node * pParent, node * pLeft, node * pRight )
: base_class( nHeight, version, pParent, pLeft, pRight )
- , m_key( std::forward<Q>( key ) )
+ , m_key( std::forward<Q>( key ))
, m_pNextRemoved( nullptr )
{}
//@endcond
/// Initializes key field, value if default-constructed
template <typename K>
map_node( K const& key )
- : m_Value( std::make_pair( key_type(key), mapped_type() ))
+ : m_Value( std::make_pair( key_type(key), mapped_type()))
{}
/// Initializes key and value fields
template <typename K, typename Q>
map_node( K const& key, Q const& v )
- : m_Value( std::make_pair(key_type(key), mapped_type(v) ))
+ : m_Value( std::make_pair(key_type(key), mapped_type(v)))
{}
};
template <typename Q, typename... Args>
node_type( hasher /*h*/, Q&& key, Args&&... args )
- : m_Value( std::make_pair( key_type( std::forward<Q>( key )), mapped_type( std::forward<Args>(args)...) ))
+ : m_Value( std::make_pair( key_type( std::forward<Q>( key )), mapped_type( std::forward<Args>(args)...)))
{}
};
value_type m_Data;
node_type( key_type const& key )
- : m_Data( key, mapped_type() )
+ : m_Data( key, mapped_type())
{}
template <typename Q>
node_type( Q const& key )
- : m_Data( key_type( key ), mapped_type() )
+ : m_Data( key_type( key ), mapped_type())
{}
template <typename Q, typename R>
template <typename R>
node_type( key_type const& key, R const& value )
- : m_Data( key, mapped_type( value ) )
+ : m_Data( key, mapped_type( value ))
{}
template <typename Q>
template <typename Ky, typename... Args>
node_type( Ky&& key, Args&&... args )
- : m_Data( key_type( std::forward<Ky>( key )), std::move( mapped_type( std::forward<Args>( args )... ) ) )
+ : m_Data( key_type( std::forward<Ky>( key )), std::move( mapped_type( std::forward<Args>( args )... )) )
{}
};
pair_type m_Data;
node_type( key_type const& key )
- : m_Data( key, value_type() )
+ : m_Data( key, value_type())
{}
template <typename Q>
node_type( Q const& key )
- : m_Data( key_type(key), value_type() )
+ : m_Data( key_type(key), value_type())
{}
template <typename Q, typename R>
template <typename Q>
node_type( unsigned int nHeight, atomic_marked_ptr * pTower, Q const& key )
- : m_Value( std::make_pair( key, mapped_type() ))
+ : m_Value( std::make_pair( key, mapped_type()))
{
init_tower( nHeight, pTower );
}
size_t operator()(node_type const& v ) const
{
- return base_class::operator()( key_accessor()( v.m_Value ) );
+ return base_class::operator()( key_accessor()( v.m_Value ));
}
template <typename Q>
size_t operator()( Q const& k ) const
size_t operator()(node_type const& v ) const
{
- return base_class::operator()( key_accessor()( v.m_Value ) );
+ return base_class::operator()( key_accessor()( v.m_Value ));
}
template <typename Q>
size_t operator()( Q const& k ) const
static unsigned char * alloc_space( unsigned int nHeight )
{
if ( nHeight > 1 ) {
- unsigned char * pMem = tower_allocator_type().allocate( node_size(nHeight) );
+ unsigned char * pMem = tower_allocator_type().allocate( node_size(nHeight));
// check proper alignments
assert( (((uintptr_t) pMem) & (alignof(node_type) - 1)) == 0 );
{
CDS_UNUSED( pred );
return exempt_ptr( base_class::extract_with_( key,
- cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() ));
+ cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >()));
}
/// Find the key \p key
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >());
}
//@cond
template <typename K, typename Less>
bool insert( Q const& val )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
bool emplace( Args&&... args )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().MoveNew( std::forward<Args>(args)... ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
{
CDS_UNUSED( pred );
return exempt_ptr( base_class::extract_with_( key,
- cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() ));
+ cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >()));
}
/// Find the key \p key
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
else
m_FlatCombining.combine( op_push_front, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPushFront();
return true;
else
m_FlatCombining.combine( op_push_front_move, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPushFrontMove();
return true;
else
m_FlatCombining.combine( op_push_back, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPushBack();
return true;
else
m_FlatCombining.combine( op_push_back_move, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPushBackMove();
return true;
else
m_FlatCombining.combine( op_pop_front, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPopFront( pRec->bEmpty );
return !pRec->bEmpty;
else
m_FlatCombining.combine( op_pop_back, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPopBack( pRec->bEmpty );
return !pRec->bEmpty;
else
m_FlatCombining.combine( op_clear, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
}
// this function is called under FC mutex, so switch TSan off
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
- switch ( pRec->op() ) {
+ switch ( pRec->op()) {
case op_push_front:
assert( pRec->pValPush );
- m_Deque.push_front( *(pRec->pValPush) );
+ m_Deque.push_front( *(pRec->pValPush));
break;
case op_push_front_move:
assert( pRec->pValPush );
- m_Deque.push_front( std::move( *(pRec->pValPush )) );
+ m_Deque.push_front( std::move( *(pRec->pValPush )));
break;
case op_push_back:
assert( pRec->pValPush );
- m_Deque.push_back( *(pRec->pValPush) );
+ m_Deque.push_back( *(pRec->pValPush));
break;
case op_push_back_move:
assert( pRec->pValPush );
- m_Deque.push_back( std::move( *(pRec->pValPush )) );
+ m_Deque.push_back( std::move( *(pRec->pValPush )));
break;
case op_pop_front:
assert( pRec->pValPop );
}
break;
case op_clear:
- while ( !m_Deque.empty() )
+ while ( !m_Deque.empty())
m_Deque.pop_front();
break;
default:
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
for ( fc_iterator it = itBegin, itPrev = itEnd; it != itEnd; ++it ) {
- switch ( it->op() ) {
+ switch ( it->op()) {
case op_push_front:
if ( itPrev != itEnd
- && (itPrev->op() == op_pop_front || (m_Deque.empty() && itPrev->op() == op_pop_back)) )
+ && (itPrev->op() == op_pop_front || (m_Deque.empty() && itPrev->op() == op_pop_back)))
{
collide( *it, *itPrev );
itPrev = itEnd;
break;
case op_push_back:
if ( itPrev != itEnd
- && (itPrev->op() == op_pop_back || (m_Deque.empty() && itPrev->op() == op_pop_front)) )
+ && (itPrev->op() == op_pop_back || (m_Deque.empty() && itPrev->op() == op_pop_front)))
{
collide( *it, *itPrev );
itPrev = itEnd;
break;
case op_pop_front:
if ( itPrev != itEnd ) {
- if ( m_Deque.empty() ) {
- switch ( itPrev->op() ) {
+ if ( m_Deque.empty()) {
+ switch ( itPrev->op()) {
case op_push_back:
collide( *itPrev, *it );
itPrev = itEnd;
}
}
else {
- switch ( itPrev->op() ) {
+ switch ( itPrev->op()) {
case op_push_front:
collide( *itPrev, *it );
itPrev = itEnd;
break;
case op_pop_back:
if ( itPrev != itEnd ) {
- if ( m_Deque.empty() ) {
- switch ( itPrev->op() ) {
+ if ( m_Deque.empty()) {
+ switch ( itPrev->op()) {
case op_push_front:
collide( *itPrev, *it );
itPrev = itEnd;
}
}
else {
- switch ( itPrev->op() ) {
+ switch ( itPrev->op()) {
case op_push_back:
collide( *itPrev, *it );
itPrev = itEnd;
m_FlatCombining.combine( op_push, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPush();
return true;
m_FlatCombining.combine( op_push_move, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPushMove();
return true;
m_FlatCombining.combine( op_pop, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPop( pRec->bEmpty );
return !pRec->bEmpty;
m_FlatCombining.combine( op_clear, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
}
// this function is called under FC mutex, so switch TSan off
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
- switch ( pRec->op() ) {
+ switch ( pRec->op()) {
case op_push:
assert( pRec->pValPush );
- m_PQueue.push( *(pRec->pValPush) );
+ m_PQueue.push( *(pRec->pValPush));
break;
case op_push_move:
assert( pRec->pValPush );
- m_PQueue.push( std::move( *(pRec->pValPush )) );
+ m_PQueue.push( std::move( *(pRec->pValPush )));
break;
case op_pop:
assert( pRec->pValPop );
}
break;
case op_clear:
- while ( !m_PQueue.empty() )
+ while ( !m_PQueue.empty())
m_PQueue.pop();
break;
default:
else
m_FlatCombining.combine( op_enq, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onEnqueue();
return true;
else
m_FlatCombining.combine( op_enq_move, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onEnqMove();
else
m_FlatCombining.combine( op_deq, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onDequeue( pRec->bEmpty );
else
m_FlatCombining.combine( op_clear, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
}
// this function is called under FC mutex, so switch TSan off
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
- switch ( pRec->op() ) {
+ switch ( pRec->op()) {
case op_enq:
assert( pRec->pValEnq );
- m_Queue.push( *(pRec->pValEnq ) );
+ m_Queue.push( *(pRec->pValEnq ));
break;
case op_enq_move:
assert( pRec->pValEnq );
- m_Queue.push( std::move( *(pRec->pValEnq )) );
+ m_Queue.push( std::move( *(pRec->pValEnq )));
break;
case op_deq:
assert( pRec->pValDeq );
}
break;
case op_clear:
- while ( !m_Queue.empty() )
+ while ( !m_Queue.empty())
m_Queue.pop();
break;
default:
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
for ( fc_iterator it = itBegin, itPrev = itEnd; it != itEnd; ++it ) {
- switch ( it->op() ) {
+ switch ( it->op()) {
case op_enq:
case op_enq_move:
case op_deq:
- if ( m_Queue.empty() ) {
+ if ( m_Queue.empty()) {
if ( itPrev != itEnd && collide( *itPrev, *it ))
itPrev = itEnd;
else
//@cond
bool collide( fc_record& rec1, fc_record& rec2 )
{
- switch ( rec1.op() ) {
+ switch ( rec1.op()) {
case op_enq:
if ( rec2.op() == op_deq ) {
assert(rec1.pValEnq);
}
break;
case op_deq:
- switch ( rec2.op() ) {
+ switch ( rec2.op()) {
case op_enq:
case op_enq_move:
return collide( rec2, rec1 );
else
m_FlatCombining.combine( op_push, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPush();
return true;
else
m_FlatCombining.combine( op_push_move, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPushMove();
else
m_FlatCombining.combine( op_pop, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPop( pRec->bEmpty );
else
m_FlatCombining.combine( op_clear, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
}
else
m_FlatCombining.combine( op_empty, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
return pRec->bEmpty;
}
// this function is called under FC mutex, so switch TSan off
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
- switch ( pRec->op() ) {
+ switch ( pRec->op()) {
case op_push:
assert( pRec->pValPush );
- m_Stack.push( *(pRec->pValPush ) );
+ m_Stack.push( *(pRec->pValPush ));
break;
case op_push_move:
assert( pRec->pValPush );
- m_Stack.push( std::move( *(pRec->pValPush )) );
+ m_Stack.push( std::move( *(pRec->pValPush )));
break;
case op_pop:
assert( pRec->pValPop );
}
break;
case op_clear:
- while ( !m_Stack.empty() )
+ while ( !m_Stack.empty())
m_Stack.pop();
break;
case op_empty:
typedef typename fc_kernel::iterator fc_iterator;
for ( fc_iterator it = itBegin, itPrev = itEnd; it != itEnd; ++it ) {
- switch ( it->op() ) {
+ switch ( it->op()) {
case op_push:
case op_push_move:
case op_pop:
//@cond
bool collide( fc_record& rec1, fc_record& rec2 )
{
- switch ( rec1.op() ) {
+ switch ( rec1.op()) {
case op_push:
if ( rec2.op() == op_pop ) {
assert(rec1.pValPush);
}
break;
case op_pop:
- switch ( rec2.op() ) {
+ switch ( rec2.op()) {
case op_push:
case op_push_move:
return collide( rec2, rec1 );
template <typename K>
bool insert( K&& key )
{
- scoped_node_ptr sp( cxx_node_allocator().MoveNew( m_Hasher, std::forward<K>(key) ));
+ scoped_node_ptr sp( cxx_node_allocator().MoveNew( m_Hasher, std::forward<K>(key)));
if ( base_class::insert( *sp )) {
sp.release();
return true;
template <typename K>
bool contains( K const& key )
{
- return base_class::contains( m_Hasher( key_type( key )) );
+ return base_class::contains( m_Hasher( key_type( key )));
}
/// Find the key \p key
void clean()
{
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
// TODO: use RCU::batch_retire
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
*/
void clear()
{
- while ( extract_min() );
+ while ( extract_min());
}
/// Clears the tree (not thread safe)
template <typename Q, typename Compare, typename Func>
find_result try_find( Q const& key, Compare cmp, Func f, node_type * pNode, int nDir, version_type nVersion ) const
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
assert( pNode );
struct stack_record
int nCmp = cmp( key, pChild->m_key );
if ( nCmp == 0 ) {
- if ( pChild->is_valued( memory_model::memory_order_acquire ) ) {
+ if ( pChild->is_valued( memory_model::memory_order_acquire )) {
// key found
node_scoped_lock l( m_Monitor, *pChild );
if ( child(pNode, nDir, memory_model::memory_order_acquire) == pChild ) {
if ( pChild->is_valued( memory_model::memory_order_relaxed )) {
- if ( f( pChild ) ) {
+ if ( f( pChild )) {
m_stat.onFindSuccess();
return find_result::found;
}
template <typename K, typename Compare, typename Func>
int try_update_root( K const& key, Compare cmp, int nFlags, Func funcUpdate, rcu_disposer& disp )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
while ( true ) {
int result;
template <typename K, typename Compare, typename Func>
bool try_remove_root( K const& key, Compare cmp, Func func, rcu_disposer& disp )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
while ( true ) {
int result;
template <typename K, typename Compare, typename Func>
int try_update( K const& key, Compare cmp, int nFlags, Func funcUpdate, node_type * pNode, version_type nVersion, rcu_disposer& disp )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
assert( nVersion != node_type::unlinked );
struct stack_record
template <typename K, typename Compare, typename Func>
int try_remove( K const& key, Compare cmp, Func func, node_type * pParent, node_type * pNode, version_type nVersion, rcu_disposer& disp )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
assert( nVersion != node_type::unlinked );
struct stack_record
template <typename Func>
int try_extract_minmax( int nDir, Func func, node_type * pParent, node_type * pNode, version_type nVersion, rcu_disposer& disp )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
assert( nVersion != node_type::unlinked );
struct stack_record
return update_flags::retry;
}
- if ( pNode->is_valued( memory_model::memory_order_relaxed ) && !(nFlags & update_flags::allow_update) ) {
+ if ( pNode->is_valued( memory_model::memory_order_relaxed ) && !(nFlags & update_flags::allow_update)) {
m_stat.onInsertFailed();
return update_flags::failed;
}
assert( pParent != nullptr );
assert( pNode != nullptr );
- if ( !pNode->is_valued( memory_model::memory_order_acquire ) )
+ if ( !pNode->is_valued( memory_model::memory_order_acquire ))
return update_flags::failed;
if ( child( pNode, left_child, memory_model::memory_order_acquire ) == nullptr
bool try_unlink_locked( node_type * pParent, node_type * pNode, rcu_disposer& disp )
{
// pParent and pNode must be locked
- assert( !pParent->is_unlinked(memory_model::memory_order_relaxed) );
+ assert( !pParent->is_unlinked(memory_model::memory_order_relaxed));
node_type * pParentLeft = child( pParent, left_child, memory_model::memory_order_relaxed );
node_type * pParentRight = child( pParent, right_child, memory_model::memory_order_relaxed );
{
while ( pNode && parent( pNode, memory_model::memory_order_acquire )) {
int nCond = estimate_node_condition( pNode );
- if ( nCond == nothing_required || pNode->is_unlinked( memory_model::memory_order_acquire ) )
+ if ( nCond == nothing_required || pNode->is_unlinked( memory_model::memory_order_acquire ))
return;
if ( nCond != unlink_required && nCond != rebalance_required )
}
// pLeft might also have routing node damage (if pLeft.left was null)
- if ( hLL == 0 && !pLeft->is_valued(memory_model::memory_order_acquire) ) {
+ if ( hLL == 0 && !pLeft->is_valued(memory_model::memory_order_acquire)) {
m_stat.onDamageAfterRightRotation();
return pLeft;
}
return pNode;
}
- if ( (pRLeft == nullptr || hL == 0) && !pNode->is_valued(memory_model::memory_order_relaxed) ) {
+ if ( (pRLeft == nullptr || hL == 0) && !pNode->is_valued(memory_model::memory_order_relaxed)) {
m_stat.onRemoveAfterLeftRotation();
return pNode;
}
return pRight;
}
- if ( hRR == 0 && !pRight->is_valued(memory_model::memory_order_acquire) ) {
+ if ( hRR == 0 && !pRight->is_valued(memory_model::memory_order_acquire)) {
m_stat.onDamageAfterLeftRotation();
return pRight;
}
return pNode;
}
- if ( (pRLL == nullptr || hL == 0) && !pNode->is_valued(memory_model::memory_order_relaxed) ) {
+ if ( (pRLL == nullptr || hL == 0) && !pNode->is_valued(memory_model::memory_order_relaxed)) {
m_stat.onRemoveAfterLRRotation();
return pNode;
}
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >());
}
//@cond
template <typename K, typename Less>
{
CDS_UNUSED( pred );
return guarded_ptr( base_class::get_with_( key,
- cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >() ));
+ cds::details::predicate_wrapper< leaf_node, Less, typename maker::key_accessor >()));
}
/// Clears the map (not atomic)
bool insert( Q const& val )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().New( val ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
bool emplace( Args&&... args )
{
scoped_node_ptr sp( cxx_leaf_node_allocator().MoveNew( std::forward<Args>(args)... ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
{
CDS_UNUSED(pred);
return base_class::get_with_( key,
- cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >() );
+ cds::details::predicate_wrapper< leaf_node, Less, typename maker::value_accessor >());
}
/// Clears the set (not atomic)
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
template <typename K>
bool insert( K&& key )
{
- scoped_node_ptr sp( cxx_node_allocator().MoveNew( m_Hasher, std::forward<K>( key ) ));
+ scoped_node_ptr sp( cxx_node_allocator().MoveNew( m_Hasher, std::forward<K>( key )));
if ( base_class::insert( *sp )) {
sp.release();
return true;
template <typename K>
bool contains( K const& key )
{
- return base_class::contains( m_Hasher( key_type( key )) );
+ return base_class::contains( m_Hasher( key_type( key )));
}
/// Find the key \p key
this code
\code
if ( it1 == it2 )
- assert( &(*it1) == &(*it2) );
+ assert( &(*it1) == &(*it2));
\endcode
can throw assertion. The point is that the iterator stores the value of element which can be modified later by other thread.
The guard inside the iterator prevents recycling that value so the iterator's value remains valid even after such changing.
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::erase_with( key, less_wrapper<Less>() );
+ return base_class::erase_with( key, less_wrapper<Less>());
}
/// Deletes \p key from the list
guarded_ptr extract_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::extract_with( key, less_wrapper<Less>() );
+ return base_class::extract_with( key, less_wrapper<Less>());
}
/// Checks whether the list contains \p key
bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return base_class::contains( key, less_wrapper<Less>() );
+ return base_class::contains( key, less_wrapper<Less>());
}
/// Finds the key \p key and performs an action with it
guarded_ptr get_with( K const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return base_class::get_with( key, less_wrapper<Less>() );
+ return base_class::get_with( key, less_wrapper<Less>());
}
/// Checks if the list is empty
template <typename K>
bool insert_at( head_type& refHead, K&& key )
{
- return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type() ));
+ return base_class::insert_at( refHead, value_type( key_type( std::forward<K>( key )), mapped_type()));
}
template <typename K, typename V>
this code
\code
if ( it1 == it2 )
- assert( &(*it1) == &(*it2) );
+ assert( &(*it1) == &(*it2));
\endcode
can throw assertion. The point is that the iterator stores the value of element which can be modified later by other thread.
The guard inside the iterator prevents recycling that value so the iterator's value remains valid even after such changing.
*/
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename Q>
guarded_ptr extract( Q const& key )
{
- return extract_at( head(), key, key_comparator() );
+ return extract_at( head(), key, key_comparator());
}
/// Extracts the item from the list with comparing functor \p pred
guarded_ptr extract_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return extract_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return extract_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key ) const
{
- return find_at( head(), key, key_comparator() );
+ return find_at( head(), key, key_comparator());
}
/// Checks whether the list contains \p key using \p pred predicate for searching
bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Finds \p key and perform an action with it
template <typename Q>
guarded_ptr get( Q const& key ) const
{
- return get_at( head(), key, key_comparator() );
+ return get_at( head(), key, key_comparator());
}
/// Finds \p key and return the item found
guarded_ptr get_with( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks if the list is empty
typedef typename base_class::template iterator_type<IsConst> iterator_base;
iterator_type( head_type const& pNode )
- : iterator_base( const_cast<head_type *>(&pNode) )
+ : iterator_base( const_cast<head_type *>(&pNode))
{}
iterator_type( head_type const * pNode )
- : iterator_base( const_cast<head_type *>(pNode) )
+ : iterator_base( const_cast<head_type *>(pNode))
{}
friend class LazyKVList;
*/
iterator begin()
{
- iterator it( head() );
+ iterator it( head());
++it ; // skip dummy head
return it;
}
*/
iterator end()
{
- return iterator( tail() );
+ return iterator( tail());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it; // skip dummy head
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it; // skip dummy head
return it;
}
template <typename K>
bool erase( K const& key )
{
- return erase_at( head(), key, intrusive_key_comparator() );
+ return erase_at( head(), key, intrusive_key_comparator());
}
/// Deletes the item from the list using \p pred predicate for searching
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return erase_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Deletes \p key from the list
template <typename K>
guarded_ptr extract( K const& key )
{
- return extract_at( head(), key, intrusive_key_comparator() );
+ return extract_at( head(), key, intrusive_key_comparator());
}
/// Extracts the item from the list with comparing functor \p pred
guarded_ptr extract_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return extract_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return extract_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key )
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
template <typename K>
guarded_ptr get( K const& key )
{
- return get_at( head(), key, intrusive_key_comparator() );
+ return get_at( head(), key, intrusive_key_comparator());
}
/// Finds the key \p val and return the item found
guarded_ptr get_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks if the list is empty
*/
iterator begin()
{
- iterator it( head() );
+ iterator it( head());
++it ; // skip dummy head node
return it;
}
*/
iterator end()
{
- return iterator( tail() );
+ return iterator( tail());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head node
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head node
return it;
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
const_iterator end() const
{
- return const_iterator( tail() );
+ return const_iterator( tail());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
const_iterator cend() const
{
- return const_iterator( tail() );
+ return const_iterator( tail());
}
//@}
template <typename Q>
guarded_ptr extract( Q const& key )
{
- return extract_at( head(), key, intrusive_key_comparator() );
+ return extract_at( head(), key, intrusive_key_comparator());
}
/// Extracts the item from the list with comparing functor \p pred
guarded_ptr extract_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return extract_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return extract_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key )
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
template <typename Q>
guarded_ptr get( Q const& key )
{
- return get_at( head(), key, intrusive_key_comparator() );
+ return get_at( head(), key, intrusive_key_comparator());
}
/// Finds the key \p key and return the item found
guarded_ptr get_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks whether the list is empty
{
scoped_node_ptr pNode( alloc_node( std::forward<Q>( key )));
- if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ f( node_to_value(node) ); } )) {
+ if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ f( node_to_value(node)); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
- return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node) ); } );
+ return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node)); } );
}
template <typename Q, typename Compare>
*/
iterator begin()
{
- return iterator( head() );
+ return iterator( head());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename K>
bool erase( K const& key )
{
- return erase_at( head(), key, intrusive_key_comparator() );
+ return erase_at( head(), key, intrusive_key_comparator());
}
/// Deletes the item from the list using \p pred predicate for searching
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return erase_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Deletes \p key from the list
template <typename K>
guarded_ptr extract( K const& key )
{
- return extract_at( head(), key, intrusive_key_comparator() );
+ return extract_at( head(), key, intrusive_key_comparator());
}
/// Extracts the item from the list with comparing functor \p pred
guarded_ptr extract_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return extract_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return extract_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key )
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
template <typename K>
guarded_ptr get( K const& key )
{
- return get_at( head(), key, intrusive_key_comparator() );
+ return get_at( head(), key, intrusive_key_comparator());
}
/// Finds the \p key and return the item found
guarded_ptr get_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks if the list is empty
*/
iterator begin()
{
- return iterator( head() );
+ return iterator( head());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename Q>
guarded_ptr extract( Q const& key )
{
- return extract_at( head(), key, intrusive_key_comparator() );
+ return extract_at( head(), key, intrusive_key_comparator());
}
/// Extracts the item from the list with comparing functor \p pred
guarded_ptr extract_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return extract_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return extract_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key )
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
template <typename Q>
guarded_ptr get( Q const& key )
{
- return get_at( head(), key, intrusive_key_comparator() );
+ return get_at( head(), key, intrusive_key_comparator());
}
/// Finds \p key and return the item found
guarded_ptr get_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Check if the list is empty
{
scoped_node_ptr pNode( alloc_node( std::forward<Q>( key )));
- if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { f( node_to_value(node) ); } )) {
+ if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { f( node_to_value(node)); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
- return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node) ); } );
+ return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node)); } );
}
template <typename Q, typename Compare>
/// Returns a forward iterator addressing the first element in a map
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a map
/// Returns a forward const iterator addressing the first element in a map
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a map.
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a map.
/// Returns a forward const iterator that addresses the location succeeding the last element in a map.
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
template <typename K>
guarded_ptr extract( K const& key )
{
- return base_class::extract_( key, typename base_class::key_comparator() );
+ return base_class::extract_( key, typename base_class::key_comparator());
}
/// Extracts the item from the map with comparing functor \p pred
{
CDS_UNUSED( pred );
typedef cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor > wrapped_less;
- return base_class::extract_( key, cds::opt::details::make_comparator_from_less<wrapped_less>() );
+ return base_class::extract_( key, cds::opt::details::make_comparator_from_less<wrapped_less>());
}
/// Extracts an item with minimal key from the map
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >());
}
//@cond
template <typename K, typename Less>
template <typename K>
guarded_ptr get( K const& key )
{
- return base_class::get_with_( key, typename base_class::key_comparator() );
+ return base_class::get_with_( key, typename base_class::key_comparator());
}
/// Finds the key \p key and return the item found
/// Returns a forward iterator addressing the first element in a set
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( base_class::begin() );
+ return const_iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a set.
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
const_iterator end() const
{
- return const_iterator( base_class::end() );
+ return const_iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
bool insert( Q const& val )
{
scoped_node_ptr sp( node_allocator().New( random_level(), val ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
bool emplace( Args&&... args )
{
scoped_node_ptr sp( node_allocator().New( random_level(), std::forward<Args>(args)... ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
bool erase_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >() );
+ return base_class::erase_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >());
}
/// Delete \p key from the set
template <typename Q>
guarded_ptr extract( Q const& key )
{
- return base_class::extract_( key, typename base_class::key_comparator() );
+ return base_class::extract_( key, typename base_class::key_comparator());
}
/// Extracts the item from the set with comparing functor \p pred
{
CDS_UNUSED( pred );
typedef cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor > wrapped_less;
- return base_class::extract_( key, cds::opt::details::make_comparator_from_less<wrapped_less>() );
+ return base_class::extract_( key, cds::opt::details::make_comparator_from_less<wrapped_less>());
}
/// Extracts an item with minimal key from the set
template <typename Q>
guarded_ptr get( Q const& key )
{
- return base_class::get_with_( key, typename base_class::key_comparator() );
+ return base_class::get_with_( key, typename base_class::key_comparator());
}
/// Finds \p key and return the item found
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
*/
iterator begin()
{
- iterator it( head() );
+ iterator it( head());
++it ; // skip dummy head
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head
return it;
}
template <typename Q>
iterator contains( Q const& key )
{
- return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ) );
+ return node_to_iterator( find_at( head(), key, intrusive_key_comparator()) );
}
//@cond
template <typename Q>
typename std::enable_if<Sort, iterator>::type contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );
+ return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type()) );
}
//@cond
template <typename Q, typename Less, bool Sort = c_bSort>
typename std::enable_if<!Sort, iterator>::type contains( Q const& key, Equal equal )
{
CDS_UNUSED( equal );
- return node_to_iterator( find_at( head(), key, typename maker::template equal_to_wrapper<Equal>::type() ) );
+ return node_to_iterator( find_at( head(), key, typename maker::template equal_to_wrapper<Equal>::type()) );
}
//@cond
template <typename Q, typename Equal, bool Sort = c_bSort>
typedef typename base_class::template iterator_type<IsConst> iterator_base;
iterator_type( head_type const& pNode )
- : iterator_base( const_cast<head_type *>(&pNode) )
+ : iterator_base( const_cast<head_type *>(&pNode))
{}
iterator_type( head_type const * pNode )
- : iterator_base( const_cast<head_type *>(pNode) )
+ : iterator_base( const_cast<head_type *>(pNode))
{}
friend class LazyKVList;
*/
iterator begin()
{
- iterator it( head() );
+ iterator it( head());
++it ; // skip dummy head
return it;
}
*/
iterator end()
{
- return iterator( tail() );
+ return iterator( tail());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it; // skip dummy head
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it; // skip dummy head
return it;
}
template <typename K>
bool erase( K const& key )
{
- return erase_at( head(), key, intrusive_key_comparator() );
+ return erase_at( head(), key, intrusive_key_comparator());
}
/// Deletes the item from the list using \p pred predicate for searching
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return erase_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Deletes \p key from the list
exempt_ptr extract_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return exempt_ptr( extract_at( head(), key, typename maker::template less_wrapper<Less>::type() ));
+ return exempt_ptr( extract_at( head(), key, typename maker::template less_wrapper<Less>::type()));
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key ) const
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
typedef typename base_class::template iterator_type<IsConst> iterator_base;
iterator_type( head_type const& pNode )
- : iterator_base( const_cast<head_type *>(&pNode) )
+ : iterator_base( const_cast<head_type *>(&pNode))
{}
explicit iterator_type( const iterator_base& it )
*/
iterator begin()
{
- iterator it( head() );
+ iterator it( head());
++it ; // skip dummy head node
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head node
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head node
return it;
}
template <typename Q>
iterator insert( Q&& val )
{
- return node_to_iterator( insert_at( head(), std::forward<Q>( val )) );
+ return node_to_iterator( insert_at( head(), std::forward<Q>( val )));
}
/// Inserts data of type \p value_type created from \p args
template <typename Q>
iterator contains( Q const& key )
{
- return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ));
+ return node_to_iterator( find_at( head(), key, intrusive_key_comparator()));
}
//@cond
template <typename Q>
typename std::enable_if<Sort, iterator>::type contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ));
+ return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type()));
}
//@cond
template <typename Q, typename Less, bool Sort = c_bSort>
typename std::enable_if<!Sort, iterator>::type contains( Q const& key, Equal equal )
{
CDS_UNUSED( equal );
- return node_to_iterator( find_at( head(), key, typename maker::template equal_to_wrapper<Equal>::type() ));
+ return node_to_iterator( find_at( head(), key, typename maker::template equal_to_wrapper<Equal>::type()));
}
//@cond
template <typename Q, typename Equal, bool Sort = c_bSort>
*/
iterator begin()
{
- iterator it( head() );
+ iterator it( head());
++it ; // skip dummy head node
return it;
}
*/
iterator end()
{
- return iterator( tail() );
+ return iterator( tail());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head node
return it;
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( head() );
+ const_iterator it( head());
++it ; // skip dummy head node
return it;
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
const_iterator end() const
{
- return const_iterator( tail() );
+ return const_iterator( tail());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
const_iterator cend() const
{
- return const_iterator( tail() );
+ return const_iterator( tail());
}
//@}
template <typename Q>
bool contains( Q const& key ) const
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
{
scoped_node_ptr pNode( alloc_node( std::forward<Q>( key )));
- if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ f( node_to_value(node) ); } )) {
+ if ( base_class::insert_at( &refHead, *pNode, [&f](node_type& node){ f( node_to_value(node)); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
- return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node) ); } );
+ return base_class::erase_at( &refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node)); } );
}
template <typename Q, typename Compare>
*/
iterator begin()
{
- return iterator( head() );
+ return iterator( head());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename Q>
iterator contains( Q const& key )
{
- return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ) );
+ return node_to_iterator( find_at( head(), key, intrusive_key_comparator()) );
}
//@cond
template <typename Q>
iterator contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );
+ return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type()) );
}
//@cond
template <typename Q, typename Less>
*/
iterator begin()
{
- return iterator( head() );
+ return iterator( head());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename K>
bool erase( K const& key )
{
- return erase_at( head(), key, intrusive_key_comparator() );
+ return erase_at( head(), key, intrusive_key_comparator());
}
/// Deletes the item from the list using \p pred predicate for searching
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return erase_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Deletes \p key from the list
rcu_michael_list::exempt_ptr p;
// The RCU should NOT be locked when extract() is called!
- assert( !rcu::is_locked() );
+ assert( !rcu::is_locked());
// extract() call
p = theList.extract( 10 );
template <typename K>
exempt_ptr extract( K const& key )
{
- return exempt_ptr( extract_at( head(), key, intrusive_key_comparator() ));
+ return exempt_ptr( extract_at( head(), key, intrusive_key_comparator()));
}
/// Extracts an item from the list using \p pred predicate for searching
exempt_ptr extract_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return exempt_ptr( extract_at( head(), key, typename maker::template less_wrapper<Less>::type() ));
+ return exempt_ptr( extract_at( head(), key, typename maker::template less_wrapper<Less>::type()));
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key )
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
raw_ptr get_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return get_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return get_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
/// Checks if the list is empty
*/
iterator begin()
{
- return iterator( head() );
+ return iterator( head());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename Q>
iterator insert( Q&& val )
{
- return node_to_iterator( insert_at( head(), std::forward<Q>( val )) );
+ return node_to_iterator( insert_at( head(), std::forward<Q>( val )));
}
/// Updates the item
template <typename Q>
iterator contains( Q const& key )
{
- return node_to_iterator( find_at( head(), key, intrusive_key_comparator() ));
+ return node_to_iterator( find_at( head(), key, intrusive_key_comparator()));
}
//@cond
template <typename Q>
iterator contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type() ) );
+ return node_to_iterator( find_at( head(), key, typename maker::template less_wrapper<Less>::type()) );
}
//@cond
template <typename Q, typename Less>
*/
iterator begin()
{
- return iterator( head() );
+ return iterator( head());
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator( head() );
+ return const_iterator( head());
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
rcu_michael_list::exempt_ptr p;
// The RCU should NOT be locked when extract() is called!
- assert( !rcu::is_locked() );
+ assert( !rcu::is_locked());
// extract() call
p = theList.extract( 10 )
template <typename Q>
exempt_ptr extract( Q const& key )
{
- return exempt_ptr( extract_at( head(), key, intrusive_key_comparator() ));
+ return exempt_ptr( extract_at( head(), key, intrusive_key_comparator()));
}
/// Extracts an item from the list using \p pred predicate for searching
exempt_ptr extract_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return exempt_ptr( extract_at( head(), key, typename maker::template less_wrapper<Less>::type() ));
+ return exempt_ptr( extract_at( head(), key, typename maker::template less_wrapper<Less>::type()));
}
/// Checks whether the list contains \p key
template <typename Q>
bool contains( Q const& key )
{
- return find_at( head(), key, intrusive_key_comparator() );
+ return find_at( head(), key, intrusive_key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( head(), key, typename maker::template less_wrapper<Less>::type() );
+ return find_at( head(), key, typename maker::template less_wrapper<Less>::type());
}
//@cond
// Deprecatd, use contains()
{
scoped_node_ptr pNode( alloc_node( std::forward<Q>( key )));
- if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { f( node_to_value(node) ); } )) {
+ if ( base_class::insert_at( refHead, *pNode, [&f]( node_type& node ) { f( node_to_value(node)); } )) {
pNode.release();
return true;
}
template <typename Q, typename Compare, typename Func>
bool erase_at( head_type& refHead, Q const& key, Compare cmp, Func f )
{
- return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node) ); } );
+ return base_class::erase_at( refHead, key, cmp, [&f](node_type const& node){ f( node_to_value(node)); } );
}
template <typename Q, typename Func>
\p key_type and an argument of template type \p K must meet the following requirements:
- \p key_type should be constructible from value of type \p K;
- the hash functor should be able to calculate correct hash value from argument \p key of type \p K:
- <tt> hash( key_type(key) ) == hash( key ) </tt>
+ <tt> hash( key_type(key)) == hash( key ) </tt>
- values of type \p key_type and \p K should be comparable
There are the specializations:
*/
iterator begin()
{
- return iterator( bucket_begin()->begin(), bucket_begin(), bucket_end() );
+ return iterator( bucket_begin()->begin(), bucket_begin(), bucket_end());
}
/// Returns an iterator that addresses the location succeeding the last element in a map
*/
iterator end()
{
- return iterator( bucket_end()[-1].end(), bucket_end() - 1, bucket_end() );
+ return iterator( bucket_end()[-1].end(), bucket_end() - 1, bucket_end());
}
/// Returns a forward const iterator addressing the first element in a map
size_t nLoadFactor ///< load factor: estimation of max number of items in the bucket
)
: m_nHashBitmask( michael_map::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
- , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
+ , m_Buckets( bucket_table_allocator().allocate( bucket_count()) )
{
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
construct_bucket<bucket_stat>( it );
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
{
auto& b = bucket( key );
auto it = b.find( key );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
return iterator( it, &b, bucket_end());
}
{
auto& b = bucket( key );
auto it = b.find_with( key, pred );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
/// Checks whether the map contains \p key
const_iterator get_const_begin() const
{
- return const_iterator( bucket_begin()->cbegin(), bucket_begin(), bucket_end() );
+ return const_iterator( bucket_begin()->cbegin(), bucket_begin(), bucket_end());
}
const_iterator get_const_end() const
{
- return const_iterator( (bucket_end() - 1)->cend(), bucket_end() - 1, bucket_end() );
+ return const_iterator( (bucket_end() - 1)->cend(), bucket_end() - 1, bucket_end());
}
template <typename Stat>
*/
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
*/
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
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
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert( key );
- if ( it != refBucket.end() ) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count() );
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert( key, val );
- if ( it != refBucket.end() ) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count() );
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
internal_bucket_type& refBucket = bucket( key );
bucket_iterator it = refBucket.insert_with( key, func );
- if ( it != refBucket.end() ) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count() );
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
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;
- return iterator( it, &refBucket, m_Buckets + bucket_count() );
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
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( 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>
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();
}
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();
}
//@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
{
- 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>
\p key_type and an argument of template type \p K must meet the following requirements:
- \p key_type should be constructible from value of type \p K;
- the hash functor should be able to calculate correct hash value from argument \p key of type \p K:
- <tt> hash( key_type(key) ) == hash( key ) </tt>
+ <tt> hash( key_type(key)) == hash( key ) </tt>
- values of type \p key_type and \p K should be comparable
<b>How to use</b>
*/
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 map
*/
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 map
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
//@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
{
- 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>
size_t nMaxItemCount, ///< estimation of max item count in the hash set
size_t nLoadFactor ///< load factor: estimation of max number of items in the bucket
) : m_nHashBitmask( michael_set::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
- , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
+ , m_Buckets( bucket_table_allocator().allocate( bucket_count()) )
{
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
construct_bucket<bucket_stat>( it );
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
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find( key );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
return iterator( it, &b, bucket_end());
}
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find( key );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
//@endcond
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find_with( key, pred );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
//@cond
template <typename Q, typename Less>
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find_with( key, pred );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
//@endcond
const_iterator get_const_begin() const
{
- return const_iterator( bucket_begin()->cbegin(), bucket_begin(), bucket_end() );
+ return const_iterator( bucket_begin()->cbegin(), bucket_begin(), bucket_end());
}
const_iterator get_const_end() const
{
- return const_iterator(( bucket_end() -1 )->cend(), bucket_end() - 1, bucket_end() );
+ return const_iterator(( bucket_end() -1 )->cend(), bucket_end() - 1, bucket_end());
}
template <typename Stat>
*/
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
*/
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
size_t nMaxItemCount, ///< estimation of max item count in the hash set
size_t nLoadFactor ///< load factor: estimation of max number of items in the bucket
) : m_nHashBitmask( michael_set::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
- , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
+ , m_Buckets( bucket_table_allocator().allocate( bucket_count()) )
{
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
construct_bucket<bucket_stat>( it );
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
internal_bucket_type& refBucket = bucket( val );
bucket_iterator it = refBucket.insert( val );
- if ( it != refBucket.end() ) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count() );
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
typename internal_bucket_type::node_type * pNode = internal_bucket_type::alloc_node( std::forward<Args>( args )... );
internal_bucket_type& refBucket = bucket( internal_bucket_type::node_to_value( *pNode ));
bucket_iterator it = refBucket.insert_node( pNode );
- if ( it != refBucket.end() ) {
+ if ( it != refBucket.end()) {
++m_ItemCounter;
- return iterator( it, &refBucket, m_Buckets + bucket_count() );
+ return iterator( it, &refBucket, m_Buckets + bucket_count());
}
return end();
internal_bucket_type& refBucket = bucket( val );
std::pair<bucket_iterator, bool> ret = refBucket.update( val, bAllowInsert );
- if ( ret.first != refBucket.end() ) {
+ if ( ret.first != refBucket.end()) {
if ( ret.second )
++m_ItemCounter;
- 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 );
}
return std::make_pair( end(), ret.second );
}
{
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();
}
{
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();
}
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
{
- 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());
}
//@endcond
};
*/
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
*/
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
size_t nMaxItemCount, ///< estimation of max item count in the hash set
size_t nLoadFactor ///< load factor: estimation of max number of items in the bucket
) : m_nHashBitmask( michael_set::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
- , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
+ , m_Buckets( bucket_table_allocator().allocate( bucket_count()) )
{
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
construct_bucket<bucket_stat>( it );
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());
}
bool emplace( Args&&... args )
{
typename internal_bucket_type::node_type * pNode = internal_bucket_type::alloc_node( std::forward<Args>( args )... );
- bool bRet = bucket( internal_bucket_type::node_to_value( *pNode ) ).insert_node( pNode );
+ bool bRet = bucket( internal_bucket_type::node_to_value( *pNode )).insert_node( pNode );
if ( bRet )
++m_ItemCounter;
return bRet;
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
{
- 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());
}
//@endcond
};
*/
bool enqueue( value_type const& val )
{
- scoped_node_ptr p( alloc_node(val) );
+ scoped_node_ptr p( alloc_node(val));
if ( base_class::enqueue( *p )) {
p.release();
return true;
bool enqueue( value_type&& val )
{
scoped_node_ptr p( alloc_node_move( std::move( val )));
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( p->m_value );
if ( base_class::enqueue( *p )) {
p.release();
template <typename... Args>
bool emplace( Args&&... args )
{
- scoped_node_ptr p( alloc_node_move( std::forward<Args>( args )... ) );
- if ( base_class::enqueue( *p ) ) {
+ scoped_node_ptr p( alloc_node_move( std::forward<Args>( args )... ));
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
bool push( value_type const& val )
{
scoped_ptr pVal( cxx_allocator().New( val ));
- if ( base_class::push( *(pVal.get()) )) {
+ if ( base_class::push( *(pVal.get()))) {
pVal.release();
return true;
}
template <typename Func>
bool push_with( Func f )
{
- scoped_ptr pVal( cxx_allocator().New() );
+ scoped_ptr pVal( cxx_allocator().New());
f( *pVal );
if ( base_class::push( *pVal )) {
pVal.release();
bool emplace( Args&&... args )
{
scoped_ptr pVal( cxx_allocator().MoveNew( std::forward<Args>(args)... ));
- if ( base_class::push( *(pVal.get()) )) {
+ if ( base_class::push( *(pVal.get()))) {
pVal.release();
return true;
}
*/
bool enqueue( value_type const& val )
{
- scoped_node_ptr p( alloc_node(val) );
- if ( base_class::enqueue( *p ) ) {
+ scoped_node_ptr p( alloc_node(val));
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
bool enqueue( value_type&& val )
{
scoped_node_ptr p( alloc_node_move( std::move( val )));
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( p->m_value );
if ( base_class::enqueue( *p )) {
p.release();
template <typename... Args>
bool emplace( Args&&... args )
{
- scoped_node_ptr p( alloc_node_move( std::forward<Args>( args )... ) );
- if ( base_class::enqueue( *p ) ) {
+ scoped_node_ptr p( alloc_node_move( std::forward<Args>( args )... ));
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
bool enqueue( value_type&& val )
{
scoped_node_ptr p( alloc_node_move( std::move( val )));
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( p->m_value );
if ( base_class::enqueue( *p )) {
p.release();
bool dequeue_with( Func f )
{
typename base_class::dequeue_result res;
- if ( base_class::do_dequeue( res ) ) {
+ if ( base_class::do_dequeue( res )) {
f( node_traits::to_value_ptr( *res.pNext )->m_value );
base_class::dispose_result( res );
bool enqueue( value_type const& data )
{
scoped_node_ptr p( alloc_node( data ));
- if ( enqueue_node( p.get() )) {
+ if ( enqueue_node( p.get())) {
p.release();
return true;
}
bool enqueue( value_type&& data )
{
scoped_node_ptr p( alloc_node_move( std::move( data )));
- if ( enqueue_node( p.get() ) ) {
+ if ( enqueue_node( p.get()) ) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( p->m_value );
- if ( enqueue_node( p.get() )) {
+ if ( enqueue_node( p.get())) {
p.release();
return true;
}
bool emplace( Args&&... args )
{
scoped_node_ptr p( alloc_node_move( std::forward<Args>(args)... ));
- if ( enqueue_node( p.get() )) {
+ if ( enqueue_node( p.get())) {
p.release();
return true;
}
*/
bool enqueue( value_type const& val )
{
- scoped_node_ptr p( alloc_node(val) );
- if ( base_class::enqueue( *p ) ) {
+ scoped_node_ptr p( alloc_node(val));
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
bool enqueue( value_type&& val )
{
scoped_node_ptr p( alloc_node_move( std::move( val )));
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( *p );
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename... Args>
bool emplace( Args&&... args )
{
- scoped_node_ptr p( alloc_node_move( std::forward<Args>(args)... ) );
+ scoped_node_ptr p( alloc_node_move( std::forward<Args>(args)... ));
if ( base_class::enqueue( *p )) {
p.release();
return true;
iterator insert( K const& key )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::insert( std::make_pair( key_type( key ), mapped_type() ) );
+ return base_class::insert( std::make_pair( key_type( key ), mapped_type()) );
}
/// Inserts new node
iterator insert_with( K const& key, Func func )
{
iterator it = insert( key );
- if ( it != end() )
- func( (*it) );
+ if ( it != end())
+ func( (*it));
return it;
}
std::pair<iterator, bool> update( K const& key, bool bInsert = true )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::update( std::make_pair( key_type( key ), mapped_type() ), bInsert );
+ return base_class::update( std::make_pair( key_type( key ), mapped_type()), bInsert );
}
//@cond
template <typename K>
/// Returns a forward iterator addressing the first element in a map
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a map
/// Returns a forward const iterator addressing the first element in a map
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a map.
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a map.
/// Returns a forward const iterator that addresses the location succeeding the last element in a map.
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >());
}
//@cond
template <typename K, typename Less>
raw_ptr get_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return raw_ptr( base_class::get_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >() ));
+ return raw_ptr( base_class::get_with( key, cds::details::predicate_wrapper< node_type, Less, typename maker::key_accessor >()));
}
/// Clears the map (not atomic)
/// Returns a forward iterator addressing the first element in a set
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( base_class::begin() );
+ return const_iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a set.
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
const_iterator end() const
{
- return const_iterator( base_class::end() );
+ return const_iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
iterator insert( const Q& val )
{
scoped_node_ptr sp( node_allocator().New( base_class::random_level(), val ));
- if ( base_class::insert( *sp.get() )) {
- return node_to_iterator( sp.release() );
+ if ( base_class::insert( *sp.get())) {
+ return node_to_iterator( sp.release());
}
return end();
}
iterator emplace( Args&&... args )
{
scoped_node_ptr sp( node_allocator().New( base_class::random_level(), std::forward<Args>(args)... ));
- if ( base_class::insert( *sp.get() )) {
- return node_to_iterator( sp.release() );
+ if ( base_class::insert( *sp.get())) {
+ return node_to_iterator( sp.release());
}
return end();
}
iterator contains( Q const& key, Less pred ) const
{
CDS_UNUSED( pred );
- node_type * pNode = base_class::contains( key, cds::details::predicate_wrapper< node_type, Less, key_accessor>() );
+ node_type * pNode = base_class::contains( key, cds::details::predicate_wrapper< node_type, Less, key_accessor>());
if ( pNode )
return node_to_iterator( pNode );
return base_class::nonconst_end();
/// Returns a forward iterator addressing the first element in a set
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( base_class::begin() );
+ return const_iterator( base_class::begin());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a set.
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
const_iterator end() const
{
- return const_iterator( base_class::end() );
+ return const_iterator( base_class::end());
}
/// Returns a forward const iterator that addresses the location succeeding the last element in a set.
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
bool insert( Q const& val )
{
scoped_node_ptr sp( node_allocator().New( random_level(), val ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
bool emplace( Args&&... args )
{
scoped_node_ptr sp( node_allocator().New( random_level(), std::forward<Args>(args)... ));
- if ( base_class::insert( *sp.get() )) {
+ if ( base_class::insert( *sp.get())) {
sp.release();
return true;
}
raw_ptr get_with( Q const& val, Less pred )
{
CDS_UNUSED( pred );
- return raw_ptr( base_class::get_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >() ));
+ return raw_ptr( base_class::get_with( val, cds::details::predicate_wrapper< node_type, Less, typename maker::value_accessor >()));
}
/// Clears the set (non-atomic).
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
template <typename K>
bool insert( K&& key )
{
- return base_class::emplace( key_type( std::forward<K>( key )), mapped_type() );
+ return base_class::emplace( key_type( std::forward<K>( key )), mapped_type());
}
/// Inserts new node
#endif
update( K&& key, Func func, bool bAllowInsert = true )
{
- typedef decltype( std::make_pair( key_type( std::forward<K>( key )), mapped_type() )) arg_pair_type;
+ typedef decltype( std::make_pair( key_type( std::forward<K>( key )), mapped_type())) arg_pair_type;
return base_class::update( std::make_pair( key_type( key ), mapped_type()),
[&func]( bool bNew, value_type& item, arg_pair_type const& /*val*/ ) {
find_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::find_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ return base_class::find_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
}
/// Checks whether the map contains \p key
iterator insert( K const& key )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::emplace( key_type( key ), mapped_type() );
+ return base_class::emplace( key_type( key ), mapped_type());
}
/// Inserts new node
iterator insert_with( const K& key, Func func )
{
iterator it = insert( key );
- if ( it != end() )
- func( (*it) );
+ if ( it != end())
+ func( (*it));
return it;
}
std::pair<iterator, bool> update( K const& key, bool bAllowInsert = true )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::update( std::make_pair( key_type( key ), mapped_type() ), bAllowInsert );
+ return base_class::update( std::make_pair( key_type( key ), mapped_type()), bAllowInsert );
}
//@cond
template <typename K>
iterator contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
}
//@cond
template <typename K, typename Less>
template <typename K>
bool insert( K const& key )
{
- return base_class::emplace( key_type( key ), mapped_type() );
+ return base_class::emplace( key_type( key ), mapped_type());
}
/// Inserts new node
bool insert_with( K const& key, Func func )
{
//TODO: pass arguments by reference (make_pair makes copy)
- return base_class::insert( std::make_pair( key_type( key ), mapped_type() ), func );
+ return base_class::insert( std::make_pair( key_type( key ), mapped_type()), func );
}
/// For key \p key inserts data of type \p mapped_type created in-place from \p args
std::pair<bool, bool> update( K const& key, Func func, bool bAllowInsert = true )
{
//TODO: pass arguments by reference (make_pair makes copy)
- typedef decltype( std::make_pair( key_type( key ), mapped_type() )) arg_pair_type;
+ typedef decltype( std::make_pair( key_type( key ), mapped_type())) arg_pair_type;
- return base_class::update( std::make_pair( key_type( key ), mapped_type() ),
+ return base_class::update( std::make_pair( key_type( key ), mapped_type()),
[&func]( bool bNew, value_type& item, arg_pair_type const& /*val*/ ) {
func( bNew, item );
},
bool erase_with( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::erase_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ return base_class::erase_with( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
}
/// Deletes \p key from the map
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>() );
+ return base_class::contains( key, cds::details::predicate_wrapper<value_type, Less, key_accessor>());
}
//@cond
template <typename K, typename Less>
#endif
upsert( Q&& val, bool bAllowInsert = true )
{
- scoped_node_ptr pNode( alloc_node( val ) );
+ scoped_node_ptr pNode( alloc_node( val ));
auto bRet = base_class::upsert( *pNode, bAllowInsert );
>::type
update( Q const& val, Func func, bool bAllowInsert = true )
{
- scoped_node_ptr pNode( alloc_node( val ) );
+ scoped_node_ptr pNode( alloc_node( val ));
auto bRet = base_class::update( *pNode,
[&func]( node_type& item, node_type* old ) {
typename std::enable_if< std::is_same<Q,Q>::value && is_iterable_list< ordered_list >::value, iterator>::type
find_iterator_( Q& val )
{
- return iterator( base_class::find( val ) );
+ return iterator( base_class::find( val ));
}
template <typename Q, typename Less, typename Func>
find_iterator_with_( Q& val, Less pred )
{
CDS_UNUSED( pred );
- return iterator( base_class::find_with( val, typename maker::template predicate_wrapper<Less>::type() ));
+ return iterator( base_class::find_with( val, typename maker::template predicate_wrapper<Less>::type()));
}
struct node_disposer {
assert( pNode != nullptr );
scoped_node_ptr p( pNode );
- if ( base_class::insert( *pNode ) ) {
+ if ( base_class::insert( *pNode )) {
p.release();
return true;
}
*/
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns an iterator that addresses the location succeeding the last element in a set
*/
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator addressing the first element in a set
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
scoped_node_ptr p(pNode);
iterator it( base_class::insert_( *pNode ));
- if ( it != end() ) {
+ if ( it != end()) {
p.release();
return it;
}
template <typename Q>
iterator insert( const Q& val )
{
- return insert_node( alloc_node( val ) );
+ return insert_node( alloc_node( val ));
}
/// Inserts data of type \p value_type created from \p args
template <typename... Args>
iterator emplace( Args&&... args )
{
- return insert_node( alloc_node( std::forward<Args>(args)... ) );
+ return insert_node( alloc_node( std::forward<Args>(args)... ));
}
/// Updates the item
iterator contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return iterator( base_class::find_with_( key, typename maker::template predicate_wrapper<Less>::type() ));
+ return iterator( base_class::find_with_( key, typename maker::template predicate_wrapper<Less>::type()));
}
//@cond
// eprecated, use contains()
assert( pNode != nullptr );
scoped_node_ptr p(pNode);
- if ( base_class::insert( *pNode ) ) {
+ if ( base_class::insert( *pNode )) {
p.release();
return true;
}
*/
iterator begin()
{
- return iterator( base_class::begin() );
+ return iterator( base_class::begin());
}
/// Returns an iterator that addresses the location succeeding the last element in a set
*/
iterator end()
{
- return iterator( base_class::end() );
+ return iterator( base_class::end());
}
/// Returns a forward const iterator addressing the first element in a set
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( base_class::cbegin() );
+ return const_iterator( base_class::cbegin());
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator cend() const
{
- return const_iterator( base_class::cend() );
+ return const_iterator( base_class::cend());
}
//@}
template <typename Q>
bool insert( Q const& val )
{
- return insert_node( alloc_node( val ) );
+ return insert_node( alloc_node( val ));
}
/// Inserts new node
bool erase_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type() );
+ return base_class::erase_with( key, typename maker::template predicate_wrapper<Less>::type());
}
/// Deletes \p key from the set
template <typename Q>
exempt_ptr extract( Q const& key )
{
- return exempt_ptr( base_class::extract_( key, key_comparator() ));
+ return exempt_ptr( base_class::extract_( key, key_comparator()));
}
/// Extracts an item from the set using \p pred predicate for searching
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, typename maker::template predicate_wrapper<Less>::type() );
+ return base_class::contains( key, typename maker::template predicate_wrapper<Less>::type());
}
//@cond
template <typename Q, typename Less>
std::list<std::pair<const Key, T> >::iterator itInsert,
std::list<std::pair<const Key, T> >::iterator itWhat )
{
- std::pair<Key, T> newVal( itWhat->first, T() );
+ std::pair<Key, T> newVal( itWhat->first, T());
std::swap( list.insert( itInsert, newVal )->second, itWhat->second );
}
} \endcode
std::list<std::pair<const Key, T> >::iterator itInsert,
std::list<std::pair<const Key, T> >::iterator itWhat )
{
- list.insert( itInsert, std::move( *itWhat ) );
+ list.insert( itInsert, std::move( *itWhat ));
}
} \endcode
</td>
{
std::swap(
map.insert(
- std::map::value_type( itWhat->first, T() ) ).first->second
+ std::map::value_type( itWhat->first, T()) ).first->second
, itWhat->second
));
}
bc::slist<std::pair<const Key, T> >::iterator itInsert,
bc::slist<std::pair<const Key, T> >::iterator itWhat )
{
- std::pair<Key, T> newVal( itWhat->first, T() );
+ std::pair<Key, T> newVal( itWhat->first, T());
std::swap( list.insert( itInsert, newVal )->second, itWhat->second );
}
} \endcode
bc::slist<std::pair<const Key, T> >::iterator itInsert,
bc::slist<std::pair<const Key, T> >::iterator itWhat )
{
- list.insert_after( itInsert, std::move( *itWhat ) );
+ list.insert_after( itInsert, std::move( *itWhat ));
}
} \endcode
</td>
StripedMap(
size_t nCapacity ///< Initial size of bucket table and lock array. Must be power of two, the minimum is 16.
,resizing_policy&& resizingPolicy ///< Resizing policy
- ) : base_class( nCapacity, std::forward<resizing_policy>(resizingPolicy) )
+ ) : base_class( nCapacity, std::forward<resizing_policy>(resizingPolicy))
{}
/// Destructor destroys internal data
bool contains( K const& key, Less pred )
{
CDS_UNUSED( pred );
- return base_class::contains( key, cds::details::predicate_wrapper< value_type, Less, key_accessor >() );
+ return base_class::contains( key, cds::details::predicate_wrapper< value_type, Less, key_accessor >());
}
//@cond
template <typename K, typename Less
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- pair_type newVal( itWhat->first, typename pair_type::second_type() );
+ pair_type newVal( itWhat->first, typename pair_type::second_type());
itInsert = list.insert( itInsert, newVal );
std::swap( itInsert->second, itWhat->second );
}
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- list.insert( itInsert, std::move( *itWhat ) );
+ list.insert( itInsert, std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
//value_type newItem( key );
- it = m_List.insert( it, value_type( key_type( key ), mapped_type()) );
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type()));
f( *it );
return true;
bool emplace( K&& key, Args&&... args )
{
value_type val( key_type( std::forward<K>( key )), mapped_type( std::forward<Args>( args )... ));
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val.first, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val.first, find_predicate());
if ( it == m_List.end() || key_comparator()( val.first, it->first ) != 0 ) {
m_List.emplace( it, std::move( val ));
return true;
template <typename Q, typename Func>
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
// insert new
if ( !bAllowInsert )
return std::make_pair( false, false );
- it = m_List.insert( it, value_type( key_type( key ), mapped_type() ));
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type()));
func( true, *it );
return std::make_pair( true, true );
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 )
return false;
bool erase( Q const& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, pred );
- if ( it == m_List.end() || pred( key, it->first ) || pred(it->first, key) )
+ if ( it == m_List.end() || pred( key, it->first ) || pred(it->first, key))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, it->first ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, pred );
- if ( it == m_List.end() || pred( val, it->first ) || pred( it->first, val ) )
+ if ( it == m_List.end() || pred( val, it->first ) || pred( it->first, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate());
assert( it == m_List.end() || key_comparator()( itWhat->first, it->first ) != 0 );
copy_item()( m_List, it, itWhat );
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- pair_type newVal( itWhat->first, typename pair_type::mapped_type() );
+ pair_type newVal( itWhat->first, typename pair_type::mapped_type());
itInsert = list.insert_after( itInsert, newVal );
std::swap( itInsert->second, itWhat->second );
}
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- list.insert_after( itInsert, std::move( *itWhat ) );
+ list.insert_after( itInsert, std::move( *itWhat ));
}
};
} // namespace striped_set
{
std::pair< iterator, bool > pos = find_prev_item( key );
if ( !pos.second ) {
- pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type() ));
+ pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type()));
f( *pos.first );
return true;
}
if ( !bAllowInsert )
return std::make_pair( false, false );
- pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type() ));
+ pos.first = m_List.insert_after( pos.first, value_type( key_type( key ), mapped_type()));
func( true, *pos.first );
return std::make_pair( true, true );
}
else {
// already exists
- func( false, *(++pos.first) );
+ func( false, *(++pos.first));
return std::make_pair( true, false );
}
}
// key exists
iterator it = pos.first;
- f( *(++it) );
+ f( *(++it));
m_List.erase_after( pos.first );
return true;
// key exists
iterator it = pos.first;
- f( *(++it) );
+ f( *(++it));
m_List.erase_after( pos.first );
return true;
void operator()( map_type& map, iterator itWhat )
{
- pair_type pair( itWhat->first, typename pair_type::second_type() );
+ pair_type pair( itWhat->first, typename pair_type::second_type());
std::pair<iterator, bool> res = map.insert( pair );
assert( res.second );
std::swap( res.first->second, itWhat->second );
void operator()( map_type& map, iterator itWhat )
{
- map.insert( std::move( *itWhat ) );
+ map.insert( std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ));
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type()));
if ( res.second )
- f( const_cast<value_type&>(*res.first) );
+ f( const_cast<value_type&>(*res.first));
return res.second;
}
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ) );
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type()) );
func( res.second, const_cast<value_type&>(*res.first));
return std::make_pair( true, res.second );
}
else {
auto it = m_Map.find( key_type( key ));
- if ( it == end() )
+ if ( it == end())
return std::make_pair( false, false );
func( false, *it );
return std::make_pair( true, false );
bool erase( const Q& key, Func f )
{
iterator it = m_Map.find( key_type( key ));
- if ( it == m_Map.end() )
+ if ( it == m_Map.end())
return false;
- f( const_cast<value_type&>(*it) );
+ f( const_cast<value_type&>(*it));
m_Map.erase( it );
return true;
}
bool find( Q& key, Func f )
{
iterator it = m_Map.find( key_type( key ));
- if ( it == m_Map.end() )
+ if ( it == m_Map.end())
return false;
f( const_cast<value_type&>(*it), key );
return true;
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- assert( m_Map.find( itWhat->first ) == m_Map.end() );
+ assert( m_Map.find( itWhat->first ) == m_Map.end());
copy_item()( m_Map, itWhat );
}
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- pair_type newVal( itWhat->first, typename pair_type::second_type() );
+ pair_type newVal( itWhat->first, typename pair_type::second_type());
itInsert = list.insert( itInsert, newVal );
std::swap( itInsert->second, itWhat->second );
}
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- list.insert( itInsert, std::move( *itWhat ) );
+ list.insert( itInsert, std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
- it = m_List.insert( it, value_type( key_type( key ), mapped_type()) );
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type()));
f( *it );
# if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM)
bool emplace( K&& key, Args&&... args )
{
value_type val( key_type( std::forward<K>( key )), mapped_type( std::forward<Args>( args )... ));
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val.first, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val.first, find_predicate());
if ( it == m_List.end() || key_comparator()( val.first, it->first ) != 0 ) {
it = m_List.emplace( it, std::move( val ));
template <typename Q, typename Func>
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 ) {
// insert new
if ( !bAllowInsert )
return std::make_pair( false, false );
- it = m_List.insert( it, value_type( key_type( key ), mapped_type() ));
+ it = m_List.insert( it, value_type( key_type( key ), mapped_type()));
func( true, *it );
# if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM)
++m_nSize;
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, it->first ) != 0 )
return false;
bool erase( Q const& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, pred );
- if ( it == m_List.end() || pred( key, it->first ) || pred( it->first, key ) )
+ if ( it == m_List.end() || pred( key, it->first ) || pred( it->first, key ))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, it->first ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, pred );
- if ( it == m_List.end() || pred( val, it->first ) || pred( it->first, val ) )
+ if ( it == m_List.end() || pred( val, it->first ) || pred( it->first, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate());
assert( it == m_List.end() || key_comparator()( itWhat->first, it->first ) != 0 );
copy_item()( m_List, it, itWhat );
void operator()( map_type& map, iterator itWhat )
{
- std::pair< typename map_type::iterator, bool > ret = map.insert( pair_type( itWhat->first, typename pair_type::second_type() ));
+ std::pair< typename map_type::iterator, bool > ret = map.insert( pair_type( itWhat->first, typename pair_type::second_type()));
assert( ret.second ) ; // successful insertion
std::swap( ret.first->second, itWhat->second );
}
void operator()( map_type& map, iterator itWhat )
{
- map.insert( std::move( *itWhat ) );
+ map.insert( std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ) );
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type()) );
if ( res.second )
f( *res.first );
return res.second;
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ));
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type()));
func( res.second, *res.first );
return std::make_pair( true, res.second );
}
else {
auto it = m_Map.find( key_type( key ));
- if ( it == end() )
+ if ( it == end())
return std::make_pair( false, false );
func( false, *it );
return std::make_pair( true, false );
bool erase( const Q& key, Func f )
{
iterator it = m_Map.find( key_type( key ));
- if ( it == m_Map.end() )
+ if ( it == m_Map.end())
return false;
f( *it );
m_Map.erase( it );
bool find( Q& key, Func f )
{
iterator it = m_Map.find( key_type( key ));
- if ( it == m_Map.end() )
+ if ( it == m_Map.end())
return false;
f( *it, key );
return true;
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- assert( m_Map.find( itWhat->first ) == m_Map.end() );
+ assert( m_Map.find( itWhat->first ) == m_Map.end());
copy_item()( m_Map, itWhat );
}
struct swap_item {
void operator()( std::list<T>& list, std::list<T>::iterator itInsert, std::list<T>::iterator itWhat )
{
- std::swap( *list.insert( itInsert, T() ), *itWhat );
+ std::swap( *list.insert( itInsert, T()), *itWhat );
}
} \endcode
struct move_item {
void operator()( std::list<T>& list, std::list<T>::iterator itInsert, std::list<T>::iterator itWhat )
{
- list.insert( itInsert, std::move( *itWhat ) );
+ list.insert( itInsert, std::move( *itWhat ));
}
} \endcode
</td>
struct swap_item {
void operator()( bc::slist<T>& list, bc::slist<T>::iterator itInsert, bc::slist<T>::iterator itWhat )
{
- std::swap( *list.insert_after( itInsert, T() ), *itWhat );
+ std::swap( *list.insert_after( itInsert, T()), *itWhat );
}
} \endcode
struct move_item {
void operator()( bc::slist<T>& list, bc::slist<T>::iterator itInsert, bc::slist<T>::iterator itWhat )
{
- list.insert_after( itInsert, std::move( *itWhat ) );
+ list.insert_after( itInsert, std::move( *itWhat ));
}
} \endcode
</td>
,resizing_policy&& resizingPolicy ///< Resizing policy
)
- : base_class( nCapacity, std::forward<resizing_policy>(resizingPolicy) )
+ : base_class( nCapacity, std::forward<resizing_policy>(resizingPolicy))
{}
/// Destructor destroys internal data
void operator()( set_type& set, iterator itWhat )
{
- set.insert( std::move( *itWhat ) );
+ set.insert( std::move( *itWhat ));
}
};
};
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val));
if ( res.second )
- f( const_cast<value_type&>(*res.first) );
+ f( const_cast<value_type&>(*res.first));
return res.second;
}
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val));
func( res.second, const_cast<value_type&>(*res.first), val );
return std::make_pair( true, res.second );
}
else {
auto it = m_Set.find( value_type( val ));
- if ( it == m_Set.end() )
+ if ( it == m_Set.end())
return std::make_pair( false, false );
func( false, const_cast<value_type&>(*it), val );
return std::make_pair( true, false );
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- const_iterator it = m_Set.find( value_type(key) );
- if ( it == m_Set.end() )
+ const_iterator it = m_Set.find( value_type(key));
+ if ( it == m_Set.end())
return false;
- f( const_cast<value_type&>(*it) );
+ f( const_cast<value_type&>(*it));
m_Set.erase( it );
return true;
}
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = m_Set.find( value_type(val) );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( value_type(val));
+ if ( it == m_Set.end())
return false;
f( const_cast<value_type&>(*it), val );
return true;
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- assert( m_Set.find( *itWhat ) == m_Set.end() );
+ assert( m_Set.find( *itWhat ) == m_Set.end());
copy_item()( m_Set, itWhat );
}
void operator()( map_type& map, iterator itWhat )
{
- std::pair< iterator, bool > ret = map.insert( pair_type( itWhat->first, typename pair_type::second_type() ));
+ std::pair< iterator, bool > ret = map.insert( pair_type( itWhat->first, typename pair_type::second_type()));
assert( ret.second ) ; // successful insertion
std::swap( ret.first->second, itWhat->second );
}
void operator()( map_type& map, iterator itWhat )
{
- map.insert( std::move( *itWhat ) );
+ map.insert( std::move( *itWhat ));
}
};
};
template <typename Q, typename Func>
bool insert( const Q& key, Func f )
{
- std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ) );
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type()) );
if ( res.second )
f( *res.first );
return res.second;
std::pair<bool, bool> update( const Q& key, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type() ));
+ std::pair<iterator, bool> res = m_Map.insert( value_type( key_type( key ), mapped_type()));
func( res.second, *res.first );
return std::make_pair( true, res.second );
}
else {
auto it = m_Map.find( key_type( key ));
- if ( it == end() )
+ if ( it == end())
return std::make_pair( false, false );
func( false, *it );
return std::make_pair( true, false );
bool erase( const Q& key, Func f )
{
iterator it = m_Map.find( key_type( key ));
- if ( it == m_Map.end() )
+ if ( it == m_Map.end())
return false;
f( *it );
m_Map.erase( it );
bool find( Q& val, Func f )
{
iterator it = m_Map.find( key_type( val ));
- if ( it == m_Map.end() )
+ if ( it == m_Map.end())
return false;
f( *it, val );
return true;
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- assert( m_Map.find( itWhat->first ) == m_Map.end() );
+ assert( m_Map.find( itWhat->first ) == m_Map.end());
copy_item()( m_Map, itWhat );
}
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- list.insert( itInsert, std::move( *itWhat ) );
+ list.insert( itInsert, std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( Q const& val, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 ) {
value_type newItem( val );
it = m_List.insert( it, newItem );
bool emplace( Args&&... args )
{
value_type val( std::forward<Args>(args)... );
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 ) {
- m_List.emplace( it, std::move( val ) );
+ m_List.emplace( it, std::move( val ));
return true;
}
return false;
template <typename Q, typename Func>
std::pair<bool, bool> update( Q const& val, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 ) {
// insert new
if ( !bAllowInsert )
template <typename Q, typename Func>
bool erase( Q const& key, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, *it ) != 0 )
return false;
bool erase( Q const& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, pred );
- if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, pred );
- if ( it == m_List.end() || pred( val, *it ) || pred( *it, val ) )
+ if ( it == m_List.end() || pred( val, *it ) || pred( *it, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate());
assert( it == m_List.end() || key_comparator()( *itWhat, *it ) != 0 );
copy_item()( m_List, it, itWhat );
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- list.insert_after( itInsert, std::move( *itWhat ) );
+ list.insert_after( itInsert, std::move( *itWhat ));
}
};
for ( iterator it = m_List.begin(); it != itEnd; ++it ) {
if ( pred( key, *it ))
itPrev = it;
- else if ( pred( *it, key ) )
+ else if ( pred( *it, key ))
break;
else
return std::make_pair( itPrev, true );
value_type val( std::forward<Args>(args)... );
std::pair< iterator, bool > pos = find_prev_item( val );
if ( !pos.second ) {
- m_List.emplace_after( pos.first, std::move( val ) );
+ m_List.emplace_after( pos.first, std::move( val ));
return true;
}
return false;
// key exists
iterator it = pos.first;
- f( *(++it) );
+ f( *(++it));
m_List.erase_after( pos.first );
return true;
// key exists
iterator it = pos.first;
- f( *(++it) );
+ f( *(++it));
m_List.erase_after( pos.first );
return true;
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
value_type newItem( val );
it = m_Vector.insert( it, newItem );
bool emplace( Args&&... args )
{
value_type val( std::forward<Args>(args)... );
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
- it = m_Vector.emplace( it, std::move( val ) );
+ it = m_Vector.emplace( it, std::move( val ));
return true;
}
return false;
template <typename Q, typename Func>
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
// insert new
if ( !bAllowInsert )
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, find_predicate());
if ( it == m_Vector.end() || key_comparator()( key, *it ) != 0 )
return false;
bool erase( const Q& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, pred );
- if ( it == m_Vector.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_Vector.end() || pred( key, *it ) || pred( *it, key ))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, pred );
- if ( it == m_Vector.end() || pred( val, *it ) || pred( *it, val ) )
+ if ( it == m_Vector.end() || pred( val, *it ) || pred( *it, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), *itWhat, find_predicate());
assert( it == m_Vector.end() || key_comparator()( *itWhat, *it ) != 0 );
copy_item()( m_Vector, it, itWhat );
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
value_type newItem( val );
it = m_Vector.insert( it, newItem );
bool emplace( Args&&... args )
{
value_type val( std::forward<Args>(args)... );
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
- it = m_Vector.emplace( it, std::move( val ) );
+ it = m_Vector.emplace( it, std::move( val ));
return true;
}
return false;
template <typename Q, typename Func>
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
// insert new
if ( !bAllowInsert )
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, find_predicate());
if ( it == m_Vector.end() || key_comparator()( key, *it ) != 0 )
return false;
bool erase( Q const& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, pred );
- if ( it == m_Vector.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_Vector.end() || pred( key, *it ) || pred( *it, key ))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, pred );
- if ( it == m_Vector.end() || pred( val, *it ) || pred( *it, val ) )
+ if ( it == m_Vector.end() || pred( val, *it ) || pred( *it, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), *itWhat, find_predicate());
assert( it == m_Vector.end() || key_comparator()( *itWhat, *it ) != 0 );
copy_item()( m_Vector, it, itWhat );
void operator()( set_type& set, iterator itWhat )
{
- set.insert( std::move( *itWhat ) );
+ set.insert( std::move( *itWhat ));
}
};
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val));
if ( res.second )
- f( const_cast<value_type&>(*res.first) );
+ f( const_cast<value_type&>(*res.first));
return res.second;
}
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val));
func( res.second, const_cast<value_type&>(*res.first), val );
return std::make_pair( true, res.second );
}
else {
auto it = m_Set.find( value_type(val));
- if ( it == m_Set.end() )
+ if ( it == m_Set.end())
return std::make_pair( false, false );
func( false, const_cast<value_type&>(*it), val );
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- const_iterator it = m_Set.find( value_type(key) );
- if ( it == m_Set.end() )
+ const_iterator it = m_Set.find( value_type(key));
+ if ( it == m_Set.end())
return false;
- f( const_cast<value_type&>(*it) );
+ f( const_cast<value_type&>(*it));
m_Set.erase( it );
return true;
}
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = m_Set.find( value_type(val) );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( value_type(val));
+ if ( it == m_Set.end())
return false;
f( const_cast<value_type&>(*it), val );
return true;
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- assert( m_Set.find( *itWhat ) == m_Set.end() );
+ assert( m_Set.find( *itWhat ) == m_Set.end());
copy_item()( m_Set, itWhat );
}
void operator()( list_type& list, iterator itInsert, iterator itWhat )
{
- list.insert( itInsert, std::move( *itWhat ) );
+ list.insert( itInsert, std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 ) {
value_type newItem( val );
it = m_List.insert( it, newItem );
bool emplace( Args&&... args )
{
value_type val(std::forward<Args>(args)...);
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 ) {
- it = m_List.emplace( it, std::move( val ) );
+ it = m_List.emplace( it, std::move( val ));
# if !defined(CDS_STD_LIST_SIZE_CXX11_CONFORM)
++m_nSize;
# endif
template <typename Q, typename Func>
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 ) {
// insert new
if ( !bAllowInsert )
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, find_predicate());
if ( it == m_List.end() || key_comparator()( key, *it ) != 0 )
return false;
bool erase( Q const& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), key, pred );
- if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, find_predicate());
if ( it == m_List.end() || key_comparator()( val, *it ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_List.begin(), m_List.end(), val, pred );
- if ( it == m_List.end() || pred( val, *it ) || pred( *it, val ) )
+ if ( it == m_List.end() || pred( val, *it ) || pred( *it, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_List.begin(), m_List.end(), *itWhat, find_predicate());
assert( it == m_List.end() || key_comparator()( *itWhat, *it ) != 0 );
copy_item()( m_List, it, itWhat );
void operator()( set_type& set, iterator itWhat )
{
- set.insert( std::move( *itWhat ) );
+ set.insert( std::move( *itWhat ));
}
};
} // namespace striped_set
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val));
if ( res.second )
- f( const_cast<value_type&>(*res.first) );
+ f( const_cast<value_type&>(*res.first));
return res.second;
}
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
if ( bAllowInsert ) {
- std::pair<iterator, bool> res = m_Set.insert( value_type(val) );
+ std::pair<iterator, bool> res = m_Set.insert( value_type(val));
func( res.second, const_cast<value_type&>(*res.first), val );
return std::make_pair( true, res.second );
}
else {
auto it = m_Set.find(value_type(val));
- if ( it == m_Set.end() )
+ if ( it == m_Set.end())
return std::make_pair( false, false );
func( false, const_cast<value_type&>(*it), val );
return std::make_pair( true, false );
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = m_Set.find( value_type(key) );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( value_type(key));
+ if ( it == m_Set.end())
return false;
- f( const_cast<value_type&>(*it) );
+ f( const_cast<value_type&>(*it));
m_Set.erase( it );
return true;
}
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = m_Set.find( value_type(val) );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( value_type(val));
+ if ( it == m_Set.end())
return false;
f( const_cast<value_type&>(*it), val );
return true;
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- assert( m_Set.find( *itWhat ) == m_Set.end() );
+ assert( m_Set.find( *itWhat ) == m_Set.end());
copy_item()( m_Set, itWhat );
}
template <typename Q, typename Func>
bool insert( const Q& val, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
value_type newItem( val );
it = m_Vector.insert( it, newItem );
#else
value_type val( std::forward<Args>(args)... );
#endif
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
- it = m_Vector.emplace( it, std::move( val ) );
+ it = m_Vector.emplace( it, std::move( val ));
return true;
}
return false;
template <typename Q, typename Func>
std::pair<bool, bool> update( const Q& val, Func func, bool bAllowInsert )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 ) {
// insert new
if ( !bAllowInsert )
template <typename Q, typename Func>
bool erase( const Q& key, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, find_predicate());
if ( it == m_Vector.end() || key_comparator()( key, *it ) != 0 )
return false;
bool erase( const Q& key, Less pred, Func f )
{
iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), key, pred );
- if ( it == m_Vector.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_Vector.end() || pred( key, *it ) || pred( *it, key ))
return false;
// key exists
template <typename Q, typename Func>
bool find( Q& val, Func f )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, find_predicate());
if ( it == m_Vector.end() || key_comparator()( val, *it ) != 0 )
return false;
bool find( Q& val, Less pred, Func f )
{
iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), val, pred );
- if ( it == m_Vector.end() || pred( val, *it ) || pred( *it, val ) )
+ if ( it == m_Vector.end() || pred( val, *it ) || pred( *it, val ))
return false;
// key exists
void move_item( adapted_container& /*from*/, iterator itWhat )
{
- iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), *itWhat, find_predicate() );
+ iterator it = std::lower_bound( m_Vector.begin(), m_Vector.end(), *itWhat, find_predicate());
assert( it == m_Vector.end() || key_comparator()( *itWhat, *it ) != 0 );
copy_item()( m_Vector, it, itWhat );
bool enqueue( value_type&& val )
{
scoped_node_ptr p( alloc_node_move( std::move( val )));
- if ( base_class::enqueue( *p ) ) {
+ if ( base_class::enqueue( *p )) {
p.release();
return true;
}
template <typename Func>
bool enqueue_with( Func f )
{
- scoped_node_ptr p( alloc_node() );
+ scoped_node_ptr p( alloc_node());
f( *p );
if ( base_class::enqueue( *p )) {
p.release();
}
else if (dif < 0) {
// Queue full?
- if ( pos - m_posDequeue.load( memory_model::memory_order_relaxed ) == capacity() )
+ if ( pos - m_posDequeue.load( memory_model::memory_order_relaxed ) == capacity())
return false; // queue full
bkoff();
pos = m_posEnqueue.load( memory_model::memory_order_relaxed );
void clear()
{
value_type v;
- while ( pop(v) );
+ while ( pop(v));
}
/// Returns queue's item count
equal to another type alignment. For example, the following declaration produces an error in Microsoft Visual Studio 2008 compiler:
\code
typedef double my_double;
- typedef __declspec(align( __alignof(my_double) )) int aligned_int;
+ typedef __declspec(align( __alignof(my_double))) int aligned_int;
\endcode
In MS VS, the __declspec(align(N)) construction requires that N must be a integer constant (1, 2, 4 and so on)
but not an integer constant expression.
--m_nCounter;
int nBit;
for ( nBit = m_nHighBit - 1; nBit >= 0; --nBit ) {
- if ( cds::bitop::complement( m_nReversed, nBit ) )
+ if ( cds::bitop::complement( m_nReversed, nBit ))
break;
}
if ( nBit < 0 ) {
return 0;
if ( x & 0xffffffffu )
return lsb32( (uint32_t) x );
- return lsb32( (uint32_t) (x >> 32) ) + 32;
+ return lsb32( (uint32_t) (x >> 32)) + 32;
}
#endif
static inline uint64_t rbo64( uint64_t x )
{
// Low 32bit Hight 32bit
- return ( static_cast<uint64_t>(rbo32( (uint32_t) x )) << 32 ) | ( static_cast<uint64_t>( rbo32( (uint32_t) (x >> 32) )));
+ return ( static_cast<uint64_t>(rbo32( (uint32_t) x )) << 32 ) | ( static_cast<uint64_t>( rbo32( (uint32_t) (x >> 32))));
}
#endif
# ifdef cds_beans_zbc64_DEFINED
return 64 - zbc64( x );
# else
- return sbc32( (uint32_t) (x >> 32) ) + sbc32( (uint32_t) x );
+ return sbc32( (uint32_t) (x >> 32)) + sbc32( (uint32_t) x );
# endif
}
#endif
explicit bounded_array(
size_t nCapacity ///< capacity
)
- : m_arr( allocator_impl().NewArray( nCapacity ) )
+ : m_arr( allocator_impl().NewArray( nCapacity ))
, m_nCapacity( nCapacity )
{}
~bounded_array()
{
- allocator_impl().Delete( m_arr, capacity() );
+ allocator_impl().Delete( m_arr, capacity());
}
const value_type& operator []( size_t nItem ) const
{
- assert( nItem < capacity() );
+ assert( nItem < capacity());
return m_arr[nItem];
}
value_type& operator []( size_t nItem )
{
- assert( nItem < capacity() );
+ assert( nItem < capacity());
return m_arr[nItem];
}
int plugin_entry_point()
{
// Attach the thread if it is not attached yet
- if ( !cds::threading::Manager::isThreadAttached() )
+ if ( !cds::threading::Manager::isThreadAttached())
cds::threading::Manager::attachThread();
// Do some work with HP-related containers
marked_ptr& operator &=( int nBits ) CDS_NOEXCEPT
{
assert( (nBits & pointer_bitmask) == 0 );
- m_ptr = to_ptr( to_int() & (pointer_bitmask | nBits) );
+ m_ptr = to_ptr( to_int() & (pointer_bitmask | nBits));
return *this;
}
{}
CDS_CONSTEXPR explicit atomic(marked_ptr val) CDS_NOEXCEPT
- : m_atomic( val.all() )
+ : m_atomic( val.all())
{}
CDS_CONSTEXPR explicit atomic(T * p) CDS_NOEXCEPT
: m_atomic( p )
do {
pLast->m_pNext.store( pHead, atomics::memory_order_relaxed );
// pHead is changed by compare_exchange_weak
- } while ( !m_pHead.compare_exchange_weak( pHead, pFirst, atomics::memory_order_release, atomics::memory_order_relaxed ) );
+ } while ( !m_pHead.compare_exchange_weak( pHead, pFirst, atomics::memory_order_release, atomics::memory_order_relaxed ));
return m_nItemCount.fetch_add( nSize, atomics::memory_order_relaxed ) + 1;
}
/**@anchor dhp_gc_retirePtr
*/
template <typename T>
- void retirePtr( T * p, void (* pFunc)(T *) )
+ void retirePtr( T * p, void (* pFunc)(T *))
{
- retirePtr( retired_ptr( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) ) );
+ retirePtr( retired_ptr( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc )) );
}
/// Places retired pointer \p into thread's array of retired pointer for deferred reclamation
void retirePtr( retired_ptr const& p )
{
- if ( m_RetiredBuffer.push( m_RetiredAllocator.alloc(p)) >= m_nLiberateThreshold.load(atomics::memory_order_relaxed) )
+ if ( m_RetiredBuffer.push( m_RetiredAllocator.alloc(p)) >= m_nLiberateThreshold.load(atomics::memory_order_relaxed))
scan();
}
public:
/// Default constructor
ThreadGC()
- : m_gc( GarbageCollector::instance() )
+ : m_gc( GarbageCollector::instance())
, m_pList( nullptr )
, m_pFree( nullptr )
{}
/// Places retired pointer \p and its deleter \p pFunc into list of retired pointer for deferred reclamation
template <typename T>
- void retirePtr( T * p, void (* pFunc)(T *) )
+ void retirePtr( T * p, void (* pFunc)(T *))
{
m_gc.retirePtr( p, pFunc );
}
/// Set vector size. Uses internally
void size( size_t nSize )
{
- assert( nSize <= capacity() );
+ assert( nSize <= capacity());
m_nSize = nSize;
}
/// Pushes retired pointer to the vector
void push( retired_ptr const& p )
{
- assert( m_nSize < capacity() );
+ assert( m_nSize < capacity());
m_arr[ m_nSize ] = p;
++m_nSize;
}
- /// Checks if the vector is full (size() == capacity() )
+ /// Checks if the vector is full (size() == capacity())
bool isFull() const CDS_NOEXCEPT
{
return m_nSize >= capacity();
~hplist_node()
{
assert( m_idOwner.load( atomics::memory_order_relaxed ) == OS::c_NullThreadId );
- assert( m_bFree.load(atomics::memory_order_relaxed) );
+ assert( m_bFree.load(atomics::memory_order_relaxed));
}
//@endcond
};
public:
/// Default constructor
ThreadGC()
- : m_HzpManager( GarbageCollector::instance() ),
+ : m_HzpManager( GarbageCollector::instance()),
m_pHzpRec( nullptr )
{}
/// Places retired pointer \p and its deleter \p pFunc into thread's array of retired pointer for deferred reclamation
template <typename T>
- void retirePtr( T * p, void (* pFunc)(T *) )
+ void retirePtr( T * p, void (* pFunc)(T *))
{
retirePtr( details::retired_ptr( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc )));
}
{
m_pHzpRec->m_arrRetired.push( p );
- if ( m_pHzpRec->m_arrRetired.isFull() ) {
+ if ( m_pHzpRec->m_arrRetired.isFull()) {
// Max of retired pointer count is reached. Do scan
scan();
}
namespace gc { namespace hp { namespace details {
inline retired_vector::retired_vector( const cds::gc::hp::GarbageCollector& HzpMgr )
- : m_arr( HzpMgr.getMaxRetiredPtrCount() ),
+ : m_arr( HzpMgr.getMaxRetiredPtrCount()),
m_nSize(0)
{}
inline hp_record::hp_record( const cds::gc::hp::GarbageCollector& HzpMgr )
- : m_hzp( HzpMgr.getHazardPointerCount() )
+ : m_hzp( HzpMgr.getHazardPointerCount())
, m_arrRetired( HzpMgr )
, m_nSync( 0 )
{}
hp_guard* release( size_t nIndex ) CDS_NOEXCEPT
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
hp_guard* p = m_arr[ nIndex ];
m_arr[ nIndex ] = nullptr;
/// Dtor
~hp_allocator()
{
- allocator_impl().Delete( m_arrHazardPtr, capacity() );
+ allocator_impl().Delete( m_arrHazardPtr, capacity());
}
/// Get capacity of array
/// Returns i-th hazard pointer
hp_guard& operator []( size_t i ) CDS_NOEXCEPT
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_arrHazardPtr[i];
}
assert( m_p );
m_funcFree( m_p );
- CDS_STRICT_DO( clear() );
+ CDS_STRICT_DO( clear());
}
/// Checks if the retired pointer is not empty
value_type * operator()( T * p );
};
\endcode
- Really, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
+ Really, the result of <tt> f( toGuard.load()) </tt> is assigned to the hazard pointer.
*/
template <typename T, class Func>
T protect( atomics::atomic<T> const& toGuard, Func f )
T pRet;
do {
pRet = pCur;
- assign( f( pCur ) );
+ assign( f( pCur ));
pCur = toGuard.load(atomics::memory_order_acquire);
} while ( pRet != pCur );
return pCur;
template <typename T, int BITMASK>
T* assign( cds::details::marked_ptr<T, BITMASK> p )
{
- return assign( p.ptr() );
+ return assign( p.ptr());
}
/// Copy from \p src guard to \p this guard
void copy( Guard const& src )
{
- assign( src.get_native() );
+ assign( src.get_native());
}
/// Clears value of the guard
template <typename T>
T * get() const
{
- return reinterpret_cast<T *>( get_native() );
+ return reinterpret_cast<T *>( get_native());
}
/// Gets native guarded pointer stored
{
T pRet;
do {
- pRet = assign( nIndex, toGuard.load(atomics::memory_order_acquire) );
+ pRet = assign( nIndex, toGuard.load(atomics::memory_order_acquire));
} while ( pRet != toGuard.load(atomics::memory_order_relaxed));
return pRet;
value_type * operator()( T * p );
};
\endcode
- Actually, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
+ Actually, the result of <tt> f( toGuard.load()) </tt> is assigned to the hazard pointer.
*/
template <typename T, class Func>
T protect( size_t nIndex, atomics::atomic<T> const& toGuard, Func f )
{
T pRet;
do {
- assign( nIndex, f( pRet = toGuard.load(atomics::memory_order_acquire) ));
+ assign( nIndex, f( pRet = toGuard.load(atomics::memory_order_acquire)));
} while ( pRet != toGuard.load(atomics::memory_order_relaxed));
return pRet;
template <typename T, int Bitmask>
T * assign( size_t nIndex, cds::details::marked_ptr<T, Bitmask> p )
{
- return assign( nIndex, p.ptr() );
+ return assign( nIndex, p.ptr());
}
/// Copy guarded value from \p src guard to slot at index \p nIndex
void copy( size_t nIndex, Guard const& src )
{
- assign( nIndex, src.get_native() );
+ assign( nIndex, src.get_native());
}
/// Copy guarded value from slot \p nSrcIndex to slot at index \p nDestIndex
/// Clear value of the slot \p nIndex
void clear( size_t nIndex )
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
assert( m_arr[nIndex] != nullptr );
m_arr[nIndex]->pPost.store( nullptr, atomics::memory_order_release );
template <typename T>
T * get( size_t nIndex ) const
{
- return reinterpret_cast<T *>( get_native( nIndex ) );
+ return reinterpret_cast<T *>( get_native( nIndex ));
}
/// Get native guarded pointer stored
guarded_pointer get_native( size_t nIndex ) const
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
assert( m_arr[nIndex] != nullptr );
return m_arr[nIndex]->pPost.load( atomics::memory_order_acquire );
//@cond
dhp::details::guard_data* release( size_t nIndex ) CDS_NOEXCEPT
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
dhp::details::guard_data* ret = m_arr[ nIndex ];
m_arr[nIndex] = nullptr;
/// Ctor from \p Guard
explicit guarded_ptr( Guard&& g ) CDS_NOEXCEPT
- : m_guard( g.release() )
+ : m_guard( g.release())
{}
/// The guarded pointer is not copy-constructible
/// Move-assignment from \p Guard
guarded_ptr& operator=( Guard&& g ) CDS_NOEXCEPT
{
- std::swap( m_guard, g.guard_ref() );
+ std::swap( m_guard, g.guard_ref());
return *this;
}
/// Returns a pointer to guarded value
value_type * operator ->() const CDS_NOEXCEPT
{
- assert( !empty() );
+ assert( !empty());
return value_cast()( reinterpret_cast<guarded_type *>(m_guard->get()));
}
/// Returns const reference to guarded value
value_type const& operator *() const CDS_NOEXCEPT
{
- assert( !empty() );
+ assert( !empty());
return *value_cast()(reinterpret_cast<guarded_type *>(m_guard->get()));
}
Deleting the pointer is the function \p pFunc call.
*/
template <typename T>
- static void retire( T * p, void (* pFunc)(T *) )
+ static void retire( T * p, void (* pFunc)(T *))
{
dhp::GarbageCollector::instance().retirePtr( p, pFunc );
}
)
: m_bPersistent( bPersistent )
{
- if ( !cds::threading::Manager::isThreadAttached() )
+ if ( !cds::threading::Manager::isThreadAttached())
cds::threading::Manager::attachThread();
}
value_type * operator()( T * p );
};
\endcode
- Actually, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
+ Actually, the result of <tt> f( toGuard.load()) </tt> is assigned to the hazard pointer.
@warning The guad object should be in linked state, otherwise the result is undefined
*/
T pRet;
do {
pRet = pCur;
- assign( f( pCur ) );
+ assign( f( pCur ));
pCur = toGuard.load(atomics::memory_order_acquire);
} while ( pRet != pCur );
return pCur;
/// Copy a value guarded from \p src guard to \p this guard (valid only in linked state)
void copy( Guard const& src )
{
- assign( src.get_native() );
+ assign( src.get_native());
}
/// Store marked pointer \p p to the guard
template <typename T>
T * get() const
{
- return reinterpret_cast<T *>( get_native() );
+ return reinterpret_cast<T *>( get_native());
}
/// Get native hazard pointer stored (valid only in linked state)
T pRet;
do {
- pRet = assign( nIndex, toGuard.load(atomics::memory_order_acquire) );
+ pRet = assign( nIndex, toGuard.load(atomics::memory_order_acquire));
} while ( pRet != toGuard.load(atomics::memory_order_acquire));
return pRet;
value_type * operator()( T * p );
};
\endcode
- Really, the result of <tt> f( toGuard.load() ) </tt> is assigned to the hazard pointer.
+ Really, the result of <tt> f( toGuard.load()) </tt> is assigned to the hazard pointer.
*/
template <typename T, class Func>
T protect( size_t nIndex, atomics::atomic<T> const& toGuard, Func f )
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
T pRet;
do {
- assign( nIndex, f( pRet = toGuard.load(atomics::memory_order_acquire) ));
+ assign( nIndex, f( pRet = toGuard.load(atomics::memory_order_acquire)));
} while ( pRet != toGuard.load(atomics::memory_order_acquire));
return pRet;
template <typename T, int BITMASK>
T * assign( size_t nIndex, cds::details::marked_ptr<T, BITMASK> p )
{
- return assign( nIndex, p.ptr() );
+ return assign( nIndex, p.ptr());
}
/// Copy guarded value from \p src guard to slot at index \p nIndex
void copy( size_t nIndex, Guard const& src )
{
- assign( nIndex, src.get_native() );
+ assign( nIndex, src.get_native());
}
/// Copy guarded value from slot \p nSrcIndex to slot at index \p nDestIndex
template <typename T>
T * get( size_t nIndex ) const
{
- return reinterpret_cast<T *>( get_native( nIndex ) );
+ return reinterpret_cast<T *>( get_native( nIndex ));
}
/// Get native hazard pointer stored
guarded_pointer get_native( size_t nIndex ) const
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
return m_arr[nIndex]->get();
}
/// Ctor from \p Guard
explicit guarded_ptr( Guard&& g ) CDS_NOEXCEPT
- : m_pGuard( g.release() )
+ : m_pGuard( g.release())
{}
/// The guarded pointer is not copy-constructible
/// Move-assignment from \p Guard
guarded_ptr& operator=( Guard&& g ) CDS_NOEXCEPT
{
- std::swap( m_pGuard, g.guard_ref() );
+ std::swap( m_pGuard, g.guard_ref());
return *this;
}
/// Returns a pointer to guarded value
value_type * operator ->() const CDS_NOEXCEPT
{
- assert( !empty() );
+ assert( !empty());
return value_cast()( reinterpret_cast<guarded_type *>(m_pGuard->get()));
}
/// Returns const reference to guarded value
value_type const& operator *() const CDS_NOEXCEPT
{
- assert( !empty() );
+ assert( !empty());
return *value_cast()(reinterpret_cast<guarded_type *>(m_pGuard->get()));
}
Deleting the pointer is the function \p pFunc call.
*/
template <typename T>
- static void retire( T * p, void (* pFunc)(T *) ); // inline in hp_impl.h
+ static void retire( T * p, void (* pFunc)(T *)); // inline in hp_impl.h
/// Retire pointer \p p with functor of type \p Disposer
/**
scan_type nScanType ///< new scan strategy
)
{
- hp::GarbageCollector::instance().setScanType( static_cast<hp::scan_type>(nScanType) );
+ hp::GarbageCollector::instance().setScanType( static_cast<hp::scan_type>(nScanType));
}
/// Checks if Hazard Pointer GC is constructed and may be used
)
: m_bPersistent( bPersistent )
{
- if ( !threading::Manager::isThreadAttached() )
+ if ( !threading::Manager::isThreadAttached())
threading::Manager::attachThread();
}
template <typename T>
inline T * HP::GuardArray<Count>::assign( size_t nIndex, T* p )
{
- assert( nIndex < capacity() );
+ assert( nIndex < capacity());
m_arr.set(nIndex, p);
hp::get_thread_gc().sync();
}
template <typename T>
- inline void HP::retire( T * p, void (* pFunc)(T *) )
+ inline void HP::retire( T * p, void (* pFunc)(T *))
{
cds::threading::getGC<HP>().retirePtr( p, pFunc );
}
{
CDS_UNUSED( nFeatureFlags );
- if ( cds::details::init_first_call() )
+ if ( cds::details::init_first_call())
{
cds::OS::topology::init();
cds::threading::ThreadData::s_nProcCount = cds::OS::topology::processor_count();
*/
static inline void Terminate()
{
- if ( cds::details::fini_last_call() ) {
+ if ( cds::details::fini_last_call()) {
cds::threading::Manager::fini();
cds::OS::topology::fini();
{
public:
// placeholder ctor
- lock_array(): lock_array_type( typename lock_array_type::select_cell_policy(2) ) {}
+ lock_array(): lock_array_type( typename lock_array_type::select_cell_policy(2)) {}
// real ctor
- lock_array( size_t nCapacity ): lock_array_type( nCapacity, typename lock_array_type::select_cell_policy(nCapacity) ) {}
+ lock_array( size_t nCapacity ): lock_array_type( nCapacity, typename lock_array_type::select_cell_policy(nCapacity)) {}
};
class scoped_lock: public std::unique_lock< lock_array_type >
if ( m_bLocked ) {
m_guard[0] = &(policy.m_Locks[0].at(nCell));
for ( unsigned int i = 1; i < c_nArity; ++i ) {
- m_guard[i] = &( policy.m_Locks[i].at( policy.m_Locks[i].lock( arrHash[i] )) );
+ m_guard[i] = &( policy.m_Locks[i].at( policy.m_Locks[i].lock( arrHash[i] )));
}
}
else {
lock_array_ptr create_lock_array( size_t nCapacity )
{
- return lock_array_ptr( lock_array_allocator().New( nCapacity ), lock_array_disposer() );
+ return lock_array_ptr( lock_array_allocator().New( nCapacity ), lock_array_disposer());
}
void acquire( size_t const * arrHash, lock_array_ptr * pLockArr, lock_type ** parrLock )
// wait while resizing
while ( true ) {
who = m_Owner.load( atomics::memory_order_acquire );
- if ( !( who & 1 ) || (who >> 1) == (me & c_nOwnerMask) )
+ if ( !( who & 1 ) || (who >> 1) == (me & c_nOwnerMask))
break;
bkoff();
m_Stat.onCellWaitResizing();
}
who = m_Owner.load( atomics::memory_order_acquire );
- if ( ( !(who & 1) || (who >> 1) == (me & c_nOwnerMask) ) && m_arrLocks[0] == pLockArr[0] ) {
+ if ( ( !(who & 1) || (who >> 1) == (me & c_nOwnerMask)) && m_arrLocks[0] == pLockArr[0] ) {
m_Stat.onCellLock();
return;
}
parrLock[0] = &(m_arrLocks[0]->at(nCell));
for ( unsigned int i = 1; i < c_nArity; ++i ) {
- parrLock[i] = &( m_arrLocks[i]->at( m_arrLocks[i]->lock( arrHash[i] & nMask)) );
+ parrLock[i] = &( m_arrLocks[i]->at( m_arrLocks[i]->lock( arrHash[i] & nMask)));
}
m_Stat.onSecondCellLock();
{
node_type * pPrev = itPrev.pNode;
node_type * pWhat = itWhat.pNode;
- assert( (!pPrev && pWhat == pHead) || (pPrev && pPrev->m_pNext == pWhat) );
+ assert( (!pPrev && pWhat == pHead) || (pPrev && pPrev->m_pNext == pWhat));
if ( pPrev )
pPrev->m_pNext = pWhat->m_pNext;
void allocate_bucket_tables( size_t nSize )
{
- assert( cds::beans::is_power2( nSize ) );
+ assert( cds::beans::is_power2( nSize ));
m_nBucketMask = nSize - 1;
bucket_table_allocator alloc;
unsigned int nTable = contains( arrPos, arrHash, val, pred );
if ( nTable != c_nUndefTable ) {
node_type& node = *arrPos[nTable].itFound;
- f( *node_traits::to_value_ptr(node) );
+ f( *node_traits::to_value_ptr(node));
bucket( nTable, arrHash[nTable]).remove( arrPos[nTable].itPrev, arrPos[nTable].itFound );
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
}
- pVal = node_traits::to_value_ptr( *refBucket.begin() );
+ pVal = node_traits::to_value_ptr( *refBucket.begin());
copy_hash( arrHash, *pVal );
scoped_cell_trylock guard2( m_MutexPolicy, arrHash );
- if ( !guard2.locked() )
+ if ( !guard2.locked())
continue ; // try one more time
- refBucket.remove( typename bucket_entry::iterator(), refBucket.begin() );
+ refBucket.remove( typename bucket_entry::iterator(), refBucket.begin());
unsigned int i = (nTable + 1) % c_nArity;
bucket_entry& bkt = bucket( i, arrHash[i] );
if ( bkt.size() < m_nProbesetThreshold ) {
position pos;
- contains_action::find( bkt, pos, i, arrHash[i], *pVal, key_predicate() ) ; // must return false!
+ contains_action::find( bkt, pos, i, arrHash[i], *pVal, key_predicate()) ; // must return false!
bkt.insert_after( pos.itPrev, node_traits::to_node_ptr( pVal ));
m_Stat.onSuccessRelocateRound();
return true;
bucket_entry& bkt = bucket( i, arrHash[i] );
if ( bkt.size() < m_nProbesetSize ) {
position pos;
- contains_action::find( bkt, pos, i, arrHash[i], *pVal, key_predicate() ) ; // must return false!
+ contains_action::find( bkt, pos, i, arrHash[i], *pVal, key_predicate()) ; // must return false!
bkt.insert_after( pos.itPrev, node_traits::to_node_ptr( pVal ));
nTable = i;
memcpy( arrGoalHash, arrHash, sizeof(arrHash));
{
scoped_resize_lock guard( m_MutexPolicy );
- if ( nOldCapacity != bucket_count() ) {
+ if ( nOldCapacity != bucket_count()) {
m_Stat.onFalseResizeCall();
return;
}
value_type& val = *node_traits::to_value_ptr( *it );
copy_hash( arrHash, val );
- contains( arrPos, arrHash, val, key_predicate() ) ; // must return c_nUndefTable
+ contains( arrPos, arrHash, val, key_predicate()) ; // must return c_nUndefTable
for ( unsigned int i = 0; i < c_nArity; ++i ) {
bucket_entry& refBucket = bucket( i, arrHash[i] );
if ( refBucket.size() < m_nProbesetSize ) {
refBucket.insert_after( arrPos[i].itPrev, &*it );
assert( refBucket.size() > 1 );
- copy_hash( arrHash, *node_traits::to_value_ptr( *refBucket.begin()) );
+ copy_hash( arrHash, *node_traits::to_value_ptr( *refBucket.begin()));
m_Stat.onResizeRelocateCall();
relocate( i, arrHash );
break;
Probe set threshold = probe set size - 1
*/
CuckooSet()
- : m_nProbesetSize( calc_probeset_size(0) )
+ : m_nProbesetSize( calc_probeset_size(0))
, m_nProbesetThreshold( m_nProbesetSize - 1 )
, m_MutexPolicy( c_nDefaultInitialSize )
{
, unsigned int nProbesetSize ///< probe set size
, unsigned int nProbesetThreshold = 0 ///< probe set threshold, <tt>nProbesetThreshold < nProbesetSize</tt>. If 0, <tt>nProbesetThreshold = nProbesetSize - 1</tt>
)
- : m_nProbesetSize( calc_probeset_size(nProbesetSize) )
+ : m_nProbesetSize( calc_probeset_size(nProbesetSize))
, m_nProbesetThreshold( nProbesetThreshold ? nProbesetThreshold : m_nProbesetSize - 1 )
, m_MutexPolicy( cds::beans::ceil2(nInitialSize ? nInitialSize : c_nDefaultInitialSize ))
{
CuckooSet(
hash_tuple_type const& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : m_nProbesetSize( calc_probeset_size(0) )
+ : m_nProbesetSize( calc_probeset_size(0))
, m_nProbesetThreshold( m_nProbesetSize -1 )
, m_Hash( h )
, m_MutexPolicy( c_nDefaultInitialSize )
, unsigned int nProbesetThreshold ///< probe set threshold, <tt>nProbesetThreshold < nProbesetSize</tt>. If 0, <tt>nProbesetThreshold = nProbesetSize - 1</tt>
, hash_tuple_type const& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : m_nProbesetSize( calc_probeset_size(nProbesetSize) )
+ : m_nProbesetSize( calc_probeset_size(nProbesetSize))
, m_nProbesetThreshold( nProbesetThreshold ? nProbesetThreshold : m_nProbesetSize - 1)
, m_Hash( h )
, m_MutexPolicy( cds::beans::ceil2(nInitialSize ? nInitialSize : c_nDefaultInitialSize ))
CuckooSet(
hash_tuple_type&& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : m_nProbesetSize( calc_probeset_size(0) )
+ : m_nProbesetSize( calc_probeset_size(0))
, m_nProbesetThreshold( m_nProbesetSize / 2 )
- , m_Hash( std::forward<hash_tuple_type>(h) )
+ , m_Hash( std::forward<hash_tuple_type>(h))
, m_MutexPolicy( c_nDefaultInitialSize )
{
check_common_constraints();
, unsigned int nProbesetThreshold ///< probe set threshold, <tt>nProbesetThreshold < nProbesetSize</tt>. If 0, <tt>nProbesetThreshold = nProbesetSize - 1</tt>
, hash_tuple_type&& h ///< hash functor tuple of type <tt>std::tuple<H1, H2, ... Hn></tt> where <tt> n == \ref c_nArity </tt>
)
- : m_nProbesetSize( calc_probeset_size(nProbesetSize) )
+ : m_nProbesetSize( calc_probeset_size(nProbesetSize))
, m_nProbesetThreshold( nProbesetThreshold ? nProbesetThreshold : m_nProbesetSize - 1)
- , m_Hash( std::forward<hash_tuple_type>(h) )
+ , m_Hash( std::forward<hash_tuple_type>(h))
, m_MutexPolicy( cds::beans::ceil2(nInitialSize ? nInitialSize : c_nDefaultInitialSize ))
{
check_common_constraints();
{
scoped_cell_lock guard( m_MutexPolicy, arrHash );
- if ( contains( arrPos, arrHash, val, key_predicate() ) != c_nUndefTable ) {
+ if ( contains( arrPos, arrHash, val, key_predicate()) != c_nUndefTable ) {
m_Stat.onInsertFailed();
return false;
}
++m_ItemCounter;
nGoalTable = i;
assert( refBucket.size() > 1 );
- copy_hash( arrHash, *node_traits::to_value_ptr( *refBucket.begin()) );
+ copy_hash( arrHash, *node_traits::to_value_ptr( *refBucket.begin()));
goto do_relocate;
}
}
{
scoped_cell_lock guard( m_MutexPolicy, arrHash );
- unsigned int nTable = contains( arrPos, arrHash, val, key_predicate() );
+ unsigned int nTable = contains( arrPos, arrHash, val, key_predicate());
if ( nTable != c_nUndefTable ) {
func( false, *node_traits::to_value_ptr( *arrPos[nTable].itFound ), val );
m_Stat.onUpdateExist();
++m_ItemCounter;
nGoalTable = i;
assert( refBucket.size() > 1 );
- copy_hash( arrHash, *node_traits::to_value_ptr( *refBucket.begin()) );
+ copy_hash( arrHash, *node_traits::to_value_ptr( *refBucket.begin()));
goto do_relocate;
}
}
{
scoped_cell_lock guard( m_MutexPolicy, arrHash );
- unsigned int nTable = contains( arrPos, arrHash, val, key_predicate() );
+ unsigned int nTable = contains( arrPos, arrHash, val, key_predicate());
if ( nTable != c_nUndefTable && node_traits::to_value_ptr(*arrPos[nTable].itFound) == &val ) {
bucket( nTable, arrHash[nTable]).remove( arrPos[nTable].itPrev, arrPos[nTable].itFound );
--m_ItemCounter;
*/
void clear()
{
- clear_and_dispose( disposer() );
+ clear_and_dispose( disposer());
}
/// Clears the set and calls \p disposer for each item
: base_class( true )
, m_pLeft( nullptr )
, m_pRight( nullptr )
- , m_pUpdate( update_ptr() )
+ , m_pUpdate( update_ptr())
, m_nEmptyUpdate(0)
{}
//@cond
update_ptr null_update_desc()
{
- return update_ptr( reinterpret_cast<update_desc_type *>( (++m_nEmptyUpdate << 2) & 0xFFFF ) );
+ return update_ptr( reinterpret_cast<update_desc_type *>( (++m_nEmptyUpdate << 2) & 0xFFFF ));
}
base_class * get_child( bool bRight, atomics::memory_order mo ) const
template <typename LeafNode>
int operator()( internal_node<key_type, LeafNode> const& n1, internal_node<key_type, LeafNode> const& n2 ) const
{
- if ( n1.infinite_key() )
+ if ( n1.infinite_key())
return n2.infinite_key() ? n1.infinite_key() - n2.infinite_key() : 1;
- else if ( n2.infinite_key() )
+ else if ( n2.infinite_key())
return -1;
return operator()( n1.m_Key, n2.m_Key );
}
template <typename LeafNode, typename Q>
int operator()( internal_node<key_type, LeafNode> const& n, Q const& v ) const
{
- if ( n.infinite_key() )
+ if ( n.infinite_key())
return 1;
return operator()( n.m_Key, v );
}
template <typename LeafNode, typename Q>
int operator()( Q const& v, internal_node<key_type, LeafNode> const& n ) const
{
- if ( n.infinite_key() )
+ if ( n.infinite_key())
return -1;
return operator()( v, n.m_Key );
}
template <typename GC, typename Tag>
int operator()( node<GC, Tag> const& n1, node<GC, Tag> const& n2 ) const
{
- if ( n1.infinite_key() != n2.infinite_key() )
+ if ( n1.infinite_key() != n2.infinite_key())
return n1.infinite_key() - n2.infinite_key();
return operator()( *node_traits::to_value_ptr( n1 ), *node_traits::to_value_ptr( n2 ));
}
template <typename GC, typename Tag, typename Q>
int operator()( node<GC, Tag> const& n, Q const& v ) const
{
- if ( n.infinite_key() )
+ if ( n.infinite_key())
return 1;
return operator()( *node_traits::to_value_ptr( n ), v );
}
template <typename GC, typename Tag, typename Q>
int operator()( Q const& v, node<GC, Tag> const& n ) const
{
- if ( n.infinite_key() )
+ if ( n.infinite_key())
return -1;
- return operator()( v, *node_traits::to_value_ptr( n ) );
+ return operator()( v, *node_traits::to_value_ptr( n ));
}
template <typename GC>
int operator()( base_node<GC> const& n1, base_node<GC> const& n2 ) const
{
- if ( n1.infinite_key() != n2.infinite_key() )
+ if ( n1.infinite_key() != n2.infinite_key())
return n1.infinite_key() - n2.infinite_key();
- if ( n1.is_leaf() ) {
- if ( n2.is_leaf() )
+ if ( n1.is_leaf()) {
+ if ( n2.is_leaf())
return operator()( node_traits::to_leaf_node( n1 ), node_traits::to_leaf_node( n2 ));
else
return operator()( node_traits::to_leaf_node( n1 ), node_traits::to_internal_node( n2 ));
}
- if ( n2.is_leaf() )
+ if ( n2.is_leaf())
return operator()( node_traits::to_internal_node( n1 ), node_traits::to_leaf_node( n2 ));
else
return operator()( node_traits::to_internal_node( n1 ), node_traits::to_internal_node( n2 ));
{
if ( n.infinite_key())
return 1;
- if ( n.is_leaf() )
+ if ( n.is_leaf())
return operator()( node_traits::to_leaf_node( n ), v );
return operator()( node_traits::to_internal_node( n ), v );
}
template <typename GC, typename LeafNode >
int operator()( base_node<GC> const& i, internal_node<key_type, LeafNode> const& n ) const
{
- if ( i.is_leaf() )
+ if ( i.is_leaf())
return operator()( static_cast<LeafNode const&>(i), n );
return operator()( static_cast<internal_node<key_type, LeafNode> const&>(i), n );
}
template <typename GC, typename Tag >
int operator()( node<GC, Tag> const& n, internal_node<key_type, node<GC, Tag> > const& i ) const
{
- if ( !n.infinite_key() ) {
- if ( i.infinite_key() )
+ if ( !n.infinite_key()) {
+ if ( i.infinite_key())
return -1;
return operator()( n, i.m_Key );
}
void next()
{
if ( m_pCurBucket < m_pEndBucket ) {
- if ( ++m_itList != m_pCurBucket->end() )
+ if ( ++m_itList != m_pCurBucket->end())
return;
while ( ++m_pCurBucket < m_pEndBucket ) {
m_itList = m_pCurBucket->begin();
- if ( m_itList != m_pCurBucket->end() )
+ if ( m_itList != m_pCurBucket->end())
return;
}
}
, m_itList( it )
, m_pEndBucket( pLast )
{
- if ( it == pFirst->end() )
+ if ( it == pFirst->end())
next();
}
/// Access to element of next pointer array
atomic_marked_ptr& next( unsigned int nLevel )
{
- assert( nLevel < height() );
- assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr) );
+ assert( nLevel < height());
+ assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr));
# ifdef CDS_THREAD_SANITIZER_ENABLED
// TSan false positive: m_arrNext is read-only array
/// Access to element of next pointer array (const version)
atomic_marked_ptr const& next( unsigned int nLevel ) const
{
- assert( nLevel < height() );
+ assert( nLevel < height());
assert( nLevel == 0 || nLevel > 0 && m_arrNext != nullptr );
# ifdef CDS_THREAD_SANITIZER_ENABLED
static node_type * make_tower( node_type * pNode, unsigned int nHeight )
{
if ( nHeight > 1 )
- pNode->make_tower( nHeight, tower_allocator().NewArray( nHeight - 1, nullptr ) );
+ pNode->make_tower( nHeight, tower_allocator().NewArray( nHeight - 1, nullptr ));
return pNode;
}
hash_node()
: m_nHash( 0 )
{
- assert( is_dummy() );
+ assert( is_dummy());
}
/// Initializes dummy node with \p nHash value
hash_node( size_t nHash )
: m_nHash( nHash )
{
- assert( is_dummy() );
+ assert( is_dummy());
}
/// Checks if the node is dummy node
node()
: hash_node(0)
{
- assert( is_dummy() );
+ assert( is_dummy());
}
/// Initializes dummy node with \p nHash value
node( size_t nHash )
: hash_node( nHash )
{
- assert( is_dummy() );
+ assert( is_dummy());
}
/// Checks if the node is dummy node
node()
: hash_node( 0 )
{
- assert( is_dummy() );
+ assert( is_dummy());
}
/// Initializes dummy node with \p nHash value
node( size_t nHash )
: hash_node( nHash )
{
- assert( is_dummy() );
+ assert( is_dummy());
}
/// Checks if the node is dummy node
size_t nLoadFactor ///< Load factor
)
: m_nLoadFactor( nLoadFactor > 0 ? nLoadFactor : (size_t) 1 )
- , m_nCapacity( cds::beans::ceil2( nItemCount / m_nLoadFactor ) )
+ , m_nCapacity( cds::beans::ceil2( nItemCount / m_nLoadFactor ))
, m_nAuxNodeAllocated( 0 )
{
// m_nCapacity must be power of 2
- assert( cds::beans::is_power2( m_nCapacity ) );
+ assert( cds::beans::is_power2( m_nCapacity ));
allocate_table();
}
/// Returns head node of bucket \p nBucket
aux_node_type * bucket( size_t nBucket ) const
{
- assert( nBucket < capacity() );
+ assert( nBucket < capacity());
return m_Table[ nBucket ].load(memory_model::memory_order_acquire);
}
/// Set \p pNode as a head of bucket \p nBucket
void bucket( size_t nBucket, aux_node_type * pNode )
{
- assert( nBucket < capacity() );
+ assert( nBucket < capacity());
assert( bucket( nBucket ) == nullptr );
m_Table[ nBucket ].store( pNode, memory_model::memory_order_release );
/// Allocates auxiliary node; can return \p nullptr if the table exhausted
aux_node_type* alloc_aux_node()
{
- if ( m_nAuxNodeAllocated.load( memory_model::memory_order_relaxed ) < capacity() ) {
+ if ( m_nAuxNodeAllocated.load( memory_model::memory_order_relaxed ) < capacity()) {
// alloc next free node from m_auxNode
size_t const idx = m_nAuxNodeAllocated.fetch_add( 1, memory_model::memory_order_relaxed );
- if ( idx < capacity() )
+ if ( idx < capacity())
return new( &m_auxNode[idx] ) aux_node_type();
}
metrics()
: nSegmentCount( 1024 )
, nSegmentSize( 512 )
- , nSegmentSizeLog2( cds::beans::log2( nSegmentSize ) )
+ , nSegmentSizeLog2( cds::beans::log2( nSegmentSize ))
, nLoadFactor( 1 )
, nCapacity( nSegmentCount * nSegmentSize )
{}
aux_node_segment* new_aux_segment = allocate_aux_segment();
new_aux_segment->aux_node_count.fetch_add( 1, memory_model::memory_order_relaxed );
if ( m_auxNodeList.compare_exchange_strong( aux_segment, new_aux_segment, memory_model::memory_order_relaxed, atomics::memory_order_relaxed ))
- return new( new_aux_segment->segment() ) aux_node_type();
+ return new( new_aux_segment->segment()) aux_node_type();
free_aux_segment( new_aux_segment );
}
void init()
{
// m_nSegmentSize must be 2**N
- assert( cds::beans::is_power2( m_metrics.nSegmentSize ) );
+ assert( cds::beans::is_power2( m_metrics.nSegmentSize ));
assert( (((size_t)1) << m_metrics.nSegmentSizeLog2) == m_metrics.nSegmentSize );
// m_nSegmentCount must be 2**K
- assert( cds::beans::is_power2( m_metrics.nSegmentCount ) );
+ assert( cds::beans::is_power2( m_metrics.nSegmentCount ));
m_Segments = allocate_table();
m_auxNodeList = allocate_aux_segment();
if ( n1->m_nHash != n2->m_nHash )
return n1->m_nHash < n2->m_nHash ? -1 : 1;
- if ( n1->is_dummy() ) {
- assert( n2->is_dummy() );
+ if ( n1->is_dummy()) {
+ assert( n2->is_dummy());
return 0;
}
- assert( !n1->is_dummy() && !n2->is_dummy() );
+ assert( !n1->is_dummy() && !n2->is_dummy());
return native_key_comparator()(v1, v2);
}
if ( n->m_nHash != q.nHash )
return n->m_nHash < q.nHash ? -1 : 1;
- assert( !n->is_dummy() );
+ assert( !n->is_dummy());
return native_key_comparator()(v, q.val);
}
void operator()( value_type * v )
{
splitlist_node_type * p = static_cast<splitlist_node_type *>(native_node_traits::to_node_ptr( v ));
- if ( !p->is_dummy() )
+ if ( !p->is_dummy())
native_disposer()(v);
}
};
/// Convert node reference to value pointer
static value_type * to_value_ptr( node_type& n )
{
- return base_class::to_value_ptr( static_cast<base_node_type &>(n) );
+ return base_class::to_value_ptr( static_cast<base_node_type &>(n));
}
/// Convert node pointer to value pointer
static value_type * to_value_ptr( node_type * n )
{
- return base_class::to_value_ptr( static_cast<base_node_type *>(n) );
+ return base_class::to_value_ptr( static_cast<base_node_type *>(n));
}
/// Convert node reference to value pointer (const version)
static const value_type * to_value_ptr( node_type const & n )
{
- return base_class::to_value_ptr( static_cast<base_node_type const &>(n) );
+ return base_class::to_value_ptr( static_cast<base_node_type const &>(n));
}
/// Convert node pointer to value pointer (const version)
static const value_type * to_value_ptr( node_type const * n )
{
- return base_class::to_value_ptr( static_cast<base_node_type const *>(n) );
+ return base_class::to_value_ptr( static_cast<base_node_type const *>(n));
}
};
if ( n->m_nHash != q.nHash )
return n->m_nHash < q.nHash ? -1 : 1;
- assert( !n->is_dummy() );
+ assert( !n->is_dummy());
return base_class()(v, q.val);
}
if ( n->m_nHash != q.nHash )
return q.nHash < n->m_nHash ? -1 : 1;
- assert( !n->is_dummy() );
+ assert( !n->is_dummy());
return base_class()(q.val, v);
}
if ( n1.m_nHash != n2.m_nHash )
return n1.m_nHash < n2.m_nHash ? -1 : 1;
- if ( n1.is_dummy() ) {
- assert( n2.is_dummy() );
+ if ( n1.is_dummy()) {
+ assert( n2.is_dummy());
return 0;
}
- assert( !n1.is_dummy() && !n2.is_dummy() );
+ assert( !n1.is_dummy() && !n2.is_dummy());
return native_key_comparator()(v1, v2);
}
if ( n.m_nHash != q.nHash )
return n.m_nHash < q.nHash ? -1 : 1;
- assert( !n.is_dummy() );
+ assert( !n.is_dummy());
return native_key_comparator()(v, q.val);
}
void operator()( value_type * v )
{
hash_node* p = static_cast<hash_node*>( v );
- if ( !p->is_dummy() )
+ if ( !p->is_dummy())
native_disposer()(v);
}
};
if ( n.m_nHash != q.nHash )
return n.m_nHash < q.nHash ? -1 : 1;
- assert( !n.is_dummy() );
+ assert( !n.is_dummy());
return base_class()(v, q.val);
}
if ( n.m_nHash != q.nHash )
return q.nHash < n.m_nHash ? -1 : 1;
- assert( !n.is_dummy() );
+ assert( !n.is_dummy());
return base_class()(q.val, v);
}
, m_itEnd( itEnd )
{
// skip dummy nodes
- while ( m_itCur != m_itEnd && node_traits::to_node_ptr( *m_itCur )->is_dummy() )
+ while ( m_itCur != m_itEnd && node_traits::to_node_ptr( *m_itCur )->is_dummy())
++m_itCur;
}
if ( m_itCur != m_itEnd ) {
do {
++m_itCur;
- } while ( m_itCur != m_itEnd && node_traits::to_node_ptr( *m_itCur )->is_dummy() );
+ } while ( m_itCur != m_itEnd && node_traits::to_node_ptr( *m_itCur )->is_dummy());
}
return *this;
}
else
m_FlatCombining.combine( op_enq, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onEnqueue();
return true;
else
m_FlatCombining.combine( op_deq, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onDequeue( pRec->bEmpty );
else
m_FlatCombining.combine( bDispose ? op_clear_and_dispose : op_clear, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
}
// All TSan warnings are false positive
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
- switch ( pRec->op() ) {
+ switch ( pRec->op()) {
case op_enq:
assert( pRec->pVal );
- m_Queue.push_back( *(pRec->pVal ) );
+ m_Queue.push_back( *(pRec->pVal ));
break;
case op_deq:
pRec->bEmpty = m_Queue.empty();
m_Queue.clear();
break;
case op_clear_and_dispose:
- m_Queue.clear_and_dispose( disposer() );
+ m_Queue.clear_and_dispose( disposer());
break;
default:
assert(false);
typedef typename fc_kernel::iterator fc_iterator;
for ( fc_iterator it = itBegin, itPrev = itEnd; it != itEnd; ++it ) {
- switch ( it->op() ) {
+ switch ( it->op()) {
case op_enq:
case op_deq:
- if ( m_Queue.empty() ) {
+ if ( m_Queue.empty()) {
if ( itPrev != itEnd && collide( *itPrev, *it ))
itPrev = itEnd;
else
//@cond
bool collide( fc_record& rec1, fc_record& rec2 )
{
- assert( m_Queue.empty() );
+ assert( m_Queue.empty());
- switch ( rec1.op() ) {
+ switch ( rec1.op()) {
case op_enq:
if ( rec2.op() == op_deq ) {
assert(rec1.pVal);
else
m_FlatCombining.combine( op_push, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPush();
return true;
else
m_FlatCombining.combine( op_pop, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
m_FlatCombining.internal_statistics().onPop( pRec->bEmpty );
else
m_FlatCombining.combine( bDispose ? op_clear_and_dispose : op_clear, pRec, *this );
- assert( pRec->is_done() );
+ assert( pRec->is_done());
m_FlatCombining.release_record( pRec );
}
// this function is called under FC mutex, so switch TSan off
CDS_TSAN_ANNOTATE_IGNORE_RW_BEGIN;
- switch ( pRec->op() ) {
+ switch ( pRec->op()) {
case op_push:
assert( pRec->pVal );
- m_Stack.push_front( *(pRec->pVal ) );
+ m_Stack.push_front( *(pRec->pVal ));
break;
case op_pop:
pRec->bEmpty = m_Stack.empty();
m_Stack.clear();
break;
case op_clear_and_dispose:
- m_Stack.clear_and_dispose( disposer() );
+ m_Stack.clear_and_dispose( disposer());
break;
default:
assert(false);
typedef typename fc_kernel::iterator fc_iterator;
for ( fc_iterator it = itBegin, itPrev = itEnd; it != itEnd; ++it ) {
- switch ( it->op() ) {
+ switch ( it->op()) {
case op_push:
case op_pop:
if ( itPrev != itEnd && collide( *itPrev, *it ))
//@cond
bool collide( fc_record& rec1, fc_record& rec2 )
{
- switch ( rec1.op() ) {
+ switch ( rec1.op()) {
case op_push:
if ( rec2.op() == op_pop ) {
assert(rec1.pVal);
*/
~FreeList()
{
- assert( empty() );
+ assert( empty());
}
/// Puts \p pNode to the free list
to put that item into the cache if its corresponding slot is empty. The slot is calculated by
current thread id:
\code
- int slot = std::hash<std::thread::id>()( std::this_thread::get_id() ) & (CacheSize - 1);
+ int slot = std::hash<std::thread::id>()( std::this_thread::get_id()) & (CacheSize - 1);
\endcode
When getting the free-list checks the corresponding cache slot. If it is not empty, its
/// Checks whether the free list is empty
bool empty() const
{
- if ( !m_freeList.empty() )
+ if ( !m_freeList.empty())
return false;
for ( auto& cell : m_cache ) {
//@cond
size_t get_hash()
{
- return std::hash<std::thread::id>()( std::this_thread::get_id() ) & (c_cache_size - 1);
+ return std::hash<std::thread::id>()( std::this_thread::get_id()) & (c_cache_size - 1);
}
//@endcond
private:
*/
~TaggedFreeList()
{
- assert( empty() );
+ assert( empty());
}
/// Puts \p pNode to the free list
{
static internal_node const& to_internal_node( tree_node const& n )
{
- assert( n.is_internal() );
+ assert( n.is_internal());
return static_cast<internal_node const&>( n );
}
static leaf_node const& to_leaf_node( tree_node const& n )
{
- assert( n.is_leaf() );
+ assert( n.is_leaf());
return static_cast<leaf_node const&>( n );
}
};
void retire_node( tree_node * pNode ) const
{
- if ( pNode->is_leaf() ) {
+ if ( pNode->is_leaf()) {
assert( static_cast<leaf_node *>( pNode ) != &m_LeafInf1 );
assert( static_cast<leaf_node *>( pNode ) != &m_LeafInf2 );
back_off bkoff;
for ( ;; ) {
- if ( search( res, val, node_compare() )) {
- if ( pNewInternal.get() )
+ if ( search( res, val, node_compare())) {
+ if ( pNewInternal.get())
m_Stat.onInternalNodeDeleted() ; // unique_internal_node_ptr deletes internal node
m_Stat.onInsertFailed();
return false;
if ( res.updGrandParent.bits() == update_desc::Clean && res.updParent.bits() == update_desc::Clean ) {
- if ( !pNewInternal.get() )
- pNewInternal.reset( alloc_internal_node() );
+ if ( !pNewInternal.get())
+ pNewInternal.reset( alloc_internal_node());
if ( try_insert( val, pNewInternal.get(), res )) {
f( val );
back_off bkoff;
for ( ;; ) {
- if ( search( res, val, node_compare() )) {
+ if ( search( res, val, node_compare())) {
func( false, *node_traits::to_value_ptr( res.pLeaf ), val );
- if ( pNewInternal.get() )
+ if ( pNewInternal.get())
m_Stat.onInternalNodeDeleted() ; // unique_internal_node_ptr deletes internal node
m_Stat.onUpdateExist();
return std::make_pair( true, false );
if ( !bAllowInsert )
return std::make_pair( false, false );
- if ( !pNewInternal.get() )
- pNewInternal.reset( alloc_internal_node() );
+ if ( !pNewInternal.get())
+ pNewInternal.reset( alloc_internal_node());
if ( try_insert( val, pNewInternal.get(), res )) {
func( true, val, val );
bool contains( Q const& key ) const
{
search_result res;
- if ( search( res, key, node_compare() )) {
+ if ( search( res, key, node_compare())) {
m_Stat.onFindSuccess();
return true;
}
> compare_functor;
search_result res;
- if ( search( res, key, compare_functor() )) {
+ if ( search( res, key, compare_functor())) {
m_Stat.onFindSuccess();
return true;
}
this sequence
\code
tree.clear();
- assert( tree.empty() );
+ assert( tree.empty());
\endcode
the assertion could be raised.
tree_node * pLeaf = const_cast<internal_node *>( &m_Root );
// Get leftmost leaf
- while ( pLeaf->is_internal() ) {
+ while ( pLeaf->is_internal()) {
pGrandParent = pParent;
pParent = static_cast<internal_node *>( pLeaf );
pLeaf = pParent->m_pLeft.load( memory_model::memory_order_relaxed );
// Remove leftmost leaf and its parent node
assert( pGrandParent );
assert( pParent );
- assert( pLeaf->is_leaf() );
+ assert( pLeaf->is_leaf());
pGrandParent->m_pLeft.store( pParent->m_pRight.load( memory_model::memory_order_relaxed ), memory_model::memory_order_relaxed );
- free_leaf_node( node_traits::to_value_ptr( static_cast<leaf_node *>( pLeaf ) ) );
+ free_leaf_node( node_traits::to_value_ptr( static_cast<leaf_node *>( pLeaf )) );
free_internal_node( pParent );
}
}
&& node_compare()( *pLeft, *pRight ) < 0 )
{
bool bRet = true;
- if ( pLeft->is_internal() )
- bRet = check_consistency( static_cast<internal_node *>( pLeft ) );
+ if ( pLeft->is_internal())
+ bRet = check_consistency( static_cast<internal_node *>( pLeft ));
assert( bRet );
- if ( bRet && pRight->is_internal() )
+ if ( bRet && pRight->is_internal())
bRet = bRet && check_consistency( static_cast<internal_node *>( pRight ));
assert( bRet );
updParent = nullptr;
bRightLeaf = false;
tree_node * pLeaf = const_cast<internal_node *>( &m_Root );
- while ( pLeaf->is_internal() ) {
+ while ( pLeaf->is_internal()) {
res.guards.copy( search_result::Guard_GrandParent, search_result::Guard_Parent );
pGrandParent = pParent;
res.guards.copy( search_result::Guard_Parent, search_result::Guard_Leaf );
updParent = search_protect_update( res, pParent->m_pUpdate );
- switch ( updParent.bits() ) {
+ switch ( updParent.bits()) {
case update_desc::DFlag:
case update_desc::Mark:
m_Stat.onSearchRetry();
}
}
- assert( pLeaf->is_leaf() );
- nCmp = cmp( key, *static_cast<leaf_node *>(pLeaf) );
+ assert( pLeaf->is_leaf());
+ nCmp = cmp( key, *static_cast<leaf_node *>(pLeaf));
res.pGrandParent = pGrandParent;
res.pParent = pParent;
pGrandParent = nullptr;
updParent = nullptr;
tree_node * pLeaf = const_cast<internal_node *>( &m_Root );
- while ( pLeaf->is_internal() ) {
+ while ( pLeaf->is_internal()) {
res.guards.copy( search_result::Guard_GrandParent, search_result::Guard_Parent );
pGrandParent = pParent;
res.guards.copy( search_result::Guard_Parent, search_result::Guard_Leaf );
updParent = search_protect_update( res, pParent->m_pUpdate );
- switch ( updParent.bits() ) {
+ switch ( updParent.bits()) {
case update_desc::DFlag:
case update_desc::Mark:
m_Stat.onSearchRetry();
res.pGrandParent = pGrandParent;
res.pParent = pParent;
- assert( pLeaf->is_leaf() );
+ assert( pLeaf->is_leaf());
res.pLeaf = static_cast<leaf_node *>( pLeaf );
res.updParent = updParent;
res.updGrandParent = updGrandParent;
updParent = nullptr;
bRightLeaf = false;
tree_node * pLeaf = const_cast<internal_node *>( &m_Root );
- while ( pLeaf->is_internal() ) {
+ while ( pLeaf->is_internal()) {
res.guards.copy( search_result::Guard_GrandParent, search_result::Guard_Parent );
pGrandParent = pParent;
res.guards.copy( search_result::Guard_Parent, search_result::Guard_Leaf );
updParent = search_protect_update( res, pParent->m_pUpdate );
- switch ( updParent.bits() ) {
+ switch ( updParent.bits()) {
case update_desc::DFlag:
case update_desc::Mark:
m_Stat.onSearchRetry();
res.pGrandParent = pGrandParent;
res.pParent = pParent;
- assert( pLeaf->is_leaf() );
+ assert( pLeaf->is_leaf());
res.pLeaf = static_cast<leaf_node *>( pLeaf );
res.updParent = updParent;
res.updGrandParent = updGrandParent;
void help( update_ptr pUpdate )
{
// pUpdate must be guarded!
- switch ( pUpdate.bits() ) {
+ switch ( pUpdate.bits()) {
case update_desc::IFlag:
- help_insert( pUpdate.ptr() );
+ help_insert( pUpdate.ptr());
m_Stat.onHelpInsert();
break;
case update_desc::DFlag:
- help_delete( pUpdate.ptr() );
+ help_delete( pUpdate.ptr());
m_Stat.onHelpDelete();
break;
case update_desc::Mark:
//m_Stat.onHelpMark();
- //help_marked( pUpdate.ptr() );
+ //help_marked( pUpdate.ptr());
break;
}
}
static tree_node * protect_sibling( typename gc::Guard& guard, atomics::atomic<tree_node *>& sibling )
{
tree_node * pSibling = guard.protect( sibling, [](tree_node * p) -> internal_node* { return static_cast<internal_node *>(p); } );
- if ( pSibling->is_leaf() )
+ if ( pSibling->is_leaf())
guard.assign( node_traits::to_value_ptr( static_cast<leaf_node *>( pSibling )));
return pSibling;
}
bool try_insert( value_type& val, internal_node * pNewInternal, search_result& res )
{
assert( res.updParent.bits() == update_desc::Clean );
- assert( res.pLeaf->is_leaf() );
+ assert( res.pLeaf->is_leaf());
// check search result
if ( res.pParent->get_child( res.bRightLeaf, memory_model::memory_order_acquire ) == res.pLeaf ) {
int nCmp = node_compare()(val, *res.pLeaf);
if ( nCmp < 0 ) {
if ( res.pGrandParent ) {
- assert( !res.pLeaf->infinite_key() );
+ assert( !res.pLeaf->infinite_key());
pNewInternal->infinite_key( 0 );
key_extractor()(pNewInternal->m_Key, *node_traits::to_value_ptr( res.pLeaf ));
}
pNewInternal->m_pRight.store( static_cast<tree_node *>(res.pLeaf), memory_model::memory_order_release );
}
else {
- assert( !res.pLeaf->is_internal() );
+ assert( !res.pLeaf->is_internal());
pNewInternal->infinite_key( 0 );
key_extractor()(pNewInternal->m_Key, val);
pNewInternal->m_pLeft.store( static_cast<tree_node *>(res.pLeaf), memory_model::memory_order_relaxed );
pNewInternal->m_pRight.store( static_cast<tree_node *>(pNewLeaf), memory_model::memory_order_release );
- assert( !res.pLeaf->infinite_key() );
+ assert( !res.pLeaf->infinite_key());
}
typename gc::Guard guard;
pOp->iInfo.pLeaf = res.pLeaf;
pOp->iInfo.bRightLeaf = res.bRightLeaf;
- update_ptr updCur( res.updParent.ptr() );
+ update_ptr updCur( res.updParent.ptr());
if ( res.pParent->m_pUpdate.compare_exchange_strong( updCur, update_ptr( pOp, update_desc::IFlag ),
- memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
// do insert
help_insert( pOp );
retire_update_desc( pOp );
back_off bkoff;
for ( ;; ) {
- if ( !search( res, val, cmp ) || !eq( val, *res.pLeaf ) ) {
+ if ( !search( res, val, cmp ) || !eq( val, *res.pLeaf )) {
if ( pOp )
retire_update_desc( pOp );
m_Stat.onEraseFailed();
if ( res.updGrandParent.bits() == update_desc::Clean && res.updParent.bits() == update_desc::Clean ) {
if ( !pOp )
pOp = alloc_update_desc();
- if ( check_delete_precondition( res ) ) {
+ if ( check_delete_precondition( res )) {
typename gc::Guard guard;
guard.assign( pOp );
pOp->dInfo.bRightParent = res.bRightParent;
pOp->dInfo.bRightLeaf = res.bRightLeaf;
- update_ptr updGP( res.updGrandParent.ptr() );
+ update_ptr updGP( res.updGrandParent.ptr());
if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ),
- memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
- if ( help_delete( pOp ) ) {
+ memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
+ if ( help_delete( pOp )) {
// res.pLeaf is not deleted yet since it is guarded
- f( *node_traits::to_value_ptr( res.pLeaf ) );
+ f( *node_traits::to_value_ptr( res.pLeaf ));
break;
}
pOp = nullptr;
if ( res.updGrandParent.bits() == update_desc::Clean && res.updParent.bits() == update_desc::Clean ) {
if ( !pOp )
pOp = alloc_update_desc();
- if ( check_delete_precondition( res ) ) {
+ if ( check_delete_precondition( res )) {
typename gc::Guard guard;
guard.assign( pOp );
pOp->dInfo.bRightParent = res.bRightParent;
pOp->dInfo.bRightLeaf = res.bRightLeaf;
- update_ptr updGP( res.updGrandParent.ptr() );
+ update_ptr updGP( res.updGrandParent.ptr());
if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ),
- memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
if ( help_delete( pOp ))
break;
pOp = nullptr;
if ( res.updGrandParent.bits() == update_desc::Clean && res.updParent.bits() == update_desc::Clean ) {
if ( !pOp )
pOp = alloc_update_desc();
- if ( check_delete_precondition( res ) ) {
+ if ( check_delete_precondition( res )) {
typename gc::Guard guard;
guard.assign( pOp );
pOp->dInfo.bRightParent = res.bRightParent;
pOp->dInfo.bRightLeaf = res.bRightLeaf;
- update_ptr updGP( res.updGrandParent.ptr() );
+ update_ptr updGP( res.updGrandParent.ptr());
if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ),
- memory_model::memory_order_acquire, atomics::memory_order_relaxed ) )
+ memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
- if ( help_delete( pOp ) )
+ if ( help_delete( pOp ))
break;
pOp = nullptr;
}
if ( res.updGrandParent.bits() == update_desc::Clean && res.updParent.bits() == update_desc::Clean ) {
if ( !pOp )
pOp = alloc_update_desc();
- if ( check_delete_precondition( res ) ) {
+ if ( check_delete_precondition( res )) {
typename gc::Guard guard;
guard.assign( pOp );
pOp->dInfo.bRightParent = res.bRightParent;
pOp->dInfo.bRightLeaf = res.bRightLeaf;
- update_ptr updGP( res.updGrandParent.ptr() );
+ update_ptr updGP( res.updGrandParent.ptr());
if ( res.pGrandParent->m_pUpdate.compare_exchange_strong( updGP, update_ptr( pOp, update_desc::DFlag ),
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
bool find_( Q& val, Func f ) const
{
search_result res;
- if ( search( res, val, node_compare() )) {
+ if ( search( res, val, node_compare())) {
assert( res.pLeaf );
f( *node_traits::to_value_ptr( res.pLeaf ), val );
> compare_functor;
search_result res;
- if ( search( res, val, compare_functor() )) {
+ if ( search( res, val, compare_functor())) {
assert( res.pLeaf );
f( *node_traits::to_value_ptr( res.pLeaf ), val );
guarded_ptr get_( Q const& val ) const
{
search_result res;
- if ( search( res, val, node_compare() ) ) {
+ if ( search( res, val, node_compare()) ) {
assert( res.pLeaf );
m_Stat.onFindSuccess();
return guarded_ptr( res.guards.release( search_result::Guard_Leaf ));
> compare_functor;
search_result res;
- if ( search( res, val, compare_functor() ) ) {
+ if ( search( res, val, compare_functor()) ) {
assert( res.pLeaf );
m_Stat.onFindSuccess();
return guarded_ptr( res.guards.release( search_result::Guard_Leaf ));
this code
\code
if ( it1 == it2 )
- assert( &(*it1) == &(*it2) );
+ assert( &(*it1) == &(*it2));
\endcode
can throw assertion. The point is that the iterator stores the value of element which can be modified later by other thread.
The guard inside the iterator prevents recycling that value so the iterator's value remains valid even after such changing.
insert_position pos;
while ( true ) {
- if ( inserting_search( pHead, *pNode->data.load(memory_model::memory_order_relaxed).ptr(), pos, key_comparator() ) ) {
+ if ( inserting_search( pHead, *pNode->data.load(memory_model::memory_order_relaxed).ptr(), pos, key_comparator()) ) {
m_Stat.onInsertFailed();
return false;
}
- if ( link_aux_node( pNode, pos ) ) {
+ if ( link_aux_node( pNode, pos )) {
++m_ItemCounter;
m_Stat.onInsertSuccess();
return true;
insert_position pos;
while ( true ) {
- if ( inserting_search( pHead, val, pos, key_comparator() )) {
+ if ( inserting_search( pHead, val, pos, key_comparator())) {
m_Stat.onInsertFailed();
return false;
}
- if ( link_data( &val, pos ) ) {
+ if ( link_data( &val, pos )) {
++m_ItemCounter;
m_Stat.onInsertSuccess();
return true;
guard.assign( &val );
while ( true ) {
- if ( inserting_search( pHead, val, pos, key_comparator() ) ) {
+ if ( inserting_search( pHead, val, pos, key_comparator()) ) {
m_Stat.onInsertFailed();
return false;
}
- if ( link_data( &val, pos ) ) {
+ if ( link_data( &val, pos )) {
f( val );
++m_ItemCounter;
m_Stat.onInsertSuccess();
guard.assign( &val );
while ( true ) {
- if ( inserting_search( pHead, val, pos, key_comparator() ) ) {
+ if ( inserting_search( pHead, val, pos, key_comparator()) ) {
// try to replace pCur->data with val
assert( pos.pFound != nullptr );
assert( key_comparator()(*pos.pFound, val) == 0 );
bool find_at( node_type const* pHead, Q const& val, Compare cmp ) const
{
position pos;
- if ( search( pHead, val, pos, cmp ) ) {
+ if ( search( pHead, val, pos, cmp )) {
m_Stat.onFindSuccess();
return true;
}
void destroy( Predicate pred )
{
node_type * pNode = m_Head.next.load( memory_model::memory_order_relaxed );
- while ( pNode != pNode->next.load( memory_model::memory_order_relaxed ) ) {
+ while ( pNode != pNode->next.load( memory_model::memory_order_relaxed )) {
value_type * pVal = pNode->data.load( memory_model::memory_order_relaxed ).ptr();
node_type * pNext = pNode->next.load( memory_model::memory_order_relaxed );
bool const is_regular_node = !pVal || pred( pVal );
// and then set it to another.
// To prevent this we mark pos.pCur data as undeletable by setting LSB
marked_data_ptr valCur( pos.pFound );
- if ( !pos.pCur->data.compare_exchange_strong( valCur, valCur | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( !pos.pCur->data.compare_exchange_strong( valCur, valCur | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
// oops, pos.pCur data has been changed or another thread is setting pos.pPrev data
m_Stat.onNodeMarkFailed();
return false;
}
marked_data_ptr valPrev( pos.pPrevVal );
- if ( !pos.pPrev->data.compare_exchange_strong( valPrev, valPrev | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( !pos.pPrev->data.compare_exchange_strong( valPrev, valPrev | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
pos.pCur->data.store( valCur, memory_model::memory_order_relaxed );
m_Stat.onNodeMarkFailed();
return false;
// and then set it to another.
// To prevent this we mark pos.pCur data as undeletable by setting LSB
marked_data_ptr valCur( pos.pFound );
- if ( !pos.pCur->data.compare_exchange_strong( valCur, valCur | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( !pos.pCur->data.compare_exchange_strong( valCur, valCur | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
// oops, pos.pCur data has been changed or another thread is setting pos.pPrev data
m_Stat.onNodeMarkFailed();
return false;
}
marked_data_ptr valPrev( pos.pPrevVal );
- if ( !pos.pPrev->data.compare_exchange_strong( valPrev, valPrev | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( !pos.pPrev->data.compare_exchange_strong( valPrev, valPrev | 1, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
pos.pCur->data.store( valCur, memory_model::memory_order_relaxed );
m_Stat.onNodeMarkFailed();
return false;
assert( pos.pFound != nullptr );
marked_data_ptr val( pos.pFound );
- if ( pos.pCur->data.compare_exchange_strong( val, marked_data_ptr(), memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( pos.pCur->data.compare_exchange_strong( val, marked_data_ptr(), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
retire_data( pos.pFound );
return true;
}
bool find_at( atomic_node_ptr& refHead, Q const& val, Compare cmp )
{
position pos;
- if ( search( refHead, val, pos, cmp ) ) {
+ if ( search( refHead, val, pos, cmp )) {
m_Stat.onFindSuccess();
return true;
}
protected:
static value_type * gc_protect( marked_ptr p )
{
- return node_traits::to_value_ptr( p.ptr() );
+ return node_traits::to_value_ptr( p.ptr());
}
void next()
back_off bkoff;
for (;;) {
- if ( m_pNode->next( m_pNode->height() - 1 ).load( atomics::memory_order_acquire ).bits() ) {
+ if ( m_pNode->next( m_pNode->height() - 1 ).load( atomics::memory_order_acquire ).bits()) {
// Current node is marked as deleted. So, its next pointer can point to anything
// In this case we interrupt our iteration and returns end() iterator.
*this = iterator();
marked_ptr p = m_guard.protect( (*m_pNode)[0], gc_protect );
node_type * pp = p.ptr();
- if ( p.bits() ) {
+ if ( p.bits()) {
// p is marked as deleted. Spin waiting for physical removal
bkoff();
continue;
}
- else if ( pp && pp->next( pp->height() - 1 ).load( atomics::memory_order_relaxed ).bits() ) {
+ else if ( pp && pp->next( pp->height() - 1 ).load( atomics::memory_order_relaxed ).bits()) {
// p is marked as deleted. Spin waiting for physical removal
bkoff();
continue;
for (;;) {
marked_ptr p = m_guard.protect( refHead[0], gc_protect );
- if ( !p.ptr() ) {
+ if ( !p.ptr()) {
// empty skip-list
m_guard.clear();
break;
node_type * pp = p.ptr();
// Logically deleted node is marked from highest level
- if ( !pp->next( pp->height() - 1 ).load( atomics::memory_order_acquire ).bits() ) {
+ if ( !pp->next( pp->height() - 1 ).load( atomics::memory_order_acquire ).bits()) {
m_pNode = pp;
break;
}
iterator( iterator const& s)
: m_pNode( s.m_pNode )
{
- m_guard.assign( node_traits::to_value_ptr(m_pNode) );
+ m_guard.assign( node_traits::to_value_ptr(m_pNode));
}
value_type * operator ->() const
static value_type * gc_protect( marked_node_ptr p )
{
- return node_traits::to_value_ptr( p.ptr() );
+ return node_traits::to_value_ptr( p.ptr());
}
static void dispose_node( value_type * pVal )
{
assert( pVal != nullptr );
- typename node_builder::node_disposer()( node_traits::to_node_ptr(pVal) );
+ typename node_builder::node_disposer()( node_traits::to_node_ptr(pVal));
disposer()( pVal );
}
pos.guards.assign( nLevel * 2, node_traits::to_value_ptr( pPred ));
while ( true ) {
pCur = pos.guards.protect( nLevel * 2 + 1, pPred->next( nLevel ), gc_protect );
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// pCur.bits() means that pPred is logically deleted
goto retry;
}
// pSucc contains deletion mark for pCur
pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
+ if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr())
goto retry;
- if ( pSucc.bits() ) {
+ if ( pSucc.bits()) {
// pCur is marked, i.e. logically deleted.
- marked_node_ptr p( pCur.ptr() );
- if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
+ marked_node_ptr p( pCur.ptr());
+ if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr()),
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
if ( nLevel == 0 ) {
- gc::retire( node_traits::to_value_ptr( pCur.ptr() ), dispose_node );
+ gc::retire( node_traits::to_value_ptr( pCur.ptr()), dispose_node );
m_Stat.onEraseWhileFind();
}
}
// head cannot be deleted
assert( pCur.bits() == 0 );
- if ( pCur.ptr() ) {
+ if ( pCur.ptr()) {
// pSucc contains deletion mark for pCur
pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
+ if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr())
goto retry;
- if ( pSucc.bits() ) {
+ if ( pSucc.bits()) {
// pCur is marked, i.e. logically deleted.
- marked_node_ptr p( pCur.ptr() );
- if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
+ marked_node_ptr p( pCur.ptr());
+ if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr()),
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
if ( nLevel == 0 ) {
- gc::retire( node_traits::to_value_ptr( pCur.ptr() ), dispose_node );
+ gc::retire( node_traits::to_value_ptr( pCur.ptr()), dispose_node );
m_Stat.onEraseWhileFind();
}
}
pos.guards.assign( nLevel * 2, node_traits::to_value_ptr( pPred ));
while ( true ) {
pCur = pos.guards.protect( nLevel * 2 + 1, pPred->next( nLevel ), gc_protect );
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// pCur.bits() means that pPred is logically deleted
goto retry;
}
// pSucc contains deletion mark for pCur
pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
+ if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr())
goto retry;
- if ( pSucc.bits() ) {
+ if ( pSucc.bits()) {
// pCur is marked, i.e. logically deleted.
- marked_node_ptr p( pCur.ptr() );
- if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
+ marked_node_ptr p( pCur.ptr());
+ if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr()),
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
{
if ( nLevel == 0 ) {
- gc::retire( node_traits::to_value_ptr( pCur.ptr() ), dispose_node );
+ gc::retire( node_traits::to_value_ptr( pCur.ptr()), dispose_node );
m_Stat.onEraseWhileFind();
}
}
goto retry;
}
else {
- if ( !pSucc.ptr() )
+ if ( !pSucc.ptr())
break;
pPred = pCur.ptr();
if ( !pNode->next( nLevel ).compare_exchange_strong( p, q, memory_model::memory_order_release, atomics::memory_order_relaxed )) {
// pNode has been marked as removed while we are inserting it
// Stop inserting
- assert( p.bits() );
+ assert( p.bits());
m_Stat.onLogicDeleteWhileInsert();
return true;
}
}
while ( true ) {
- marked_node_ptr p( pDel->next(0).load(memory_model::memory_order_relaxed).ptr() );
+ marked_node_ptr p( pDel->next(0).load(memory_model::memory_order_relaxed).ptr());
if ( pDel->next(0).compare_exchange_strong( p, p | 1, memory_model::memory_order_release, atomics::memory_order_relaxed ))
{
f( *node_traits::to_value_ptr( pDel ));
for ( int nLevel = static_cast<int>( pDel->height() - 1 ); nLevel >= 0; --nLevel ) {
pSucc = pDel->next(nLevel).load(memory_model::memory_order_relaxed);
if ( !pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( p, marked_node_ptr(pSucc.ptr()),
- memory_model::memory_order_acquire, atomics::memory_order_relaxed) )
+ memory_model::memory_order_acquire, atomics::memory_order_relaxed))
{
// Make slow erase
find_position( *node_traits::to_value_ptr( pDel ), pos, key_comparator(), false );
return true;
}
else {
- if ( p.bits() ) {
+ if ( p.bits()) {
// Another thread is deleting pDel right now
return false;
}
continue;
while ( pCur != pNull ) {
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
unsigned int nAttempt = 0;
while ( pCur.bits() && nAttempt++ < 16 ) {
bkoff();
}
bkoff.reset();
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// Maybe, we are on deleted node sequence
// Abort searching, try slow-path
return find_fastpath_abort;
}
}
- if ( pCur.ptr() ) {
- int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr() ), val );
+ if ( pCur.ptr()) {
+ int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr()), val );
if ( nCmp < 0 ) {
guards.copy( 0, 1 );
pPred = pCur.ptr();
}
else if ( nCmp == 0 ) {
// found
- f( *node_traits::to_value_ptr( pCur.ptr() ), val );
+ f( *node_traits::to_value_ptr( pCur.ptr()), val );
return find_fastpath_found;
}
else // pCur > val - go down
{
position pos;
- if ( !find_position( val, pos, cmp, false ) ) {
+ if ( !find_position( val, pos, cmp, false )) {
m_Stat.onEraseFailed();
return false;
}
node_type * pDel = pos.pCur;
typename gc::Guard gDel;
- gDel.assign( node_traits::to_value_ptr(pDel) );
+ gDel.assign( node_traits::to_value_ptr(pDel));
assert( cmp( *node_traits::to_value_ptr( pDel ), val ) == 0 );
unsigned int nHeight = pDel->height();
guarded_ptr gp;
for (;;) {
- if ( !find_position( val, pos, cmp, false ) ) {
+ if ( !find_position( val, pos, cmp, false )) {
m_Stat.onExtractFailed();
return guarded_ptr();
}
guarded_ptr gp;
for (;;) {
- if ( !find_min_position( pos ) ) {
+ if ( !find_min_position( pos )) {
// The list is empty
m_Stat.onExtractMinFailed();
return guarded_ptr();
node_type * pDel = pos.pCur;
unsigned int nHeight = pDel->height();
- gp.reset( node_traits::to_value_ptr(pDel) );
+ gp.reset( node_traits::to_value_ptr(pDel));
if ( try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
guarded_ptr gp;
for (;;) {
- if ( !find_max_position( pos ) ) {
+ if ( !find_max_position( pos )) {
// The list is empty
m_Stat.onExtractMaxFailed();
return guarded_ptr();
node_type * pDel = pos.pCur;
unsigned int nHeight = pDel->height();
- gp.reset( node_traits::to_value_ptr(pDel) );
+ gp.reset( node_traits::to_value_ptr(pDel));
if ( try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
/// Returns a forward iterator addressing the first element in a set
iterator begin()
{
- return iterator( *m_Head.head() );
+ return iterator( *m_Head.head());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( *m_Head.head() );
+ return const_iterator( *m_Head.head());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( *m_Head.head() );
+ return const_iterator( *m_Head.head());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a set.
{
position pos;
- if ( !find_position( val, pos, key_comparator(), false ) ) {
+ if ( !find_position( val, pos, key_comparator(), false )) {
m_Stat.onUnlinkFailed();
return false;
}
unsigned int nHeight = pDel->height();
typename gc::Guard gDel;
- gDel.assign( node_traits::to_value_ptr(pDel) );
+ gDel.assign( node_traits::to_value_ptr(pDel));
if ( node_traits::to_value_ptr( pDel ) == &val && try_remove_at( pDel, pos, [](value_type const&) {} )) {
--m_ItemCounter;
template <typename Q>
guarded_ptr extract( Q const& key )
{
- return extract_( key, key_comparator() );
+ return extract_( key, key_comparator());
}
/// Extracts the item from the set with comparing functor \p pred
guarded_ptr extract_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return extract_( key, cds::opt::details::make_comparator_from_less<Less>() );
+ return extract_( key, cds::opt::details::make_comparator_from_less<Less>());
}
/// Extracts an item with minimal key from the list
template <typename Q>
guarded_ptr get( Q const& key )
{
- return get_with_( key, key_comparator() );
+ return get_with_( key, key_comparator());
}
/// Finds \p key and return the item found
guarded_ptr get_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return get_with_( key, cds::opt::details::make_comparator_from_less<Less>() );
+ return get_with_( key, cds::opt::details::make_comparator_from_less<Less>());
}
/// Returns item count in the set
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- const_iterator it( const_cast<node_type *>(&m_Head) );
+ const_iterator it( const_cast<node_type *>(&m_Head));
++it; // skip dummy head
return it;
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
const_iterator cend() const
{
- return const_iterator( const_cast<node_type *>(&m_Tail) );
+ return const_iterator( const_cast<node_type *>(&m_Tail));
}
public:
template <typename Q>
value_type * contains( Q const& key )
{
- return find_at( &m_Head, key, key_comparator() );
+ return find_at( &m_Head, key, key_comparator());
}
//@cond
template <typename Q>
typename std::enable_if<Sort, value_type *>::type contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>() );
+ return find_at( &m_Head, key, cds::opt::details::make_comparator_from_less<Less>());
}
//@cond
template <typename Q, typename Less, bool Sort = c_bSort>
*/
void clear()
{
- clear( disposer() );
+ clear( disposer());
}
/// Checks if the list is empty
// Hack: convert node_type to value_type.
// In principle, auxiliary node can be non-reducible to value_type
// We assume that comparator can correctly distinguish aux and regular node.
- return insert_at( pHead, *node_traits::to_value_ptr( pNode ) );
+ return insert_at( pHead, *node_traits::to_value_ptr( pNode ));
}
bool insert_at( node_type * pHead, value_type& val )
{
auto_lock_position alp( pos );
if ( validate( pos.pPred, pos.pCur )) {
- if ( pos.pCur != &m_Tail && equal( *node_traits::to_value_ptr( *pos.pCur ), val, pred ) ) {
+ if ( pos.pCur != &m_Tail && equal( *node_traits::to_value_ptr( *pos.pCur ), val, pred )) {
// failed: key already in list
m_Stat.onInsertFailed();
return false;
++m_ItemCounter;
m_Stat.onUpdateNew();
- return std::make_pair( iterator( node_traits::to_node_ptr( val ) ), true );
+ return std::make_pair( iterator( node_traits::to_node_ptr( val )), true );
}
template <typename Func>
search( pHead, val, pos, pred );
if ( pos.pCur != &m_Tail ) {
std::unique_lock< typename node_type::lock_type> al( pos.pCur->m_Lock );
- if ( equal( *node_traits::to_value_ptr( *pos.pCur ), val, pred ) )
+ if ( equal( *node_traits::to_value_ptr( *pos.pCur ), val, pred ))
{
f( *node_traits::to_value_ptr( *pos.pCur ), val );
m_Stat.onFindSuccess();
value_type * find_at( node_type * pHead, Q& val, Pred pred)
{
iterator it = find_at_( pHead, val, pred );
- if ( it != end() )
+ if ( it != end())
return &*it;
return nullptr;
}
node_type * pCur = pHead;
node_type * pPrev = pHead;
- while ( pCur != pTail && ( pCur == pHead || !equal( *node_traits::to_value_ptr( *pCur ), key, eq ) )) {
+ while ( pCur != pTail && ( pCur == pHead || !equal( *node_traits::to_value_ptr( *pCur ), key, eq ))) {
pPrev = pCur;
pCur = pCur->m_pNext.load(memory_model::memory_order_acquire);
}
if ( pred( *node_traits::to_value_ptr( pHead ))) {
assert( pPred != nullptr );
pPred->m_pNext.store( p, memory_model::memory_order_relaxed );
- dispose_node( pHead, disposer() );
+ dispose_node( pHead, disposer());
}
else
pPred = pHead;
static void dispose_node( node_type * pNode )
{
assert( pNode );
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
- gc::template retire_ptr<clear_and_dispose>( node_traits::to_value_ptr( *pNode ) );
+ gc::template retire_ptr<clear_and_dispose>( node_traits::to_value_ptr( *pNode ));
}
static void link_node( node_type * pNode, node_type * pPred, node_type * pCur )
bool validate( node_type * pPred, node_type * pCur ) CDS_NOEXCEPT
{
- if ( validate_link( pPred, pCur ) ) {
+ if ( validate_link( pPred, pCur )) {
m_Stat.onValidationSuccess();
return true;
}
//@cond
const_iterator get_const_begin() const
{
- const_iterator it( const_cast<node_type *>(&m_Head) );
+ const_iterator it( const_cast<node_type *>(&m_Head));
++it; // skip dummy head
return it;
}
const_iterator get_const_end() const
{
- return const_iterator( const_cast<node_type *>(&m_Tail) );
+ return const_iterator( const_cast<node_type *>(&m_Tail));
}
//@endcond
};
*/
iterator begin()
{
- return iterator(m_pHead.load(memory_model::memory_order_relaxed) );
+ return iterator(m_pHead.load(memory_model::memory_order_relaxed));
}
/// Returns an iterator that addresses the location succeeding the last element in a list
/// Returns a forward const iterator addressing the first element in a list
const_iterator begin() const
{
- return const_iterator(m_pHead.load(memory_model::memory_order_relaxed) );
+ return const_iterator(m_pHead.load(memory_model::memory_order_relaxed));
}
/// Returns a forward const iterator addressing the first element in a list
const_iterator cbegin() const
{
- return const_iterator(m_pHead.load(memory_model::memory_order_relaxed) );
+ return const_iterator(m_pHead.load(memory_model::memory_order_relaxed));
}
/// Returns an const iterator that addresses the location succeeding the last element in a list
template <typename Q>
value_type * contains( Q const& key )
{
- return find_at( m_pHead, key, key_comparator() );
+ return find_at( m_pHead, key, key_comparator());
}
//@cond
template <typename Q>
*/
void clear()
{
- clear( disposer() );
+ clear( disposer());
}
/// Checks if the list is empty
// Hack: convert node_type to value_type.
// In principle, auxiliary node can be non-reducible to value_type
// We assume that comparator can correctly distinguish aux and regular node.
- return insert_at( refHead, *node_traits::to_value_ptr( pNode ) );
+ return insert_at( refHead, *node_traits::to_value_ptr( pNode ));
}
bool insert_at( atomic_node_ptr& refHead, value_type& val )
return false;
}
- if ( link_node( node_traits::to_node_ptr( val ), pos ) ) {
+ if ( link_node( node_traits::to_node_ptr( val ), pos )) {
++m_ItemCounter;
m_Stat.onInsertSuccess();
return true;
position pos;
while ( true ) {
- if ( search( refHead, val, key_comparator(), pos ) ) {
- assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur ) ) == 0 );
+ if ( search( refHead, val, key_comparator(), pos )) {
+ assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur )) == 0 );
func( false, *node_traits::to_value_ptr( *pos.pCur ) , val );
m_Stat.onUpdateExisting();
return std::make_pair( end(), false );
}
- if ( link_node( node_traits::to_node_ptr( val ), pos ) ) {
+ if ( link_node( node_traits::to_node_ptr( val ), pos )) {
++m_ItemCounter;
func( true, val , val );
m_Stat.onUpdateNew();
{
position pos;
- if ( search( refHead, val, cmp, pos ) ) {
+ if ( search( refHead, val, cmp, pos )) {
assert( pos.pCur != nullptr );
f( *node_traits::to_value_ptr( *pos.pCur ), val );
m_Stat.onFindSuccess();
value_type * find_at( atomic_node_ptr& refHead, Q const& val, Compare cmp )
{
iterator it = find_at_( refHead, val, cmp );
- if ( it != end() ) {
+ if ( it != end()) {
m_Stat.onFindSuccess();
return &*it;
}
{
position pos;
- if ( search( refHead, val, cmp, pos ) ) {
+ if ( search( refHead, val, cmp, pos )) {
assert( pos.pCur != nullptr );
m_Stat.onFindSuccess();
return iterator( pos.pCur );
template <typename Q>
bool erase( Q const& key )
{
- return erase_at( m_pHead, key, key_comparator() );
+ return erase_at( m_pHead, key, key_comparator());
}
/// Deletes the item from the list using \p pred predicate for searching
bool erase_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>() );
+ return erase_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>());
}
/// Deletes the item from the list
rcu_michael_list::exempt_ptr p1;
// The RCU should NOT be locked when extract() is called!
- assert( !rcu::is_locked() );
+ assert( !rcu::is_locked());
// You can call extract() function
p1 = theList.extract( 10 );
template <typename Q>
exempt_ptr extract( Q const& key )
{
- return exempt_ptr( extract_at( m_pHead, key, key_comparator() ));
+ return exempt_ptr( extract_at( m_pHead, key, key_comparator()));
}
/// Extracts an item from the list using \p pred predicate for searching
exempt_ptr extract_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return exempt_ptr( extract_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>() ));
+ return exempt_ptr( extract_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>()));
}
/// Find the key \p val
template <typename Q>
bool contains( Q const& key )
{
- return find_at( m_pHead, key, key_comparator() );
+ return find_at( m_pHead, key, key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>() );
+ return find_at( m_pHead, key, cds::opt::details::make_comparator_from_less<Less>());
}
//@cond
template <typename Q, typename Less>
*/
void clear()
{
- if( !empty() ) {
+ if( !empty()) {
check_deadlock_policy::check();
marked_node_ptr pHead;
{
rcu_lock l;
pHead = m_pHead.load(memory_model::memory_order_acquire);
- if ( !pHead.ptr() )
+ if ( !pHead.ptr())
break;
- marked_node_ptr pNext( pHead->m_pNext.load(memory_model::memory_order_relaxed) );
+ marked_node_ptr pNext( pHead->m_pNext.load(memory_model::memory_order_relaxed));
if ( cds_unlikely( !pHead->m_pNext.compare_exchange_weak( pNext, pNext | 1, memory_model::memory_order_acquire, memory_model::memory_order_relaxed )))
continue;
if ( cds_unlikely( !m_pHead.compare_exchange_weak( pHead, marked_node_ptr(pNext.ptr()), memory_model::memory_order_release, memory_model::memory_order_relaxed )))
}
--m_ItemCounter;
- dispose_node( pHead.ptr() );
+ dispose_node( pHead.ptr());
}
}
}
static void dispose_node( node_type * pNode )
{
assert( pNode );
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
- gc::template retire_ptr<clear_and_dispose>( node_traits::to_value_ptr( *pNode ) );
+ gc::template retire_ptr<clear_and_dispose>( node_traits::to_value_ptr( *pNode ));
}
static void dispose_chain( node_type * pChain )
{
if ( pChain ) {
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
auto f = [&pChain]() -> cds::urcu::retired_ptr {
node_type * p = pChain;
if ( p ) {
pChain = p->m_pDelChain;
- return cds::urcu::make_retired_ptr<clear_and_dispose>( node_traits::to_value_ptr( p ) );
+ return cds::urcu::make_retired_ptr<clear_and_dispose>( node_traits::to_value_ptr( p ));
}
- return cds::urcu::make_retired_ptr<clear_and_dispose>( static_cast<value_type *>(nullptr) );
+ return cds::urcu::make_retired_ptr<clear_and_dispose>( static_cast<value_type *>(nullptr));
};
- gc::batch_retire( std::ref( f ) );
+ gc::batch_retire( std::ref( f ));
}
}
marked_node_ptr p( pos.pCur );
pNode->m_pNext.store( p, memory_model::memory_order_release );
- if ( cds_likely( pos.pPrev->compare_exchange_strong( p, marked_node_ptr( pNode ), memory_model::memory_order_release, atomics::memory_order_relaxed ) ) )
+ if ( cds_likely( pos.pPrev->compare_exchange_strong( p, marked_node_ptr( pNode ), memory_model::memory_order_release, atomics::memory_order_relaxed )) )
return true;
pNode->m_pNext.store( marked_node_ptr(), memory_model::memory_order_relaxed );
bool unlink_node( position& pos, erase_node_mask nMask )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
// Mark the node (logical deletion)
marked_node_ptr next( pos.pNext, 0 );
- if ( cds_likely( pos.pCur->m_pNext.compare_exchange_strong( next, next | nMask, memory_model::memory_order_release, atomics::memory_order_relaxed ) ) ) {
+ if ( cds_likely( pos.pCur->m_pNext.compare_exchange_strong( next, next | nMask, memory_model::memory_order_release, atomics::memory_order_relaxed )) ) {
// Try physical removal - fast path
marked_node_ptr cur( pos.pCur );
- if ( cds_likely( pos.pPrev->compare_exchange_strong( cur, marked_node_ptr( pos.pNext ), memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) ) {
+ if ( cds_likely( pos.pPrev->compare_exchange_strong( cur, marked_node_ptr( pos.pNext ), memory_model::memory_order_acquire, atomics::memory_order_relaxed )) ) {
if ( nMask == erase_mask )
link_to_remove_chain( pos, pos.pCur );
}
else {
// Slow path
- search( pos.refHead, *node_traits::to_value_ptr( pos.pCur ), pos, key_comparator() );
+ search( pos.refHead, *node_traits::to_value_ptr( pos.pCur ), pos, key_comparator());
}
return true;
}
// Hack: convert node_type to value_type.
// In principle, auxiliary node can be non-reducible to value_type
// We assume that comparator can correctly distinguish between aux and regular node.
- return insert_at( refHead, *node_traits::to_value_ptr( pNode ) );
+ return insert_at( refHead, *node_traits::to_value_ptr( pNode ));
}
bool insert_at( atomic_node_ptr& refHead, value_type& val )
return false;
}
- if ( link_node( node_traits::to_node_ptr( val ), pos ) ) {
+ if ( link_node( node_traits::to_node_ptr( val ), pos )) {
f( val );
++m_ItemCounter;
m_Stat.onInsertSuccess();
for (;;) {
{
rcu_lock l;
- if ( !search( refHead, val, pos, key_comparator() ) || node_traits::to_value_ptr( *pos.pCur ) != &val ) {
+ if ( !search( refHead, val, pos, key_comparator()) || node_traits::to_value_ptr( *pos.pCur ) != &val ) {
m_Stat.onEraseFailed();
return false;
}
for (;;) {
{
rcu_lock l;
- if ( !search( pos.refHead, val, pos, cmp ) ) {
+ if ( !search( pos.refHead, val, pos, cmp )) {
m_Stat.onEraseFailed();
return false;
}
}
}
assert( pDel );
- f( *node_traits::to_value_ptr( pDel ) );
+ f( *node_traits::to_value_ptr( pDel ));
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
{
position pos( refHead );
back_off bkoff;
- assert( !gc::is_locked() ) ; // RCU must not be locked!!!
+ assert( !gc::is_locked()) ; // RCU must not be locked!!!
node_type * pExtracted;
{
{
rcu_lock l;
- if ( search( refHead, val, pos, cmp ) ) {
+ if ( search( refHead, val, pos, cmp )) {
assert( pos.pCur != nullptr );
f( *node_traits::to_value_ptr( *pos.pCur ), val );
m_Stat.onFindSuccess();
raw_ptr get_at( atomic_node_ptr& refHead, Q const& val, Compare cmp )
{
// RCU should be locked!
- assert(gc::is_locked() );
+ assert(gc::is_locked());
position pos( refHead );
bool search( atomic_node_ptr& refHead, const Q& val, position& pos, Compare cmp )
{
// RCU lock should be locked!!!
- assert( gc::is_locked() );
+ assert( gc::is_locked());
atomic_node_ptr * pPrev;
marked_node_ptr pNext;
pNext = nullptr;
while ( true ) {
- if ( !pCur.ptr() ) {
+ if ( !pCur.ptr()) {
pos.pPrev = pPrev;
pos.pCur = nullptr;
pos.pNext = nullptr;
goto try_again;
}
- if ( pNext.bits() ) {
+ if ( pNext.bits()) {
// pCur is marked as deleted. Try to unlink it from the list
- if ( cds_likely( pPrev->compare_exchange_weak( pCur, marked_node_ptr( pNext.ptr() ), memory_model::memory_order_acquire, atomics::memory_order_relaxed ))) {
+ if ( cds_likely( pPrev->compare_exchange_weak( pCur, marked_node_ptr( pNext.ptr()), memory_model::memory_order_acquire, atomics::memory_order_relaxed ))) {
if ( pNext.bits() == erase_mask )
- link_to_remove_chain( pos, pCur.ptr() );
+ link_to_remove_chain( pos, pCur.ptr());
m_Stat.onHelpingSuccess();
}
}
assert( pCur.ptr() != nullptr );
- int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr() ), val );
+ int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr()), val );
if ( nCmp >= 0 ) {
pos.pPrev = pPrev;
pos.pCur = pCur.ptr();
bool insert_at_locked( position& pos, value_type& val )
{
// RCU lock should be locked!!!
- assert( gc::is_locked() );
+ assert( gc::is_locked());
while ( true ) {
- if ( search( pos.refHead, val, pos, key_comparator() )) {
+ if ( search( pos.refHead, val, pos, key_comparator())) {
m_Stat.onInsertFailed();
return false;
}
- if ( link_node( node_traits::to_node_ptr( val ), pos ) ) {
+ if ( link_node( node_traits::to_node_ptr( val ), pos )) {
++m_ItemCounter;
m_Stat.onInsertSuccess();
return true;
std::pair<iterator, bool> update_at_locked( position& pos, value_type& val, Func func, bool bInsert )
{
// RCU should be locked!!!
- assert( gc::is_locked() );
+ assert( gc::is_locked());
while ( true ) {
- if ( search( pos.refHead, val, pos, key_comparator() ) ) {
- assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur ) ) == 0 );
+ if ( search( pos.refHead, val, pos, key_comparator()) ) {
+ assert( key_comparator()( val, *node_traits::to_value_ptr( *pos.pCur )) == 0 );
func( false, *node_traits::to_value_ptr( *pos.pCur ), val );
m_Stat.onUpdateExisting();
return std::make_pair( end(), false );
}
- if ( link_node( node_traits::to_node_ptr( val ), pos ) ) {
+ if ( link_node( node_traits::to_node_ptr( val ), pos )) {
++m_ItemCounter;
func( true, val , val );
m_Stat.onUpdateNew();
template <typename Q, typename Compare>
const_iterator find_at_locked( position& pos, Q const& val, Compare cmp )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
- if ( search( pos.refHead, val, pos, cmp ) ) {
+ if ( search( pos.refHead, val, pos, cmp )) {
assert( pos.pCur != nullptr );
m_Stat.onFindSuccess();
return const_iterator( pos.pCur );
*/
iterator begin()
{
- return iterator( m_Buckets[0].begin(), bucket_begin(), bucket_end() );
+ return iterator( m_Buckets[0].begin(), bucket_begin(), bucket_end());
}
/// Returns an iterator that addresses the location succeeding the last element in a set
*/
iterator end()
{
- return iterator( bucket_end()[-1].end(), bucket_end() - 1, bucket_end() );
+ return iterator( bucket_end()[-1].end(), bucket_end() - 1, bucket_end());
}
/// Returns a forward const iterator addressing the first element in a set
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
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find( key );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
return iterator( it, &b, bucket_end());
}
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find( key );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
//@endcond
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find_with( key, pred );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
//@cond
template <typename Q, typename Less>
{
internal_bucket_type& b = bucket( key );
typename internal_bucket_type::iterator it = b.find_with( key, pred );
- if ( it == b.end() )
+ if ( it == b.end())
return end();
- return iterator( it, &b, bucket_end() );
+ return iterator( it, &b, bucket_end());
}
//@endcond
const_iterator get_const_begin() const
{
- return const_iterator( m_Buckets[0].cbegin(), bucket_begin(), bucket_end() );
+ return const_iterator( m_Buckets[0].cbegin(), bucket_begin(), bucket_end());
}
const_iterator get_const_end() const
{
- return const_iterator( bucket_end()[-1].cend(), bucket_end() - 1, bucket_end() );
+ return const_iterator( bucket_end()[-1].cend(), bucket_end() - 1, bucket_end());
}
template <typename Stat>
*/
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
*/
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
const_iterator cbegin() const
{
- return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count() );
+ return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count());
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator cend() const
{
- return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
+ return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count());
}
//@}
size_t nMaxItemCount, ///< estimation of max item count in the hash set
size_t nLoadFactor ///< load factor: estimation of max number of items in the bucket
) : m_nHashBitmask( michael_set::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
- , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
+ , m_Buckets( bucket_table_allocator().allocate( bucket_count()) )
{
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
construct_bucket<bucket_stat>( it );
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
*/
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
*/
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
const_iterator cbegin() const
{
- return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count() );
+ return const_iterator( m_Buckets[0].cbegin(), m_Buckets, m_Buckets + bucket_count());
}
/// Returns an const iterator that addresses the location succeeding the last element in a set
/// Returns an const iterator that addresses the location succeeding the last element in a set
const_iterator cend() const
{
- return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count() );
+ return const_iterator( m_Buckets[bucket_count() - 1].cend(), m_Buckets + bucket_count() - 1, m_Buckets + bucket_count());
}
//@}
size_t nMaxItemCount, ///< estimation of max item count in the hash set
size_t nLoadFactor ///< load factor: average size of the bucket
) : m_nHashBitmask( michael_set::details::init_hash_bitmask( nMaxItemCount, nLoadFactor ))
- , m_Buckets( bucket_table_allocator().allocate( bucket_count() ) )
+ , m_Buckets( bucket_table_allocator().allocate( bucket_count()) )
{
for ( auto it = m_Buckets, itEnd = m_Buckets + bucket_count(); it != itEnd; ++it )
construct_bucket<bucket_stat>( it );
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
template <typename Q>
exempt_ptr extract( Q const& key )
{
- exempt_ptr p( bucket( key ).extract( key ) );
+ exempt_ptr p( bucket( key ).extract( key ));
if ( p )
--m_ItemCounter;
return p;
template <typename Q, typename Less>
exempt_ptr extract_with( Q const& key, Less pred )
{
- exempt_ptr p( bucket( key ).extract_with( key, pred ) );
+ exempt_ptr p( bucket( key ).extract_with( key, pred ));
if ( p )
--m_ItemCounter;
return p;
/// Creates empty node
node()
: m_pVal( nullptr )
- , m_nTag( tag_type(Empty) )
+ , m_nTag( tag_type(Empty))
{}
/// Lock the node
// Insert new item at bottom of the heap
m_Lock.lock();
- if ( m_ItemCounter.value() >= capacity() ) {
+ if ( m_ItemCounter.value() >= capacity()) {
// the heap is full
m_Lock.unlock();
m_Stat.onPushFailed();
}
counter_type i = m_ItemCounter.inc();
- assert( i < m_Heap.capacity() );
+ assert( i < m_Heap.capacity());
node& refNode = m_Heap[i];
refNode.lock();
return nullptr;
}
counter_type nBottom = m_ItemCounter.dec();
- assert( nBottom < m_Heap.capacity() );
+ assert( nBottom < m_Heap.capacity());
assert( nBottom > 0 );
refTop.lock();
refBottom.m_pVal = nullptr;
refBottom.unlock();
- if ( refTop.m_nTag == tag_type(Empty) ) {
+ if ( refTop.m_nTag == tag_type(Empty)) {
// nBottom == nTop
refTop.unlock();
m_Stat.onPopSuccess();
i = 0;
}
}
- else if ( refParent.m_nTag == tag_type( Empty ) ) {
+ else if ( refParent.m_nTag == tag_type( Empty )) {
m_Stat.onItemMovedTop();
i = 0;
}
void operator()( value_type * p ) const
{
assert( p != nullptr );
- MSQueue::clear_links( node_traits::to_node_ptr( p ) );
+ MSQueue::clear_links( node_traits::to_node_ptr( p ));
disposer()(p);
}
};
if ( p != &m_Dummy )
- gc::template retire<disposer_thunk>( node_traits::to_value_ptr( p ) );
+ gc::template retire<disposer_thunk>( node_traits::to_value_ptr( p ));
}
//@endcond
node_type * pHead = m_pHead.load(memory_model::memory_order_relaxed);
assert( pHead != nullptr );
- assert( pHead == m_pTail.load(memory_model::memory_order_relaxed) );
+ assert( pHead == m_pTail.load(memory_model::memory_order_relaxed));
m_pHead.store( nullptr, memory_model::memory_order_relaxed );
m_pTail.store( nullptr, memory_model::memory_order_relaxed );
*/
void clear()
{
- while ( dequeue() );
+ while ( dequeue());
}
/// Returns queue's item count
{
assert( p != nullptr );
- OptimisticQueue::clear_links( node_traits::to_node_ptr( *p ) );
+ OptimisticQueue::clear_links( node_traits::to_node_ptr( *p ));
disposer()(p);
}
};
- gc::template retire<internal_disposer>( node_traits::to_value_ptr(p) );
+ gc::template retire<internal_disposer>( node_traits::to_value_ptr(p));
}
}
~segment_list()
{
- m_List.clear_and_dispose( gc_segment_disposer() );
+ m_List.clear_and_dispose( gc_segment_disposer());
}
segment * head( typename gc::Guard& guard )
// The lock should be held
cell const * pLastCell = s.cells + quasi_factor();
for ( cell const * pCell = s.cells; pCell < pLastCell; ++pCell ) {
- if ( !pCell->data.load( memory_model::memory_order_relaxed ).all() )
+ if ( !pCell->data.load( memory_model::memory_order_relaxed ).all())
return false;
}
return true;
// The lock should be held
cell const * pLastCell = s.cells + quasi_factor();
for ( cell const * pCell = s.cells; pCell < pLastCell; ++pCell ) {
- if ( !pCell->data.load( memory_model::memory_order_relaxed ).bits() )
+ if ( !pCell->data.load( memory_model::memory_order_relaxed ).bits())
return false;
}
return true;
if ( !m_List.empty() && ( pTail != &m_List.back() || get_version(pTail) != m_List.back().version )) {
m_pTail.store( &m_List.back(), memory_model::memory_order_relaxed );
- return guard.assign( &m_List.back() );
+ return guard.assign( &m_List.back());
}
# ifdef _DEBUG
- assert( m_List.empty() || populated( m_List.back() ));
+ assert( m_List.empty() || populated( m_List.back()));
# endif
segment * pNew = allocate_segment();
m_Stat.onSegmentCreated();
- if ( m_List.empty() )
+ if ( m_List.empty())
m_pHead.store( pNew, memory_model::memory_order_release );
m_List.push_back( *pNew );
m_pTail.store( pNew, memory_model::memory_order_release );
{
scoped_lock l( m_Lock );
- if ( m_List.empty() ) {
+ if ( m_List.empty()) {
m_pTail.store( nullptr, memory_model::memory_order_relaxed );
m_pHead.store( nullptr, memory_model::memory_order_relaxed );
return guard.assign( nullptr );
if ( pHead != &m_List.front() || get_version(pHead) != m_List.front().version ) {
m_pHead.store( &m_List.front(), memory_model::memory_order_relaxed );
- return guard.assign( &m_List.front() );
+ return guard.assign( &m_List.front());
}
# ifdef _DEBUG
# endif
m_List.pop_front();
- if ( m_List.empty() ) {
+ if ( m_List.empty()) {
pRet = guard.assign( nullptr );
m_pTail.store( nullptr, memory_model::memory_order_relaxed );
}
else
- pRet = guard.assign( &m_List.front() );
+ pRet = guard.assign( &m_List.front());
m_pHead.store( pRet, memory_model::memory_order_release );
}
segment * allocate_segment()
{
- return segment_allocator().NewBlock( sizeof(segment) + sizeof(cell) * m_nQuasiFactor, quasi_factor() );
+ return segment_allocator().NewBlock( sizeof(segment) + sizeof(cell) * m_nQuasiFactor, quasi_factor());
}
static void free_segment( segment * pSegment )
assert( pTailSegment );
}
- permutation_generator gen( quasi_factor() );
+ permutation_generator gen( quasi_factor());
// First, increment item counter.
// We sure that the item will be enqueued
do {
typename permutation_generator::integer_type i = gen;
CDS_DEBUG_ONLY( ++nLoopCount );
- if ( pTailSegment->cells[i].data.load(memory_model::memory_order_relaxed).all() ) {
+ if ( pTailSegment->cells[i].data.load(memory_model::memory_order_relaxed).all()) {
// Cell is not empty, go next
m_Stat.onPushPopulated();
}
m_Stat.onPush();
return true;
}
- assert( nullCell.ptr() );
+ assert( nullCell.ptr());
m_Stat.onPushContended();
}
- } while ( gen.next() );
+ } while ( gen.next());
assert( nLoopCount == quasi_factor());
*/
void clear()
{
- clear_with( disposer() );
+ clear_with( disposer());
}
/// Clear the queue
void clear_with( Disposer )
{
typename gc::Guard itemGuard;
- while ( do_dequeue( itemGuard ) ) {
- assert( itemGuard.template get<value_type>() );
- gc::template retire<Disposer>( itemGuard.template get<value_type>() );
+ while ( do_dequeue( itemGuard )) {
+ assert( itemGuard.template get<value_type>());
+ gc::template retire<Disposer>( itemGuard.template get<value_type>());
itemGuard.clear();
}
}
typename gc::Guard segmentGuard;
segment * pHeadSegment = m_SegmentList.head( segmentGuard );
- permutation_generator gen( quasi_factor() );
+ permutation_generator gen( quasi_factor());
while ( true ) {
if ( !pHeadSegment ) {
// Queue is empty
// In segmented queue the cell cannot be reused
// So no loop is needed here to protect the cell
item = pHeadSegment->cells[i].data.load( memory_model::memory_order_relaxed );
- itemGuard.assign( item.ptr() );
+ itemGuard.assign( item.ptr());
// Check if this cell is empty, which means an element
// can be enqueued to this cell in the future
- if ( !item.ptr() )
+ if ( !item.ptr())
bHadNullValue = true;
else {
// If the item is not deleted yet
- if ( !item.bits() ) {
+ if ( !item.bits()) {
// Try to mark the cell as deleted
if ( pHeadSegment->cells[i].data.compare_exchange_strong( item, item | 1,
memory_model::memory_order_acquire, atomics::memory_order_relaxed ))
return true;
}
- assert( item.bits() );
+ assert( item.bits());
m_Stat.onPopContended();
}
}
- } while ( gen.next() );
+ } while ( gen.next());
- assert( nLoopCount == quasi_factor() );
+ assert( nLoopCount == quasi_factor());
// scanning the entire segment without finding a candidate to dequeue
// If there was an empty cell, the queue is considered empty
/// Access to element of next pointer array
atomic_ptr& next( unsigned int nLevel )
{
- assert( nLevel < height() );
- assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr) );
+ assert( nLevel < height());
+ assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr));
return nLevel ? m_arrNext[ nLevel - 1] : m_pNext;
}
/// Access to element of next pointer array (const version)
atomic_ptr const& next( unsigned int nLevel ) const
{
- assert( nLevel < height() );
+ assert( nLevel < height());
assert( nLevel == 0 || nLevel > 0 && m_arrNext != nullptr );
return nLevel ? m_arrNext[ nLevel - 1] : m_pNext;
public: // for internal use only!!!
iterator( node_type& refHead )
- : m_pNode( refHead[0].load( atomics::memory_order_relaxed ) )
+ : m_pNode( refHead[0].load( atomics::memory_order_relaxed ))
{}
static iterator from_node( node_type * pNode )
{
node_type * p = pos.pSucc[0];
pNode->next( 0 ).store( pos.pSucc[ 0 ], memory_model::memory_order_release );
- if ( !pos.pPrev[0]->next(0).compare_exchange_strong( p, pNode, memory_model::memory_order_release, memory_model::memory_order_relaxed ) ) {
+ if ( !pos.pPrev[0]->next(0).compare_exchange_strong( p, pNode, memory_model::memory_order_release, memory_model::memory_order_relaxed )) {
return false;
}
f( val );
if ( pNode->next( nLevel ).compare_exchange_strong( p, q, memory_model::memory_order_release, memory_model::memory_order_relaxed )) {
p = q;
- if ( pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( q, pNode, memory_model::memory_order_release, memory_model::memory_order_relaxed ) )
+ if ( pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( q, pNode, memory_model::memory_order_release, memory_model::memory_order_relaxed ))
break;
}
void increase_height( unsigned int nHeight )
{
unsigned int nCur = m_nHeight.load( memory_model::memory_order_relaxed );
- while ( nCur < nHeight && !m_nHeight.compare_exchange_weak( nCur, nHeight, memory_model::memory_order_acquire, atomics::memory_order_relaxed ) );
+ while ( nCur < nHeight && !m_nHeight.compare_exchange_weak( nCur, nHeight, memory_model::memory_order_acquire, atomics::memory_order_relaxed ));
}
//@endcond
/// Returns a forward iterator addressing the first element in a set
iterator begin()
{
- return iterator( *m_Head.head() );
+ return iterator( *m_Head.head());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( *m_Head.head() );
+ return const_iterator( *m_Head.head());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( *m_Head.head() );
+ return const_iterator( *m_Head.head());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a set.
/// Access to element of next pointer array
atomic_marked_ptr& next( unsigned int nLevel )
{
- assert( nLevel < height() );
- assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr) );
+ assert( nLevel < height());
+ assert( nLevel == 0 || (nLevel > 0 && m_arrNext != nullptr));
# ifdef CDS_THREAD_SANITIZER_ENABLED
// TSan false positive: m_arrNext is read-only array
/// Access to element of next pointer array (const version)
atomic_marked_ptr const& next( unsigned int nLevel ) const
{
- assert( nLevel < height() );
+ assert( nLevel < height());
assert( nLevel == 0 || nLevel > 0 && m_arrNext != nullptr );
# ifdef CDS_THREAD_SANITIZER_ENABLED
back_off bkoff;
for (;;) {
- if ( m_pNode->next( m_pNode->height() - 1 ).load( atomics::memory_order_acquire ).bits() ) {
+ if ( m_pNode->next( m_pNode->height() - 1 ).load( atomics::memory_order_acquire ).bits()) {
// Current node is marked as deleted. So, its next pointer can point to anything
// In this case we interrupt our iteration and returns end() iterator.
*this = iterator();
marked_ptr p = m_pNode->next(0).load( atomics::memory_order_relaxed );
node_type * pp = p.ptr();
- if ( p.bits() ) {
+ if ( p.bits()) {
// p is marked as deleted. Spin waiting for physical removal
bkoff();
continue;
}
- else if ( pp && pp->next( pp->height() - 1 ).load( atomics::memory_order_relaxed ).bits() ) {
+ else if ( pp && pp->next( pp->height() - 1 ).load( atomics::memory_order_relaxed ).bits()) {
// p is marked as deleted. Spin waiting for physical removal
bkoff();
continue;
for (;;) {
marked_ptr p = refHead.next(0).load( atomics::memory_order_relaxed );
- if ( !p.ptr() ) {
+ if ( !p.ptr()) {
// empty skip-list
break;
}
node_type * pp = p.ptr();
// Logically deleted node is marked from highest level
- if ( !pp->next( pp->height() - 1 ).load( atomics::memory_order_acquire ).bits() ) {
+ if ( !pp->next( pp->height() - 1 ).load( atomics::memory_order_acquire ).bits()) {
m_pNode = pp;
break;
}
{
assert( pVal );
- typename node_builder::node_disposer()( node_traits::to_node_ptr(pVal) );
+ typename node_builder::node_disposer()( node_traits::to_node_ptr(pVal));
disposer()( pVal );
}
static void dispose_chain( node_type * pChain )
{
if ( pChain ) {
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
auto f = [&pChain]() -> cds::urcu::retired_ptr {
node_type * p = pChain;
template <typename Q, typename Compare >
bool find_position( Q const& val, position& pos, Compare cmp, bool bStopIfFound )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
node_type * pPred;
marked_node_ptr pSucc;
while ( true ) {
pCur = pPred->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// pCur.bits() means that pPred is logically deleted
goto retry;
}
// pSucc contains deletion mark for pCur
pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
+ if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr())
goto retry;
- if ( pSucc.bits() ) {
+ if ( pSucc.bits()) {
// pCur is marked, i.e. logically deleted.
- marked_node_ptr p( pCur.ptr() );
+ marked_node_ptr p( pCur.ptr());
# ifdef _DEBUG
if ( nLevel == 0 )
pCur->m_bUnlinked = true;
# endif
- if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
+ if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr()),
memory_model::memory_order_release, atomics::memory_order_relaxed ))
{
if ( nLevel == 0 ) {
if ( !is_extracted( pSucc )) {
// We cannot free the node at this moment since RCU is locked
// Link deleted nodes to a chain to free later
- pos.dispose( pCur.ptr() );
+ pos.dispose( pCur.ptr());
m_Stat.onEraseWhileFind();
}
else {
bool find_min_position( position& pos )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
node_type * pPred;
marked_node_ptr pSucc;
// head cannot be deleted
assert( pCur.bits() == 0 );
- if ( pCur.ptr() ) {
+ if ( pCur.ptr()) {
// pSucc contains deletion mark for pCur
pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
+ if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr())
goto retry;
- if ( pSucc.bits() ) {
+ if ( pSucc.bits()) {
// pCur is marked, i.e. logically deleted.
# ifdef _DEBUG
if ( nLevel == 0 )
pCur->m_bUnlinked = true;
# endif
- marked_node_ptr p( pCur.ptr() );
- if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
+ marked_node_ptr p( pCur.ptr());
+ if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr()),
memory_model::memory_order_release, atomics::memory_order_relaxed ))
{
if ( nLevel == 0 ) {
if ( !is_extracted( pSucc )) {
// We cannot free the node at this moment since RCU is locked
// Link deleted nodes to a chain to free later
- pos.dispose( pCur.ptr() );
+ pos.dispose( pCur.ptr());
m_Stat.onEraseWhileFind();
}
else {
bool find_max_position( position& pos )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
node_type * pPred;
marked_node_ptr pSucc;
while ( true ) {
pCur = pPred->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// pCur.bits() means that pPred is logically deleted
goto retry;
}
// pSucc contains deletion mark for pCur
pSucc = pCur->next( nLevel ).load( memory_model::memory_order_acquire );
- if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr() )
+ if ( pPred->next( nLevel ).load( memory_model::memory_order_acquire ).all() != pCur.ptr())
goto retry;
- if ( pSucc.bits() ) {
+ if ( pSucc.bits()) {
// pCur is marked, i.e. logically deleted.
# ifdef _DEBUG
if ( nLevel == 0 )
pCur->m_bUnlinked = true;
# endif
- marked_node_ptr p( pCur.ptr() );
- if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr() ),
+ marked_node_ptr p( pCur.ptr());
+ if ( pPred->next( nLevel ).compare_exchange_strong( p, marked_node_ptr( pSucc.ptr()),
memory_model::memory_order_release, atomics::memory_order_relaxed ))
{
if ( nLevel == 0 ) {
if ( !is_extracted( pSucc )) {
// We cannot free the node at this moment since RCU is locked
// Link deleted nodes to a chain to free later
- pos.dispose( pCur.ptr() );
+ pos.dispose( pCur.ptr());
m_Stat.onEraseWhileFind();
}
else {
goto retry;
}
else {
- if ( !pSucc.ptr() )
+ if ( !pSucc.ptr())
break;
pPred = pCur.ptr();
template <typename Func>
bool insert_at_position( value_type& val, node_type * pNode, position& pos, Func f )
{
- assert( gc::is_locked() );
+ assert( gc::is_locked());
unsigned int nHeight = pNode->height();
pNode->clear_tower();
if ( !pNode->next( nLevel ).compare_exchange_strong( p, q, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
// pNode has been marked as removed while we are inserting it
// Stop inserting
- assert( p.bits() );
+ assert( p.bits());
m_Stat.onLogicDeleteWhileInsert();
return true;
}
p = q;
- if ( pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( q, marked_node_ptr( pNode ), memory_model::memory_order_release, atomics::memory_order_relaxed ) )
+ if ( pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( q, marked_node_ptr( pNode ), memory_model::memory_order_release, atomics::memory_order_relaxed ))
break;
// Renew insert position
bool try_remove_at( node_type * pDel, position& pos, Func f, bool bExtract )
{
assert( pDel != nullptr );
- assert( gc::is_locked() );
+ assert( gc::is_locked());
marked_node_ptr pSucc;
pSucc = pDel->next(0).load( memory_model::memory_order_relaxed );
while ( true ) {
- if ( pSucc.bits() )
+ if ( pSucc.bits())
return false;
int const nMask = bExtract ? 3 : 1;
pSucc = pDel;
for ( int nLevel = static_cast<int>( pDel->height() - 1 ); nLevel >= 0; --nLevel ) {
if ( !pos.pPrev[nLevel]->next(nLevel).compare_exchange_strong( pSucc,
- marked_node_ptr( pDel->next(nLevel).load(memory_model::memory_order_relaxed).ptr() ),
- memory_model::memory_order_release, atomics::memory_order_relaxed) )
+ marked_node_ptr( pDel->next(nLevel).load(memory_model::memory_order_relaxed).ptr()),
+ memory_model::memory_order_release, atomics::memory_order_relaxed))
{
// Do slow erase
find_position( *node_traits::to_value_ptr(pDel), pos, key_comparator(), false );
continue;
while ( pCur != pNull ) {
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// Wait until pCur is removed
unsigned int nAttempt = 0;
while ( pCur.bits() && nAttempt++ < 16 ) {
}
bkoff.reset();
- if ( pCur.bits() ) {
+ if ( pCur.bits()) {
// Maybe, we are on deleted node sequence
// Abort searching, try slow-path
return find_fastpath_abort;
}
}
- if ( pCur.ptr() ) {
- int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr() ), val );
+ if ( pCur.ptr()) {
+ int nCmp = cmp( *node_traits::to_value_ptr( pCur.ptr()), val );
if ( nCmp < 0 ) {
pPred = pCur.ptr();
pCur = pCur->next(nLevel).load( memory_model::memory_order_acquire );
}
else if ( nCmp == 0 ) {
// found
- f( *node_traits::to_value_ptr( pCur.ptr() ), val );
+ f( *node_traits::to_value_ptr( pCur.ptr()), val );
return find_fastpath_found;
}
else // pCur > val - go down
{
rcu_lock rcuLock;
- if ( !find_position( val, pos, cmp, false ) ) {
+ if ( !find_position( val, pos, cmp, false )) {
m_Stat.onEraseFailed();
bRet = false;
}
value_type * do_extract_key( Q const& key, Compare cmp, position& pos )
{
// RCU should be locked!!!
- assert( gc::is_locked() );
+ assert( gc::is_locked());
node_type * pDel;
- if ( !find_position( key, pos, cmp, false ) ) {
+ if ( !find_position( key, pos, cmp, false )) {
m_Stat.onExtractFailed();
pDel = nullptr;
}
value_type * do_extract_min()
{
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
position pos;
node_type * pDel;
{
rcu_lock l;
- if ( !find_min_position( pos ) ) {
+ if ( !find_min_position( pos )) {
m_Stat.onExtractMinFailed();
pDel = nullptr;
}
pDel = pos.pCur;
unsigned int const nHeight = pDel->height();
- if ( try_remove_at( pDel, pos, []( value_type const& ) {}, true ) ) {
+ if ( try_remove_at( pDel, pos, []( value_type const& ) {}, true )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractMinSuccess();
value_type * do_extract_max()
{
- assert( !gc::is_locked() );
+ assert( !gc::is_locked());
position pos;
node_type * pDel;
{
rcu_lock l;
- if ( !find_max_position( pos ) ) {
+ if ( !find_max_position( pos )) {
m_Stat.onExtractMaxFailed();
pDel = nullptr;
}
pDel = pos.pCur;
unsigned int const nHeight = pDel->height();
- if ( try_remove_at( pDel, pos, []( value_type const& ) {}, true ) ) {
+ if ( try_remove_at( pDel, pos, []( value_type const& ) {}, true )) {
--m_ItemCounter;
m_Stat.onRemoveNode( nHeight );
m_Stat.onExtractMaxSuccess();
/// Returns a forward iterator addressing the first element in a set
iterator begin()
{
- return iterator( *m_Head.head() );
+ return iterator( *m_Head.head());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator begin() const
{
- return const_iterator( *m_Head.head() );
+ return const_iterator( *m_Head.head());
}
/// Returns a forward const iterator addressing the first element in a set
const_iterator cbegin() const
{
- return const_iterator( *m_Head.head() );
+ return const_iterator( *m_Head.head());
}
/// Returns a forward iterator that addresses the location succeeding the last element in a set.
{
rcu_lock l;
- if ( !find_position( val, pos, key_comparator(), false ) ) {
+ if ( !find_position( val, pos, key_comparator(), false )) {
m_Stat.onUnlinkFailed();
bRet = false;
}
skip_list theList;
// ...
- typename skip_list::exempt_ptr ep( theList.extract_max() );
+ typename skip_list::exempt_ptr ep( theList.extract_max());
if ( ep ) {
// Deal with ep
//...
this sequence
\code
set.clear();
- assert( set.empty() );
+ assert( set.empty());
\endcode
the assertion could be raised.
void clear()
{
exempt_ptr ep;
- while ( (ep = extract_min()) );
+ while ( (ep = extract_min()));
}
/// Returns maximum height of skip-list. The max height is a constant for each object and does not exceed 32.
#endif
find( Q& key )
{
- return find_iterator_( key, key_comparator() );
+ return find_iterator_( key, key_comparator());
}
//@cond
template <typename Q>
typename std::enable_if< std::is_same<Q, Q>::value && is_iterable_list< ordered_list >::value, iterator >::type
find( Q const& key )
{
- return find_iterator_( key, key_comparator() );
+ return find_iterator_( key, key_comparator());
}
//@endcond
find_with( Q& key, Less pred )
{
CDS_UNUSED( pred );
- return find_iterator_( key, typename ordered_list_adapter::template make_compare_from_less<Less>() );
+ return find_iterator_( key, typename ordered_list_adapter::template make_compare_from_less<Less>());
}
//@cond
template <typename Q, typename Less>
find_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_iterator_( key, typename ordered_list_adapter::template make_compare_from_less<Less>() );
+ return find_iterator_( key, typename ordered_list_adapter::template make_compare_from_less<Less>());
}
//@endcond
if ( pBucket )
return pBucket;
- pBucket = alloc_aux_node( split_list::dummy_hash( nBucket ) );
+ pBucket = alloc_aux_node( split_list::dummy_hash( nBucket ));
if ( pBucket ) {
- if ( m_List.insert_aux_node( pParentBucket, pBucket ) ) {
+ if ( m_List.insert_aux_node( pParentBucket, pBucket )) {
m_Buckets.bucket( nBucket, pBucket );
m_Stat.onNewBucket();
return pBucket;
if ( pHead == nullptr )
pHead = init_bucket( nBucket );
- assert( pHead->is_dummy() );
+ assert( pHead->is_dummy());
return pHead;
}
assert( pNode != nullptr );
// insert_aux_node cannot return false for empty list
- CDS_VERIFY( m_List.insert_aux_node( pNode ) );
+ CDS_VERIFY( m_List.insert_aux_node( pNode ));
m_Buckets.bucket( 0, pNode );
}
size_t sz = m_nBucketCountLog2.load( memory_model::memory_order_relaxed );
const size_t nBucketCount = static_cast<size_t>(1) << sz;
- if ( nBucketCount < m_Buckets.capacity() ) {
+ if ( nBucketCount < m_Buckets.capacity()) {
// we may grow the bucket table
const size_t nLoadFactor = m_Buckets.load_factor();
- if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor ) )
+ if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor ))
return; // someone already have updated m_nBucketCountLog2, so stop here
m_nMaxItemCount.compare_exchange_strong( nMaxCount, max_item_count( nBucketCount << 1, nLoadFactor ),
bool find_( Q& val, Compare cmp, Func f )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
bool find_( Q const& val, Compare cmp )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- return m_Stat.onFind( m_List.find_at( pHead, sv, cmp ) );
+ return m_Stat.onFind( m_List.find_at( pHead, sv, cmp ));
}
template <typename Q, typename Compare>
iterator find_iterator_( Q const& val, Compare cmp )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
guarded_ptr get_( Q const& val, Compare cmp )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
guarded_ptr gp = m_List.get_at( pHead, sv, cmp );
- m_Stat.onFind( !gp.empty() );
+ m_Stat.onFind( !gp.empty());
return gp;
}
template <typename Q>
guarded_ptr get_( Q const& key )
{
- return get_( key, key_comparator() );
+ return get_( key, key_comparator());
}
template <typename Q, typename Less>
guarded_ptr get_with_( Q const& key, Less )
{
- return get_( key, typename ordered_list_adapter::template make_compare_from_less<Less>() );
+ return get_( key, typename ordered_list_adapter::template make_compare_from_less<Less>());
}
template <typename Q, typename Compare, typename Func>
bool erase_( Q const& val, Compare cmp, Func f )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.erase_at( pHead, sv, cmp, f ) ) {
+ if ( m_List.erase_at( pHead, sv, cmp, f )) {
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
bool erase_( Q const& val, Compare cmp )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.erase_at( pHead, sv, cmp ) ) {
+ if ( m_List.erase_at( pHead, sv, cmp )) {
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
guarded_ptr extract_( Q const& val, Compare cmp )
{
size_t nHash = hash_value( val );
- split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ) );
+ split_list::details::search_value_type<Q const> sv( val, split_list::regular_hash( nHash ));
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
template <typename Q>
guarded_ptr extract_( Q const& key )
{
- return extract_( key, key_comparator() );
+ return extract_( key, key_comparator());
}
template <typename Q, typename Less>
guarded_ptr extract_with_( Q const& key, Less )
{
- return extract_( key, typename ordered_list_adapter::template make_compare_from_less<Less>() );
+ return extract_( key, typename ordered_list_adapter::template make_compare_from_less<Less>());
}
//@endcond
*/
SplitListSet()
: m_nBucketCountLog2(1)
- , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) )
+ , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()))
{
init();
}
)
: m_Buckets( nItemCount, nLoadFactor )
, m_nBucketCountLog2(1)
- , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) )
+ , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()))
{
init();
}
value_type * contains( Q const& key )
{
iterator it = find_( key );
- if ( it == end() )
+ if ( it == end())
return nullptr;
return &*it;
}
value_type * contains( Q const& key, Less pred )
{
iterator it = find_with_( key, pred );
- if ( it == end() )
+ if ( it == end())
return nullptr;
return &*it;
}
*/
iterator begin()
{
- return iterator( m_List.begin(), m_List.end() );
+ return iterator( m_List.begin(), m_List.end());
}
/// Returns an iterator that addresses the location succeeding the last element in a split-list
*/
iterator end()
{
- return iterator( m_List.end(), m_List.end() );
+ return iterator( m_List.end(), m_List.end());
}
/// Returns a forward const iterator addressing the first element in a split-list
const_iterator begin() const
{
- return const_iterator( m_List.begin(), m_List.end() );
+ return const_iterator( m_List.begin(), m_List.end());
}
/// Returns a forward const iterator addressing the first element in a split-list
const_iterator cbegin() const
{
- return const_iterator( m_List.cbegin(), m_List.cend() );
+ return const_iterator( m_List.cbegin(), m_List.cend());
}
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
const_iterator end() const
{
- return const_iterator( m_List.end(), m_List.end() );
+ return const_iterator( m_List.end(), m_List.end());
}
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
const_iterator cend() const
{
- return const_iterator( m_List.cend(), m_List.cend() );
+ return const_iterator( m_List.cend(), m_List.cend());
}
//@}
node_traits::to_node_ptr( val )->m_nHash = split_list::regular_hash( nHash );
list_iterator it = m_List.insert_at_( pHead, val );
- if ( it != m_List.end() ) {
+ if ( it != m_List.end()) {
inc_item_count();
m_Stat.onInsertSuccess();
- return iterator( it, m_List.end() );
+ return iterator( it, m_List.end());
}
m_Stat.onInsertFailed();
return end();
node_traits::to_node_ptr( val )->m_nHash = split_list::regular_hash( nHash );
std::pair<list_iterator, bool> ret = m_List.update_at_( pHead, val, func, bAllowInsert );
- if ( ret.first != m_List.end() ) {
+ if ( ret.first != m_List.end()) {
if ( ret.second ) {
inc_item_count();
m_Stat.onUpdateNew();
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- auto it = m_List.find_at_( pHead, sv, typename ordered_list_adapter::template make_compare_from_less<Less>() );
- m_Stat.onFind( it != m_List.end() );
- return iterator( it, m_List.end() );
+ auto it = m_List.find_at_( pHead, sv, typename ordered_list_adapter::template make_compare_from_less<Less>());
+ m_Stat.onFind( it != m_List.end());
+ return iterator( it, m_List.end());
}
template <typename Q>
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- auto it = m_List.find_at_( pHead, sv, key_comparator() );
- m_Stat.onFind( it != m_List.end() );
- return iterator( it, m_List.end() );
+ auto it = m_List.find_at_( pHead, sv, key_comparator());
+ m_Stat.onFind( it != m_List.end());
+ return iterator( it, m_List.end());
}
template <typename Q, typename Compare, typename Func>
aux_node_type * pBucket = m_Buckets.bucket( nBucket );
back_off bkoff;
- for ( ;; pBucket = m_Buckets.bucket( nBucket ) ) {
+ for ( ;; pBucket = m_Buckets.bucket( nBucket )) {
if ( pBucket )
return pBucket;
- pBucket = alloc_aux_node( split_list::dummy_hash( nBucket ) );
+ pBucket = alloc_aux_node( split_list::dummy_hash( nBucket ));
if ( pBucket ) {
- if ( m_List.insert_aux_node( pParentBucket, pBucket ) ) {
+ if ( m_List.insert_aux_node( pParentBucket, pBucket )) {
m_Buckets.bucket( nBucket, pBucket );
m_Stat.onNewBucket();
return pBucket;
}
// Another thread set the bucket. Wait while it done
- for ( pBucket = m_Buckets.bucket( nBucket ); pBucket == nullptr; pBucket = m_Buckets.bucket( nBucket ) ) {
+ for ( pBucket = m_Buckets.bucket( nBucket ); pBucket == nullptr; pBucket = m_Buckets.bucket( nBucket )) {
bkoff();
m_Stat.onBusyWaitBucketInit();
}
if ( pHead == nullptr )
pHead = init_bucket( nBucket );
- assert( pHead->is_dummy() );
+ assert( pHead->is_dummy());
return pHead;
}
aux_node_type * pNode = alloc_aux_node( 0 /*split_list::dummy_hash(0)*/ );
// insert_aux_node cannot return false for empty list
- CDS_VERIFY( m_List.insert_aux_node( pNode ) );
+ CDS_VERIFY( m_List.insert_aux_node( pNode ));
m_Buckets.bucket( 0, pNode );
}
size_t sz = m_nBucketCountLog2.load( memory_model::memory_order_relaxed );
const size_t nBucketCount = static_cast<size_t>(1) << sz;
- if ( nBucketCount < m_Buckets.capacity() ) {
+ if ( nBucketCount < m_Buckets.capacity()) {
// we may grow the bucket table
const size_t nLoadFactor = m_Buckets.load_factor();
- if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor ) )
+ if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor ))
return; // someone already have updated m_nBucketCountLog2, so stop here
m_nMaxItemCount.compare_exchange_strong( nMaxCount, max_item_count( nBucketCount << 1, nLoadFactor ),
*/
SplitListSet()
: m_nBucketCountLog2(1)
- , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) )
+ , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()))
{
init();
}
)
: m_Buckets( nItemCount, nLoadFactor )
, m_nBucketCountLog2(1)
- , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()) )
+ , m_nMaxItemCount( max_item_count(2, m_Buckets.load_factor()))
{
init();
}
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.unlink_at( pHead, val ) ) {
+ if ( m_List.unlink_at( pHead, val )) {
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
template <typename Q>
bool erase( Q const& key )
{
- return erase_( key, key_comparator() );
+ return erase_( key, key_comparator());
}
/// Deletes the item from the set using \p pred for searching
bool erase_with( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return erase_( key, typename ordered_list_adapter::template make_compare_from_less<Less>() );
+ return erase_( key, typename ordered_list_adapter::template make_compare_from_less<Less>());
}
/// Deletes the item from the set
template <typename Q>
exempt_ptr extract( Q const& key )
{
- return exempt_ptr(extract_( key, key_comparator() ));
+ return exempt_ptr(extract_( key, key_comparator()));
}
/// Extracts an item from the set using \p pred for searching
template <typename Q>
bool contains( Q const& key )
{
- return find_value( key, key_comparator() );
+ return find_value( key, key_comparator());
}
//@cond
template <typename Q>
bool contains( Q const& key, Less pred )
{
CDS_UNUSED( pred );
- return find_value( key, typename ordered_list_adapter::template make_compare_from_less<Less>() );
+ return find_value( key, typename ordered_list_adapter::template make_compare_from_less<Less>());
}
//@cond
template <typename Q, typename Less>
template <typename Q>
raw_ptr get( Q const& key )
{
- return get_( key, key_comparator() );
+ return get_( key, key_comparator());
}
/// Finds the key \p key and return the item found
void clear()
{
iterator it = begin();
- while ( it != end() ) {
+ while ( it != end()) {
iterator i(it);
++i;
unlink( *it );
*/
iterator begin()
{
- return iterator( m_List.begin(), m_List.end() );
+ return iterator( m_List.begin(), m_List.end());
}
/// Returns an iterator that addresses the location succeeding the last element in a split-list
*/
iterator end()
{
- return iterator( m_List.end(), m_List.end() );
+ return iterator( m_List.end(), m_List.end());
}
/// Returns a forward const iterator addressing the first element in a split-list
/// Returns a forward const iterator addressing the first element in a split-list
const_iterator cbegin() const
{
- return const_iterator( m_List.cbegin(), m_List.cend() );
+ return const_iterator( m_List.cbegin(), m_List.cend());
}
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
/// Returns an const iterator that addresses the location succeeding the last element in a split-list
const_iterator cend() const
{
- return const_iterator( m_List.cend(), m_List.cend() );
+ return const_iterator( m_List.cend(), m_List.cend());
}
//@}
static size_t parent_bucket( size_t nBucket )
{
assert( nBucket > 0 );
- return nBucket & ~( 1 << bitop::MSBnz( nBucket ) );
+ return nBucket & ~( 1 << bitop::MSBnz( nBucket ));
}
aux_node_type * init_bucket( size_t const nBucket )
aux_node_type * pBucket = m_Buckets.bucket( nBucket );
back_off bkoff;
- for ( ;; pBucket = m_Buckets.bucket( nBucket ) ) {
+ for ( ;; pBucket = m_Buckets.bucket( nBucket )) {
if ( pBucket )
return pBucket;
- pBucket = alloc_aux_node( split_list::dummy_hash( nBucket ) );
+ pBucket = alloc_aux_node( split_list::dummy_hash( nBucket ));
if ( pBucket ) {
- if ( m_List.insert_aux_node( pParentBucket, pBucket ) ) {
+ if ( m_List.insert_aux_node( pParentBucket, pBucket )) {
m_Buckets.bucket( nBucket, pBucket );
m_Stat.onNewBucket();
return pBucket;
}
// Another thread set the bucket. Wait while it done
- for ( pBucket = m_Buckets.bucket( nBucket ); pBucket == nullptr; pBucket = m_Buckets.bucket( nBucket ) ) {
+ for ( pBucket = m_Buckets.bucket( nBucket ); pBucket == nullptr; pBucket = m_Buckets.bucket( nBucket )) {
bkoff();
m_Stat.onBusyWaitBucketInit();
}
if ( pHead == nullptr )
pHead = init_bucket( nBucket );
- assert( pHead->is_dummy() );
+ assert( pHead->is_dummy());
return pHead;
}
size_t sz = m_nBucketCountLog2.load(memory_model::memory_order_relaxed);
const size_t nBucketCount = static_cast<size_t>(1) << sz;
- if ( nBucketCount < m_Buckets.capacity() ) {
+ if ( nBucketCount < m_Buckets.capacity()) {
// we may grow the bucket table
const size_t nLoadFactor = m_Buckets.load_factor();
if ( nMaxCount < max_item_count( nBucketCount, nLoadFactor ))
aux_node_type * pHead = get_bucket( nHash );
assert( pHead != nullptr );
- if ( m_List.erase_at( pHead, sv, cmp ) ) {
+ if ( m_List.erase_at( pHead, sv, cmp )) {
--m_ItemCounter;
m_Stat.onEraseSuccess();
return true;
for ( bucket_iterator it = pCur->begin(); it != itEnd; it = itNext ) {
itNext = it;
++itNext;
- bucket( m_Hash( *it ) )->move_item( *pCur, it );
+ bucket( m_Hash( *it ))->move_item( *pCur, it );
}
pCur->clear();
}
size_t volatile& refBucketMask = m_nBucketMask;
scoped_resize_lock al( m_MutexPolicy );
- if ( al.success() ) {
+ if ( al.success()) {
if ( nOldCapacity != refBucketMask + 1 ) {
// someone resized already
return;
: m_Buckets( nullptr )
, m_nBucketMask( ( nCapacity ? calc_init_capacity(nCapacity) : c_nMinimalCapacity ) - 1 )
, m_MutexPolicy( m_nBucketMask + 1 )
- , m_ResizingPolicy( std::forward<resizing_policy>( resizingPolicy ) )
+ , m_ResizingPolicy( std::forward<resizing_policy>( resizingPolicy ))
{
alloc_bucket_table( m_nBucketMask + 1 );
}
return std::make_pair( true, res.second );
}
else {
- auto it = m_Set.find( val, key_comparator() );
- if ( it == m_Set.end() )
+ auto it = m_Set.find( val, key_comparator());
+ if ( it == m_Set.end())
return std::make_pair( false, false );
f( false, *it, val );
return std::make_pair( true, false );
bool unlink( value_type& val )
{
- iterator it = m_Set.find( val, key_comparator() );
+ iterator it = m_Set.find( val, key_comparator());
if ( it == m_Set.end() || &(*it) != &val )
return false;
m_Set.erase( it );
template <typename Q, typename Func>
value_type * erase( Q const& key, Func f )
{
- iterator it = m_Set.find( key, key_comparator() );
+ iterator it = m_Set.find( key, key_comparator());
if (it == m_Set.end())
return nullptr;
value_type& val = *it;
bool find( Q const& key, Compare cmp, Func f )
{
iterator it = m_Set.find( key, cmp );
- if ( it == m_Set.end() )
+ if ( it == m_Set.end())
return false;
f( *it, key );
return true;
iterator itEnd = m_List.end();
iterator it;
for ( it = m_List.begin(); it != itEnd; ++it ) {
- if ( !pred( *it, key ) )
+ if ( !pred( *it, key ))
break;
}
return it;
template <typename Func>
bool insert( value_type& val, Func f )
{
- iterator it = find_key( val, find_predicate() );
+ iterator it = find_key( val, find_predicate());
if ( it == m_List.end() || key_comparator()(val, *it) != 0 ) {
m_List.insert( it, val );
f( val );
template <typename Func>
std::pair<bool, bool> update( value_type& val, Func f, bool bAllowInsert )
{
- iterator it = find_key( val, find_predicate() );
+ iterator it = find_key( val, find_predicate());
if ( it == m_List.end() || key_comparator()(val, *it) != 0 ) {
// insert new
if ( !bAllowInsert )
bool unlink( value_type& val )
{
- iterator it = find_key( val, find_predicate() );
+ iterator it = find_key( val, find_predicate());
if ( it == m_List.end() || &(*it) != &val )
return false;
template <typename Q, typename Func>
value_type * erase( Q const& key, Func f )
{
- iterator it = find_key( key, find_predicate() );
+ iterator it = find_key( key, find_predicate());
if ( it == m_List.end() || key_comparator()(key, *it) != 0 )
return nullptr;
value_type * erase( Q const& key, Less pred, Func f )
{
iterator it = find_key( key, pred );
- if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ))
return nullptr;
// key exists
bool find( Q& key, Less pred, Func f )
{
iterator it = find_key( key, pred );
- if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ) )
+ if ( it == m_List.end() || pred( key, *it ) || pred( *it, key ))
return false;
// key exists
iterator itPrev = m_List.before_begin();
iterator itEnd = m_List.end();
for ( iterator it = m_List.begin(); it != itEnd; ++it ) {
- if ( pred( key, *it ) )
+ if ( pred( key, *it ))
itPrev = it;
- else if ( pred( *it, key ) )
+ else if ( pred( *it, key ))
break;
else
return std::make_pair( itPrev, true );
template <typename Q>
std::pair< iterator, bool > find_prev_item( Q const& key )
{
- return find_prev_item_cmp( key, key_comparator() );
+ return find_prev_item_cmp( key, key_comparator());
}
template <typename Q, typename Compare>
public:
adapted_container()
- : m_Set( typename container_type::bucket_traits( m_Buckets.buffer(), m_Buckets.capacity() ) )
+ : m_Set( typename container_type::bucket_traits( m_Buckets.buffer(), m_Buckets.capacity()) )
{}
container_type& base_container()
}
else {
auto it = m_Set.find( val );
- if ( it == m_Set.end() )
+ if ( it == m_Set.end())
return std::make_pair( false, false );
f( false, *it, val );
return std::make_pair( true, false );
bool unlink( value_type& val )
{
- iterator it = m_Set.find( value_type( val ) );
+ iterator it = m_Set.find( value_type( val ));
if ( it == m_Set.end() || &(*it) != &val )
return false;
m_Set.erase( it );
template <typename Q, typename Func>
value_type * erase( Q const& key, Func f )
{
- iterator it = m_Set.find( key, typename container_type::hasher(), typename container_type::key_equal() );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( key, typename container_type::hasher(), typename container_type::key_equal());
+ if ( it == m_Set.end())
return nullptr;
value_type& val = *it;
f( val );
template <typename Q, typename Less, typename Func>
value_type * erase( Q const& key, Less pred, Func f )
{
- iterator it = m_Set.find( key, typename container_type::hasher(), equal_from_compare<Less>( pred ) );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( key, typename container_type::hasher(), equal_from_compare<Less>( pred ));
+ if ( it == m_Set.end())
return nullptr;
value_type& val = *it;
f( val );
template <typename Q, typename Func>
bool find( Q& key, Func f )
{
- iterator it = m_Set.find( key, typename container_type::hasher(), typename container_type::key_equal() );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( key, typename container_type::hasher(), typename container_type::key_equal());
+ if ( it == m_Set.end())
return false;
f( *it, key );
return true;
template <typename Q, typename Less, typename Func>
bool find( Q& key, Less pred, Func f )
{
- iterator it = m_Set.find( key, typename container_type::hasher(), equal_from_compare<Less>( pred ) );
- if ( it == m_Set.end() )
+ iterator it = m_Set.find( key, typename container_type::hasher(), equal_from_compare<Less>( pred ));
+ if ( it == m_Set.end())
return false;
f( *it, key );
return true;
lock_array_ptr create_lock_array( size_t nCapacity )
{
m_nCapacity.store( nCapacity, atomics::memory_order_relaxed );
- return lock_array_ptr( lock_array_allocator().New( nCapacity ), lock_array_disposer() );
+ return lock_array_ptr( lock_array_allocator().New( nCapacity ), lock_array_disposer());
}
lock_type& acquire( size_t nHash )
// wait while resizing
while ( true ) {
who = m_Owner.load( atomics::memory_order_acquire );
- if ( !( who & 1 ) || (who >> 1) == (me & c_nOwnerMask) )
+ if ( !( who & 1 ) || (who >> 1) == (me & c_nOwnerMask))
break;
bkoff();
}
lock.lock();
who = m_Owner.load( atomics::memory_order_acquire );
- if ( ( !(who & 1) || (who >> 1) == (me & c_nOwnerMask) ) && m_arrLocks == pLocks )
+ if ( ( !(who & 1) || (who >> 1) == (me & c_nOwnerMask)) && m_arrLocks == pLocks )
return lock;
lock.unlock();
}
// wait while resizing
while ( true ) {
who = m_Owner.load( atomics::memory_order_acquire );
- if ( !( who & 1 ) || (who >> 1) == (me & c_nOwnerMask) )
+ if ( !( who & 1 ) || (who >> 1) == (me & c_nOwnerMask))
break;
bkoff();
}
pLocks->lock_all();
who = m_Owner.load( atomics::memory_order_acquire );
- if ( ( !(who & 1) || (who >> 1) == (me & c_nOwnerMask) ) && m_arrLocks == pLocks )
+ if ( ( !(who & 1) || (who >> 1) == (me & c_nOwnerMask)) && m_arrLocks == pLocks )
return pLocks;
pLocks->unlock_all();
for ( size_t i = 0; i < nLockCount; ++i ) {
typename lock_array_type::lock_type& lock = pOldLocks->at(i);
bkoff.reset();
- while ( !lock.try_lock() )
+ while ( !lock.try_lock())
bkoff();
lock.unlock();
}
public:
scoped_cell_lock( refinable& policy, size_t nHash )
- : m_guard( policy.acquire( nHash ), std::adopt_lock_t() )
+ : m_guard( policy.acquire( nHash ), std::adopt_lock_t())
{}
};
pTop = m_Top.load( memory_model::memory_order_relaxed );
if ( pTop == nullptr )
return;
- if ( m_Top.compare_exchange_weak( pTop, nullptr, memory_model::memory_order_acquire, atomics::memory_order_relaxed ) ) {
+ if ( m_Top.compare_exchange_weak( pTop, nullptr, memory_model::memory_order_acquire, atomics::memory_order_relaxed )) {
m_ItemCounter.reset();
break;
}
node_type * p = pTop;
pTop = p->m_pNext.load(memory_model::memory_order_relaxed);
clear_links( p );
- gc::template retire<disposer>( node_traits::to_value_ptr( *p ) );
+ gc::template retire<disposer>( node_traits::to_value_ptr( *p ));
}
}
index_type temp = ( ate + 1 ) & nModulo ; // next item after tail
// Looking for actual tail
- while ( !is_free( tt ) ) {
- if ( te != m_nTail.load(memory_model::memory_order_relaxed) ) // check the tail consistency
+ while ( !is_free( tt )) {
+ if ( te != m_nTail.load(memory_model::memory_order_relaxed)) // check the tail consistency
goto TryAgain;
- if ( temp == m_nHead.load(memory_model::memory_order_acquire) ) // queue full?
+ if ( temp == m_nHead.load(memory_model::memory_order_acquire)) // queue full?
break;
tt = m_buffer[ temp ].load(memory_model::memory_order_relaxed);
ate = temp;
temp = (temp + 1) & nModulo;
}
- if ( te != m_nTail.load(memory_model::memory_order_acquire) )
+ if ( te != m_nTail.load(memory_model::memory_order_acquire))
continue;
// Check whether queue is full
- if ( temp == m_nHead.load(memory_model::memory_order_acquire) ) {
+ if ( temp == m_nHead.load(memory_model::memory_order_acquire)) {
ate = ( temp + 1 ) & nModulo;
tt = m_buffer[ ate ].load(memory_model::memory_order_relaxed);
- if ( !is_free( tt ) ) {
+ if ( !is_free( tt )) {
return false; // Queue is full
}
continue;
}
- if ( tt == reinterpret_cast<value_type *>(free1) )
+ if ( tt == reinterpret_cast<value_type *>(free1))
pNewNode = reinterpret_cast<value_type *>(reinterpret_cast<intptr_t>( pNewNode ) | 1);
- if ( te != m_nTail.load(memory_model::memory_order_acquire) )
+ if ( te != m_nTail.load(memory_model::memory_order_acquire))
continue;
// get actual tail and try to enqueue new node
- if ( m_buffer[ate].compare_exchange_strong( tt, pNewNode, memory_model::memory_order_release, atomics::memory_order_relaxed ) ) {
+ if ( m_buffer[ate].compare_exchange_strong( tt, pNewNode, memory_model::memory_order_release, atomics::memory_order_relaxed )) {
if ( temp % 2 == 0 )
m_nTail.compare_exchange_strong( te, temp, memory_model::memory_order_release, atomics::memory_order_relaxed );
++m_ItemCounter;
value_type * pNull;
// find the actual head after this loop
- while ( is_free( tt ) ) {
- if ( th != m_nHead.load(memory_model::memory_order_relaxed) )
+ while ( is_free( tt )) {
+ if ( th != m_nHead.load(memory_model::memory_order_relaxed))
goto TryAgain;
// two consecutive nullptr means the queue is empty
- if ( temp == m_nTail.load(memory_model::memory_order_acquire) )
+ if ( temp == m_nTail.load(memory_model::memory_order_acquire))
return nullptr;
temp = ( temp + 1 ) & nModulo;
tt = m_buffer[ temp ].load(memory_model::memory_order_relaxed);
}
- if ( th != m_nHead.load(memory_model::memory_order_relaxed) )
+ if ( th != m_nHead.load(memory_model::memory_order_relaxed))
continue;
// check whether the queue is empty
- if ( temp == m_nTail.load(memory_model::memory_order_acquire) ) {
+ if ( temp == m_nTail.load(memory_model::memory_order_acquire)) {
// help the enqueue to update end
m_nTail.compare_exchange_weak( temp, (temp + 1) & nModulo, memory_model::memory_order_release, atomics::memory_order_relaxed );
continue;
pNull = reinterpret_cast<value_type *>((reinterpret_cast<uintptr_t>(tt) & 1) ? free0 : free1);
- if ( th != m_nHead.load(memory_model::memory_order_relaxed) )
+ if ( th != m_nHead.load(memory_model::memory_order_relaxed))
continue;
// Get the actual head, null means empty
const value_type * tt = m_buffer[ temp ].load(memory_model::memory_order_relaxed);
// find the actual head after this loop
- while ( is_free( tt ) ) {
- if ( th != m_nHead.load(memory_model::memory_order_relaxed) )
+ while ( is_free( tt )) {
+ if ( th != m_nHead.load(memory_model::memory_order_relaxed))
goto TryAgain;
// two consecutive nullptr means queue empty
- if ( temp == m_nTail.load(memory_model::memory_order_relaxed) )
+ if ( temp == m_nTail.load(memory_model::memory_order_relaxed))
return true;
temp = ( temp + 1 ) & nModulo;
tt = m_buffer[ temp ].load(memory_model::memory_order_relaxed);
*/
void clear()
{
- clear( disposer() );
+ clear( disposer());
}
/// Returns queue's item count
*/
void clear()
{
- clear( disposer() );
+ clear( disposer());
}
/// Checks if the queue is empty
~page_cached_allocator()
{
void * pPage;
- while ( m_FreeList.pop(pPage) )
+ while ( m_FreeList.pop(pPage))
base_class::free( pPage );
}
//@endcond
void * alloc()
{
void * pPage;
- if ( !m_FreeList.pop( pPage ) )
+ if ( !m_FreeList.pop( pPage ))
pPage = base_class::alloc();
return pPage;
}
/// Gets details::size_class struct for size-class index \p nIndex
static const size_class * at( sizeclass_index nIndex )
{
- assert( nIndex < size() );
+ assert( nIndex < size());
return m_szClass + nIndex;
}
};
/// Push superblock descriptor to free-list
void push( T * pDesc )
{
- assert( base_class::node_algorithms::inited( static_cast<item_hook *>(pDesc) ) );
+ assert( base_class::node_algorithms::inited( static_cast<item_hook *>(pDesc)) );
auto_lock al(m_access);
base_class::push_back( *pDesc );
}
T * pop()
{
auto_lock al(m_access);
- if ( base_class::empty() )
+ if ( base_class::empty())
return nullptr;
T& rDesc = base_class::front();
base_class::pop_front();
- assert( base_class::node_algorithms::inited( static_cast<item_hook *>(&rDesc) ) );
+ assert( base_class::node_algorithms::inited( static_cast<item_hook *>(&rDesc)) );
return &rDesc;
}
void push( T * pDesc )
{
auto_lock al( m_access );
- assert( base_class::node_algorithms::inited( static_cast<item_hook *>(pDesc) ) );
+ assert( base_class::node_algorithms::inited( static_cast<item_hook *>(pDesc)) );
base_class::push_back( *pDesc );
}
T * pop()
{
auto_lock al( m_access );
- if ( base_class::empty() )
+ if ( base_class::empty())
return nullptr;
T& rDesc = base_class::front();
base_class::pop_front();
- assert( base_class::node_algorithms::inited( static_cast<item_hook *>(&rDesc) ) );
+ assert( base_class::node_algorithms::inited( static_cast<item_hook *>(&rDesc)) );
return &rDesc;
}
assert(pDesc != nullptr);
auto_lock al( m_access );
// !inited(pDesc) is equal to "pDesc is being linked to partial list"
- if ( !base_class::node_algorithms::inited( static_cast<item_hook *>(pDesc) ) ) {
- base_class::erase( base_class::iterator_to( *pDesc ) );
+ if ( !base_class::node_algorithms::inited( static_cast<item_hook *>(pDesc)) ) {
+ base_class::erase( base_class::iterator_to( *pDesc ));
return true;
}
return false;
size_t getOSAllocSize() const
{
- assert( isOSAllocated() );
+ assert( isOSAllocated());
return nSize;
}
superblock_desc * desc()
{
- assert( !isOSAllocated() );
- return (pDesc.bits() & bitAligned) ? reinterpret_cast<block_header *>( pDesc.ptr() )->desc() : pDesc.ptr();
+ assert( !isOSAllocated());
+ return (pDesc.bits() & bitAligned) ? reinterpret_cast<block_header *>( pDesc.ptr())->desc() : pDesc.ptr();
}
block_header * begin()
{
- return (pDesc.bits() & bitAligned) ? reinterpret_cast<block_header *>( pDesc.ptr() ) : this;
+ return (pDesc.bits() & bitAligned) ? reinterpret_cast<block_header *>( pDesc.ptr()) : this;
}
bool isAligned() const
size_t getOSAllocSize() const
{
- assert( isOSAllocated() );
- return reinterpret_cast<uintptr_t>( pDesc.ptr() ) >> 2;
+ assert( isOSAllocated());
+ return reinterpret_cast<uintptr_t>( pDesc.ptr()) >> 2;
}
};
pDesc = partialList.pop();
break;
}
- } while ( !pPartial.compare_exchange_weak( pDesc, nullptr, atomics::memory_order_release, atomics::memory_order_relaxed ) );
+ } while ( !pPartial.compare_exchange_weak( pDesc, nullptr, atomics::memory_order_release, atomics::memory_order_relaxed ));
- //assert( pDesc == nullptr || free_desc_list<superblock_desc>::node_algorithms::inited( static_cast<sb_free_list_hook *>(pDesc) ));
- //assert( pDesc == nullptr || partial_desc_list<superblock_desc>::node_algorithms::inited( static_cast<sb_partial_list_hook *>(pDesc) ) );
+ //assert( pDesc == nullptr || free_desc_list<superblock_desc>::node_algorithms::inited( static_cast<sb_free_list_hook *>(pDesc)));
+ //assert( pDesc == nullptr || partial_desc_list<superblock_desc>::node_algorithms::inited( static_cast<sb_partial_list_hook *>(pDesc)) );
return pDesc;
}
void add_partial( superblock_desc * pDesc )
{
assert( pPartial != pDesc );
- //assert( partial_desc_list<superblock_desc>::node_algorithms::inited( static_cast<sb_partial_list_hook *>(pDesc) ) );
+ //assert( partial_desc_list<superblock_desc>::node_algorithms::inited( static_cast<sb_partial_list_hook *>(pDesc)) );
superblock_desc * pCur = nullptr;
- if ( !pPartial.compare_exchange_strong(pCur, pDesc, atomics::memory_order_acq_rel, atomics::memory_order_relaxed) )
+ if ( !pPartial.compare_exchange_strong(pCur, pDesc, atomics::memory_order_acq_rel, atomics::memory_order_relaxed))
partialList.push( pDesc );
}
/// Allocates large block from system memory
block_header * alloc_from_OS( size_t nSize )
{
- block_header * p = reinterpret_cast<block_header *>( m_LargeHeap.alloc( nSize ) );
+ block_header * p = reinterpret_cast<block_header *>( m_LargeHeap.alloc( nSize ));
m_OSAllocStat.incBytesAllocated( nSize );
p->setOSAllocated( nSize );
return p;
while ( true ) {
++nCollision;
oldActive = pProcHeap->active.load(atomics::memory_order_acquire);
- if ( !oldActive.ptr() )
+ if ( !oldActive.ptr())
return nullptr;
unsigned int nCredits = oldActive.credits();
active_tag newActive ; // default = 0
// block_header fields is not needed to setup
// It was set in alloc_from_new_superblock
assert( reinterpret_cast<block_header *>( pAddr )->desc() == pDesc );
- assert( !reinterpret_cast<block_header *>( pAddr )->isOSAllocated() );
- assert( !reinterpret_cast<block_header *>( pAddr )->isAligned() );
+ assert( !reinterpret_cast<block_header *>( pAddr )->isOSAllocated());
+ assert( !reinterpret_cast<block_header *>( pAddr )->isAligned());
return reinterpret_cast<block_header *>( pAddr );
}
newAnchor.count -= nMoreCredits + 1;
newAnchor.state = (nMoreCredits > 0) ? SBSTATE_ACTIVE : SBSTATE_FULL;
newAnchor.tag += 1;
- } while ( !pDesc->anchor.compare_exchange_strong(oldAnchor, newAnchor, atomics::memory_order_release, atomics::memory_order_relaxed) );
+ } while ( !pDesc->anchor.compare_exchange_strong(oldAnchor, newAnchor, atomics::memory_order_release, atomics::memory_order_relaxed));
if ( nCollision )
pProcHeap->stat.incPartialDescCASFailureCount( nCollision );
pAddr = pDesc->pSB + oldAnchor.avail * pDesc->nBlockSize;
newAnchor.avail = reinterpret_cast<free_block_header *>( pAddr )->nNextFree;
++newAnchor.tag;
- } while ( !pDesc->anchor.compare_exchange_strong(oldAnchor, newAnchor, atomics::memory_order_release, atomics::memory_order_relaxed) );
+ } while ( !pDesc->anchor.compare_exchange_strong(oldAnchor, newAnchor, atomics::memory_order_release, atomics::memory_order_relaxed));
if ( nCollision )
pProcHeap->stat.incPartialAnchorCASFailureCount( nCollision );
// block_header fields is not needed to setup
// It was set in alloc_from_new_superblock
assert( reinterpret_cast<block_header *>( pAddr )->desc() == pDesc );
- assert( !reinterpret_cast<block_header *>( pAddr )->isAligned() );
- assert( !reinterpret_cast<block_header *>( pAddr )->isOSAllocated() );
+ assert( !reinterpret_cast<block_header *>( pAddr )->isAligned());
+ assert( !reinterpret_cast<block_header *>( pAddr )->isOSAllocated());
return reinterpret_cast<block_header *>( pAddr );
}
/// Find appropriate processor heap based on size-class selected
processor_heap * find_heap( typename sizeclass_selector::sizeclass_index nSizeClassIndex )
{
- assert( nSizeClassIndex < m_SizeClassSelector.size() );
+ assert( nSizeClassIndex < m_SizeClassSelector.size());
unsigned int nProcessorId = m_Topology.current_processor();
assert( nProcessorId < m_nProcessorCount );
while ( !pDesc ) {
processor_desc * pNewDesc = new_processor_desc( nProcessorId );
- if ( m_arrProcDesc[nProcessorId].compare_exchange_strong( pDesc, pNewDesc, atomics::memory_order_release, atomics::memory_order_relaxed ) ) {
+ if ( m_arrProcDesc[nProcessorId].compare_exchange_strong( pDesc, pNewDesc, atomics::memory_order_release, atomics::memory_order_relaxed )) {
pDesc = pNewDesc;
break;
}
active_tag newActive;
newActive.set( pDesc, nCredits - 1 );
- if ( pProcHeap->active.compare_exchange_strong( nullActive, newActive, atomics::memory_order_seq_cst, atomics::memory_order_relaxed ) )
+ if ( pProcHeap->active.compare_exchange_strong( nullActive, newActive, atomics::memory_order_seq_cst, atomics::memory_order_relaxed ))
return;
// Someone installed another active superblock.
// TSan false positive: a new descriptor will be linked further with release fence
CDS_TSAN_ANNOTATE_IGNORE_WRITES_BEGIN;
- pDesc = new( m_AlignedHeap.alloc( szTotal, c_nAlignment ) ) processor_desc;
+ pDesc = new( m_AlignedHeap.alloc( szTotal, c_nAlignment )) processor_desc;
pDesc->pageHeaps = reinterpret_cast<page_heap *>( pDesc + 1 );
for ( size_t i = 0; i < nPageHeapCount; ++i )
anchor_tag anchor;
superblock_desc * pDesc = pProcHeap->pProcDesc->listSBDescFree.pop();
if ( pDesc == nullptr ) {
- pDesc = new( m_AlignedHeap.alloc(sizeof(superblock_desc), c_nAlignment ) ) superblock_desc;
+ pDesc = new( m_AlignedHeap.alloc(sizeof(superblock_desc), c_nAlignment )) superblock_desc;
assert( (uintptr_t(pDesc) & (c_nAlignment - 1)) == 0 );
anchor = pDesc->anchor.load( atomics::memory_order_relaxed );
if ( nSizeClassIndex == sizeclass_selector::c_nNoSizeClass ) {
return alloc_from_OS( nSize );
}
- assert( nSizeClassIndex < m_SizeClassSelector.size() );
+ assert( nSizeClassIndex < m_SizeClassSelector.size());
block_header * pBlock;
processor_heap * pProcHeap;
block_header * pBlock = int_alloc( nSize + sizeof(block_header) + bound_checker::trailer_size );
// Bound checking is only for our blocks
- if ( !pBlock->isOSAllocated() ) {
+ if ( !pBlock->isOSAllocated()) {
// the block is allocated from our heap - bound checker is applicable
m_BoundChecker.make_trailer(
reinterpret_cast<byte *>(pBlock + 1),
block_header * pRedirect = (reinterpret_cast<block_header *>( pMemory ) - 1);
block_header * pBlock = pRedirect->begin();
- if ( pBlock->isOSAllocated() ) {
+ if ( pBlock->isOSAllocated()) {
// Block has been allocated from OS
- m_OSAllocStat.incBytesDeallocated( pBlock->getOSAllocSize() );
+ m_OSAllocStat.incBytesDeallocated( pBlock->getOSAllocSize());
m_LargeHeap.free( pBlock );
return;
}
- assert( !pBlock->isAligned() );
+ assert( !pBlock->isAligned());
superblock_desc * pDesc = pBlock->desc();
m_BoundChecker.check_bounds(
}
else
newAnchor.count += 1;
- } while ( !pDesc->anchor.compare_exchange_strong( oldAnchor, newAnchor, atomics::memory_order_release, atomics::memory_order_relaxed ) );
+ } while ( !pDesc->anchor.compare_exchange_strong( oldAnchor, newAnchor, atomics::memory_order_release, atomics::memory_order_relaxed ));
pProcHeap->stat.incFreeCount();
block_header * pBlock = reinterpret_cast<block_header *>( pMemory ) - 1;
// Reallocation of aligned block is not possible
- if ( pBlock->isAligned() ) {
+ if ( pBlock->isAligned()) {
assert( false );
return nullptr;
}
- if ( pBlock->isOSAllocated() ) {
+ if ( pBlock->isOSAllocated()) {
// The block has been allocated from OS
size_t nCurSize = pBlock->getOSAllocSize();
// Grow block size
void * pNewBuf = alloc( nOrigSize );
if ( pNewBuf ) {
- memcpy( pNewBuf, pMemory, nCurSize - sizeof(block_header) );
+ memcpy( pNewBuf, pMemory, nCurSize - sizeof(block_header));
free( pMemory );
}
return pNewBuf;
void * pNew = alloc( nNewSize );
if ( pNew ) {
- memcpy( pNew, pMemory, pDesc->nBlockSize - sizeof(block_header) );
+ memcpy( pNew, pMemory, pDesc->nBlockSize - sizeof(block_header));
free( pMemory );
return pNew;
}
// Bound checking is only for our blocks
- if ( !pBlock->isOSAllocated() ) {
+ if ( !pBlock->isOSAllocated()) {
// the block is allocated from our heap - bound checker is applicable
m_BoundChecker.make_trailer(
reinterpret_cast<byte *>(pRedirect + 1),
assert( reinterpret_cast<char *>(pEndBlock) - (pArea + nAllocSize) >= trailer_size );
trailer_type trailer = s_BoundCheckerTrailer;
- memcpy( pArea + nAllocSize, &trailer, sizeof(trailer) );
+ memcpy( pArea + nAllocSize, &trailer, sizeof(trailer));
// the next assignment is correct because pBlock is at least sizeof(size_t)-byte aligned
assert( (reinterpret_cast<uintptr_t>(pEndBlock) & (sizeof(size_t) - 1)) == 0 );
assert( nAllocSize < nBlockSize );
return nAllocSize < nBlockSize
- && memcmp( reinterpret_cast<char *>(pStartArea) + nAllocSize, &trailer, sizeof(trailer) ) == 0;
+ && memcmp( reinterpret_cast<char *>(pStartArea) + nAllocSize, &trailer, sizeof(trailer)) == 0;
}
};
}
void check_bounds( void * pStartArea, void * pEndBlock, size_t nBlockSize )
{
// Bound checking assertion
- assert( base_class::check_bounds( pStartArea, pEndBlock, nBlockSize ) );
+ assert( base_class::check_bounds( pStartArea, pEndBlock, nBlockSize ));
}
//@endcond
public:
void check_bounds( void * pStartArea, void * pEndBlock, size_t nBlockSize )
{
- if ( !base_class::check_bounds( pStartArea, pEndBlock, nBlockSize ) ) {
+ if ( !base_class::check_bounds( pStartArea, pEndBlock, nBlockSize )) {
throw bound_checker_exception();
}
}
//@cond
void preallocate_pool()
{
- m_pFirst = std_allocator().allocate( m_Queue.capacity() );
+ m_pFirst = std_allocator().allocate( m_Queue.capacity());
m_pLast = m_pFirst + m_Queue.capacity();
for ( value_type * p = m_pFirst; p < m_pLast; ++p ) {
value_type * p = m_Queue.pop();
if ( p ) {
- assert( from_pool(p) );
+ assert( from_pool(p));
return new( p ) value_type;
}
// The pool is empty - allocate new from the heap
CDS_UNUSED(n);
if ( p ) {
- if ( from_pool(p) ) {
+ if ( from_pool(p)) {
p->~value_type();
// The queue can notify about false fullness state
// so we push in loop
~lazy_vyukov_queue_pool()
{
std_allocator a;
- while ( !m_Queue.empty() )
+ while ( !m_Queue.empty())
a.deallocate( m_Queue.pop(), 1 );
}
if ( !p ) {
back_off bkoff;
- while ( m_Queue.size() ) {
+ while ( m_Queue.size()) {
p = m_Queue.pop();
if ( p )
goto ok;
}
ok:
- assert( from_pool(p) );
+ assert( from_pool(p));
return p;
}
back_off bkoff;
// The queue can notify it is full but that is false fullness state
// So, we push in loop
- while ( !m_Queue.push(*p) )
+ while ( !m_Queue.push(*p))
bkoff();
}
}
/// Get item \p i
value_type& operator []( size_t i )
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i].v;
}
/// Get item \p i, const version
const value_type& operator []( size_t i ) const
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i].v;
}
/// Zeroize the buffer
void zeroize()
{
- memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]) );
+ memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]));
}
/// Returns pointer to buffer array
/// Get item \p i
value_type& operator []( size_t i )
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i];
}
/// Get item \p i, const version
const value_type& operator []( size_t i ) const
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i];
}
/// Zeroize the buffer
void zeroize()
{
- memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]) );
+ memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]));
}
/// Returns pointer to buffer array
/// Get item \p i
value_type& operator []( size_t i )
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i];
}
/// Get item \p i, const version
const value_type& operator []( size_t i ) const
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i];
}
/// Zeroize the buffer
void zeroize()
{
- memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]) );
+ memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]));
}
/// Returns pointer to buffer array
/// Get item \p i
value_type& operator []( size_t i )
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i];
}
/// Get item \p i, const version
const value_type& operator []( size_t i ) const
{
- assert( i < capacity() );
+ assert( i < capacity());
return m_buffer[i];
}
/// Zeroize the buffer
void zeroize()
{
- memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]) );
+ memset( m_buffer, 0, capacity() * sizeof(m_buffer[0]));
}
/// Returns pointer to buffer array
/// Operator that compares two value of type \p T
int operator()(T const& v1, T const& v2)
{
- if ( std::less<T>()( v1, v2 ) )
+ if ( std::less<T>()( v1, v2 ))
return -1;
if ( std::less<T>()( v2, v1 ))
return 1;
int operator ()( T const& t, Q const& q ) const
{
less_functor f;
- if ( f( t, q ) )
+ if ( f( t, q ))
return -1;
- if ( f( q, t ) )
+ if ( f( q, t ))
return 1;
return 0;
}
: hash_tuple( t )
{}
hash_list( hash_tuple_type&& t)
- : hash_tuple( std::forward<hash_tuple_type>(t) )
+ : hash_tuple( std::forward<hash_tuple_type>(t))
{}
template <size_t I, typename T>
: m_wrappedList( t )
{}
hash_list_wrapper( hash_tuple_type&& t)
- : m_wrappedList( std::forward<hash_tuple_type>(t) )
+ : m_wrappedList( std::forward<hash_tuple_type>(t))
{}
void operator()( size_t * dest, wrapped_type const& what ) const
do {
int i = gen;
//...
- } while ( gen.next() );
+ } while ( gen.next());
// Get other permutation
gen.reset();
do {
int i = gen;
//...
- } while ( gen.next() );
+ } while ( gen.next());
\endcode
The following \p Generator defined:
random_permutation( size_t nLength )
: m_nCur(0)
, m_nStart(0)
- , m_nMod( integer_type(nLength) )
+ , m_nMod( integer_type(nLength))
{
reset();
}
/// Resets the generator to produce new sequence
void reset()
{
- m_nCur = m_nStart = integer_type( std::rand() ) % m_nMod;
+ m_nCur = m_nStart = integer_type( std::rand()) % m_nMod;
}
};
/// Resets the generator to produce new sequence
void reset()
{
- m_nCur = m_nStart = integer_type( std::rand() ) & m_nMask;
+ m_nCur = m_nStart = integer_type( std::rand()) & m_nMask;
}
};
typedef timebasestruct_t native_timer_type;
typedef long long native_duration_type;
- Timer() : m_tmStart( current() ) {}
+ Timer() : m_tmStart( current()) {}
static native_timer_type current()
{
}
static void current( native_timer_type& tmr )
{
- read_real_time( &tmr, sizeof(tmr) );
+ read_real_time( &tmr, sizeof(tmr));
time_base_to_time( &tmr, sizeof(tmr ));
}
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
native_duration_type native_duration()
{
- return native_duration( m_tmStart, current() );
+ return native_duration( m_tmStart, current());
}
static native_duration_type native_duration( native_timer_type const & nStart, native_timer_type const & nEnd )
static unsigned long long random_seed()
{
native_timer_type tmr;
- read_real_time( &tmr, sizeof(tmr) );
+ read_real_time( &tmr, sizeof(tmr));
return ( ((unsigned long long)(tmr.tb_hight)) << 32 ) + tmr.tb_low;
}
};
*/
pointer allocate( size_type nAlign, size_type nCount )
{
- assert( cds::beans::is_power2( nAlign ) );
- pointer p = reinterpret_cast<T *>( cds::OS::aligned_malloc( sizeof(T) * nCount, nAlign ) );
+ assert( cds::beans::is_power2( nAlign ));
+ pointer p = reinterpret_cast<T *>( cds::OS::aligned_malloc( sizeof(T) * nCount, nAlign ));
if ( !p )
throw std::bad_alloc();
assert( cds::details::is_aligned( p, nAlign ));
*/
pointer allocate(size_type nAlign, size_type nCount, const void *)
{
- return ( allocate( nAlign, nCount ) );
+ return ( allocate( nAlign, nCount ));
}
/// construct object at \p ptr with value \p val
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
native_duration_type native_duration()
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
native_duration_type native_duration()
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
native_duration_type native_duration()
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
native_duration_type native_duration()
typedef hrtime_t native_timer_type;
typedef long long native_duration_type;
- Timer() : m_tmStart( current() ) {}
+ Timer() : m_tmStart( current()) {}
static native_timer_type current() { return gethrtime(); }
static void current( native_timer_type& tmr ) { tmr = gethrtime(); }
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
native_duration_type native_duration()
{
- return native_duration( m_tmStart, current() );
+ return native_duration( m_tmStart, current());
}
static native_duration_type native_duration( native_timer_type nStart, native_timer_type nEnd )
/// Returns duration (in seconds) from start time to current
double duration()
{
- return duration( native_duration() );
+ return duration( native_duration());
}
/// Returns duration (in native format) from start time to current
/// Locks a lock at cell \p hint
/**
To define real array's cell which should be locked, \ref select_cell_policy is used.
- The target cell is a result of <tt>select_cell_policy( hint, size() )</tt>.
+ The target cell is a result of <tt>select_cell_policy( hint, size())</tt>.
Returns the index of locked lock.
*/
template <typename Q>
size_t lock( Q const& hint )
{
- size_t nCell = m_SelectCellPolicy( hint, size() );
- assert( nCell < size() );
+ size_t nCell = m_SelectCellPolicy( hint, size());
+ assert( nCell < size());
m_arrLocks[nCell].lock();
return nCell;
}
/// Try lock a lock at cell \p hint
/**
To define real array's cell which should be locked, \ref select_cell_policy is used.
- The target cell is a result of <tt>select_cell_policy( hint, size() )</tt>.
+ The target cell is a result of <tt>select_cell_policy( hint, size())</tt>.
Returns the index of locked lock if success, \ref c_nUnspecifiedCell constant otherwise.
*/
template <typename Q>
size_t try_lock( Q const& hint )
{
- size_t nCell = m_SelectCellPolicy( hint, size() );
- assert( nCell < size() );
- if ( m_arrLocks[nCell].try_lock() )
+ size_t nCell = m_SelectCellPolicy( hint, size());
+ assert( nCell < size());
+ if ( m_arrLocks[nCell].try_lock())
return nCell;
return c_nUnspecifiedCell;
}
/// Unlock the lock specified by index \p nCell
void unlock( size_t nCell )
{
- assert( nCell < size() );
+ assert( nCell < size());
m_arrLocks[nCell].unlock();
}
*/
lock_type& at( size_t nCell ) const
{
- assert( nCell < size() );
+ assert( nCell < size());
return m_arrLocks[ nCell ];
}
template <typename Q>
unique_lock( lock_array_type& arrLocks, Q const& hint )
: m_arrLocks( arrLocks )
- , m_nLockGuarded( arrLocks.lock( hint ) )
+ , m_nLockGuarded( arrLocks.lock( hint ))
{}
/// Locks all from \p arrLocks array
{
++m_nLockAllocation;
int nDiff = static_cast<int>( m_nLockAllocation.get() - m_nLockDeallocation.get());
- if ( nDiff > 0 && m_nMaxAllocated.get() < static_cast<typename event_counter::value_type>( nDiff ) )
+ if ( nDiff > 0 && m_nMaxAllocated.get() < static_cast<typename event_counter::value_type>( nDiff ))
m_nMaxAllocated = static_cast<typename event_counter::value_type>( nDiff );
}
void onLockDeallocation() { ++m_nLockDeallocation;}
// try lock spin and increment reference counter
refspin_type cur = p.m_SyncMonitorInjection.m_RefSpin.load( atomics::memory_order_relaxed ) & ~c_nSpinBit;
if ( !p.m_SyncMonitorInjection.m_RefSpin.compare_exchange_weak( cur, cur + c_nRefIncrement + c_nSpinBit,
- atomics::memory_order_acquire, atomics::memory_order_relaxed ) )
+ atomics::memory_order_acquire, atomics::memory_order_relaxed ))
{
back_off bkoff;
do {
// try lock spin
refspin_type cur = p.m_SyncMonitorInjection.m_RefSpin.load( atomics::memory_order_relaxed ) & ~c_nSpinBit;
if ( !p.m_SyncMonitorInjection.m_RefSpin.compare_exchange_weak( cur, cur | c_nSpinBit,
- atomics::memory_order_acquire, atomics::memory_order_relaxed ) )
+ atomics::memory_order_acquire, atomics::memory_order_relaxed ))
{
back_off bkoff;
do {
/// Destructor. On debug time it checks whether spin-lock is free
~spin_lock()
{
- assert( !m_spin.load( atomics::memory_order_relaxed ) );
+ assert( !m_spin.load( atomics::memory_order_relaxed ));
}
/// Check if the spin is locked
Returns \p true if locking is succeeded
otherwise (if the spin is already locked) returns \p false
*/
- bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()() ) )
+ bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()) )
{
backoff_strategy backoff;
while ( nTryCount-- ) {
- if ( try_lock() )
+ if ( try_lock())
return true;
backoff();
}
}
/// Lock the spin-lock. Waits infinitely while spin-lock is locked. Debug version: deadlock may be detected
- void lock() CDS_NOEXCEPT_(noexcept( backoff_strategy()() ))
+ void lock() CDS_NOEXCEPT_(noexcept( backoff_strategy()()))
{
backoff_strategy backoff;
// Deadlock detected
- assert( m_dbgOwnerId != OS::get_current_thread_id() );
+ assert( m_dbgOwnerId != OS::get_current_thread_id());
// TATAS algorithm
- while ( !try_lock() ) {
- while ( m_spin.load( atomics::memory_order_relaxed ) ) {
+ while ( !try_lock()) {
+ while ( m_spin.load( atomics::memory_order_relaxed )) {
backoff();
}
}
- assert( m_dbgOwnerId == OS::get_current_thread_id() );
+ assert( m_dbgOwnerId == OS::get_current_thread_id());
}
/// Unlock the spin-lock. Debug version: deadlock may be detected
void unlock() CDS_NOEXCEPT
{
- assert( m_spin.load( atomics::memory_order_relaxed ) );
+ assert( m_spin.load( atomics::memory_order_relaxed ));
- assert( m_dbgOwnerId == OS::get_current_thread_id() );
+ assert( m_dbgOwnerId == OS::get_current_thread_id());
CDS_DEBUG_ONLY( m_dbgOwnerId = OS::c_NullThreadId; )
m_spin.store( false, atomics::memory_order_release );
return m_spin.compare_exchange_weak( nCurrent, 1, atomics::memory_order_acquire, atomics::memory_order_relaxed );
}
- bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()() ))
+ bool try_acquire( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( backoff_strategy()()))
{
backoff_strategy bkoff;
while ( nTryCount-- ) {
- if ( try_acquire() )
+ if ( try_acquire())
return true;
bkoff();
}
return false;
}
- void acquire() CDS_NOEXCEPT_( noexcept( backoff_strategy()() ))
+ void acquire() CDS_NOEXCEPT_( noexcept( backoff_strategy()()))
{
// TATAS algorithm
backoff_strategy bkoff;
- while ( !try_acquire() ) {
- while ( m_spin.load( atomics::memory_order_relaxed ) )
+ while ( !try_acquire()) {
+ while ( m_spin.load( atomics::memory_order_relaxed ))
bkoff();
}
}
*/
bool is_locked() const CDS_NOEXCEPT
{
- return !( m_spin.load( atomics::memory_order_relaxed ) == 0 || is_taken( cds::OS::get_current_thread_id() ));
+ return !( m_spin.load( atomics::memory_order_relaxed ) == 0 || is_taken( cds::OS::get_current_thread_id()));
}
/// Try to lock the spin-lock (synonym for \p try_lock())
bool try_lock() CDS_NOEXCEPT
{
thread_id tid = OS::get_current_thread_id();
- if ( try_taken_lock( tid ) )
+ if ( try_taken_lock( tid ))
return true;
if ( try_acquire()) {
take( tid );
bool try_lock( unsigned int nTryCount ) CDS_NOEXCEPT_( noexcept( std::declval<reentrant_spin_lock>().try_acquire( nTryCount )))
{
thread_id tid = OS::get_current_thread_id();
- if ( try_taken_lock( tid ) )
+ if ( try_taken_lock( tid ))
return true;
if ( try_acquire( nTryCount )) {
take( tid );
void lock() CDS_NOEXCEPT_( noexcept( std::declval<reentrant_spin_lock>().acquire()))
{
thread_id tid = OS::get_current_thread_id();
- if ( !try_taken_lock( tid ) ) {
+ if ( !try_taken_lock( tid )) {
acquire();
take( tid );
}
/// Unlock the spin-lock. Return \p true if the current thread is owner of spin-lock \p false otherwise
bool unlock() CDS_NOEXCEPT
{
- if ( is_taken( OS::get_current_thread_id() ) ) {
+ if ( is_taken( OS::get_current_thread_id()) ) {
integral_type n = m_spin.load( atomics::memory_order_relaxed );
if ( n > 1 )
m_spin.store( n - 1, atomics::memory_order_relaxed );
/// Change the owner of locked spin-lock. May be called by thread that is owner of the spin-lock
bool change_owner( OS::ThreadId newOwnerId ) CDS_NOEXCEPT
{
- if ( is_taken( OS::get_current_thread_id() ) ) {
+ if ( is_taken( OS::get_current_thread_id()) ) {
assert( newOwnerId != OS::c_NullThreadId );
m_OwnerId = newOwnerId;
return true;
\code
class Manager {
public:
- // Initialize manager (called by cds::Initialize() )
+ // Initialize manager (called by cds::Initialize())
static void init();
- // Terminate manager (called by cds::Terminate() )
+ // Terminate manager (called by cds::Terminate())
static void fini();
// Checks whether current thread is attached to \p libcds feature or not.
, m_nFakeProcessorNumber( s_nLastUsedProcNo.fetch_add(1, atomics::memory_order_relaxed) % s_nProcCount )
, m_nAttachCount(0)
{
- if (cds::gc::HP::isUsed() )
+ if (cds::gc::HP::isUsed())
m_hpManager = new (m_hpManagerPlaceholder) cds::gc::HP::thread_gc_impl;
else
m_hpManager = nullptr;
- if ( cds::gc::DHP::isUsed() )
+ if ( cds::gc::DHP::isUsed())
m_dhpManager = new (m_dhpManagerPlaceholder) cds::gc::DHP::thread_gc_impl;
else
m_dhpManager = nullptr;
void init()
{
if ( m_nAttachCount++ == 0 ) {
- if ( cds::gc::HP::isUsed() )
+ if ( cds::gc::HP::isUsed())
m_hpManager->init();
- if ( cds::gc::DHP::isUsed() )
+ if ( cds::gc::DHP::isUsed())
m_dhpManager->init();
- if ( cds::urcu::details::singleton<cds::urcu::general_instant_tag>::isUsed() )
+ if ( cds::urcu::details::singleton<cds::urcu::general_instant_tag>::isUsed())
m_pGPIRCU = cds::urcu::details::singleton<cds::urcu::general_instant_tag>::attach_thread();
- if ( cds::urcu::details::singleton<cds::urcu::general_buffered_tag>::isUsed() )
+ if ( cds::urcu::details::singleton<cds::urcu::general_buffered_tag>::isUsed())
m_pGPBRCU = cds::urcu::details::singleton<cds::urcu::general_buffered_tag>::attach_thread();
- if ( cds::urcu::details::singleton<cds::urcu::general_threaded_tag>::isUsed() )
+ if ( cds::urcu::details::singleton<cds::urcu::general_threaded_tag>::isUsed())
m_pGPTRCU = cds::urcu::details::singleton<cds::urcu::general_threaded_tag>::attach_thread();
#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
- if ( cds::urcu::details::singleton<cds::urcu::signal_buffered_tag>::isUsed() )
+ if ( cds::urcu::details::singleton<cds::urcu::signal_buffered_tag>::isUsed())
m_pSHBRCU = cds::urcu::details::singleton<cds::urcu::signal_buffered_tag>::attach_thread();
- if ( cds::urcu::details::singleton<cds::urcu::signal_threaded_tag>::isUsed() )
+ if ( cds::urcu::details::singleton<cds::urcu::signal_threaded_tag>::isUsed())
m_pSHTRCU = cds::urcu::details::singleton<cds::urcu::signal_threaded_tag>::attach_thread();
#endif
}
bool fini()
{
if ( --m_nAttachCount == 0 ) {
- if ( cds::gc::DHP::isUsed() )
+ if ( cds::gc::DHP::isUsed())
m_dhpManager->fini();
- if ( cds::gc::HP::isUsed() )
+ if ( cds::gc::HP::isUsed())
m_hpManager->fini();
- if ( cds::urcu::details::singleton<cds::urcu::general_instant_tag>::isUsed() ) {
+ if ( cds::urcu::details::singleton<cds::urcu::general_instant_tag>::isUsed()) {
cds::urcu::details::singleton<cds::urcu::general_instant_tag>::detach_thread( m_pGPIRCU );
m_pGPIRCU = nullptr;
}
- if ( cds::urcu::details::singleton<cds::urcu::general_buffered_tag>::isUsed() ) {
+ if ( cds::urcu::details::singleton<cds::urcu::general_buffered_tag>::isUsed()) {
cds::urcu::details::singleton<cds::urcu::general_buffered_tag>::detach_thread( m_pGPBRCU );
m_pGPBRCU = nullptr;
}
- if ( cds::urcu::details::singleton<cds::urcu::general_threaded_tag>::isUsed() ) {
+ if ( cds::urcu::details::singleton<cds::urcu::general_threaded_tag>::isUsed()) {
cds::urcu::details::singleton<cds::urcu::general_threaded_tag>::detach_thread( m_pGPTRCU );
m_pGPTRCU = nullptr;
}
#ifdef CDS_URCU_SIGNAL_HANDLING_ENABLED
- if ( cds::urcu::details::singleton<cds::urcu::signal_buffered_tag>::isUsed() ) {
+ if ( cds::urcu::details::singleton<cds::urcu::signal_buffered_tag>::isUsed()) {
cds::urcu::details::singleton<cds::urcu::signal_buffered_tag>::detach_thread( m_pSHBRCU );
m_pSHBRCU = nullptr;
}
- if ( cds::urcu::details::singleton<cds::urcu::signal_threaded_tag>::isUsed() ) {
+ if ( cds::urcu::details::singleton<cds::urcu::signal_threaded_tag>::isUsed()) {
cds::urcu::details::singleton<cds::urcu::signal_threaded_tag>::detach_thread( m_pSHTRCU );
m_pSHTRCU = nullptr;
}
/// This method must be called in end of thread execution
static void detachThread()
{
- assert( _threadData() );
+ assert( _threadData());
- if ( _threadData()->fini() )
+ if ( _threadData()->fini())
destroy_thread_data();
}
/// This method must be called in end of thread execution
static void detachThread()
{
- assert( _threadData() );
+ assert( _threadData());
- if ( _threadData()->fini() )
+ if ( _threadData()->fini())
destroy_thread_data();
}
/// This method must be called in end of thread execution
static void detachThread()
{
- assert( _threadData() );
+ assert( _threadData());
- if ( _threadData()->fini() )
+ if ( _threadData()->fini())
destroy_thread_data();
}
static ThreadData * get()
{
- return reinterpret_cast<ThreadData *>( pthread_getspecific( m_key ) );
+ return reinterpret_cast<ThreadData *>( pthread_getspecific( m_key ));
}
static void alloc()
assert( pData );
if ( pData ) {
- if ( pData->fini() )
+ if ( pData->fini())
_threadData( do_detachThread );
}
else
assert( pData );
if ( pData ) {
- if ( pData->fini() )
+ if ( pData->fini())
_threadData( do_detachThread );
}
else
// First, try to reuse a retired (non-active) HP record
for ( pRec = m_pHead.load( atomics::memory_order_acquire ); pRec; pRec = pRec->m_list.m_pNext ) {
cds::OS::ThreadId thId = nullThreadId;
- if ( !pRec->m_list.m_idOwner.compare_exchange_strong( thId, curThreadId, atomics::memory_order_seq_cst, atomics::memory_order_relaxed ) )
+ if ( !pRec->m_list.m_idOwner.compare_exchange_strong( thId, curThreadId, atomics::memory_order_seq_cst, atomics::memory_order_relaxed ))
continue;
return pRec;
}
assert( p->m_list.m_idOwner.load( atomics::memory_order_relaxed ) == nullThreadId
|| p->m_list.m_idOwner.load( atomics::memory_order_relaxed ) == mainThreadId
- || !cds::OS::is_thread_alive( p->m_list.m_idOwner.load( atomics::memory_order_relaxed ) )
+ || !cds::OS::is_thread_alive( p->m_list.m_idOwner.load( atomics::memory_order_relaxed ))
);
al.Delete( p );
{
static void check()
{
- assert( !RCU::is_locked() );
- if ( RCU::is_locked() )
+ assert( !RCU::is_locked());
+ if ( RCU::is_locked())
throw cds::urcu::rcu_deadlock();
}
};
{
static void check()
{
- assert( !RCU::is_locked() );
+ assert( !RCU::is_locked());
}
};
template <typename RCUtag>
inline gp_thread_gc<RCUtag>::gp_thread_gc()
{
- if ( !threading::Manager::isThreadAttached() )
+ if ( !threading::Manager::isThreadAttached())
cds::threading::Manager::attachThread();
}
m_nGlobalControl.fetch_xor( general_purpose_rcu::c_nControlBit, atomics::memory_order_seq_cst );
for ( thread_record * pRec = m_ThreadList.head( atomics::memory_order_acquire ); pRec; pRec = pRec->m_list.m_pNext ) {
- while ( pRec->m_list.m_idOwner.load( atomics::memory_order_acquire ) != nullThreadId && check_grace_period( pRec ) ) {
+ while ( pRec->m_list.m_idOwner.load( atomics::memory_order_acquire ) != nullThreadId && check_grace_period( pRec )) {
bkoff();
CDS_COMPILER_RW_BARRIER;
}
/// Retire pointer \p by the disposer \p pFunc
template <typename T>
- static void retire( T * p, void (* pFunc)(T *) )
+ static void retire( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire( rp );
}
/// Returns singleton instance
static general_buffered * instance()
{
- return static_cast<general_buffered *>( base_class::instance() );
+ return static_cast<general_buffered *>( base_class::instance());
}
/// Checks if the singleton is created and ready to use
static bool isUsed()
p.free();
}
else {
- push_buffer( std::move(p) );
+ push_buffer( std::move(p));
break;
}
}
bool push_buffer( epoch_retired_ptr&& ep )
{
bool bPushed = m_Buffer.push( ep );
- if ( !bPushed || m_Buffer.size() >= capacity() ) {
+ if ( !bPushed || m_Buffer.size() >= capacity()) {
synchronize();
if ( !bPushed ) {
ep.free();
/// Destroys singleton object
static void Destruct( bool bDetachAll = false )
{
- if ( isUsed() ) {
+ if ( isUsed()) {
instance()->clear_buffer( std::numeric_limits< uint64_t >::max());
if ( bDetachAll )
instance()->m_ThreadList.detach_all();
while ( itFirst != itLast ) {
epoch_retired_ptr ep( *itFirst, nEpoch );
++itFirst;
- push_buffer( std::move(ep) );
+ push_buffer( std::move(ep));
}
}
atomics::atomic_thread_fence( atomics::memory_order_acquire );
{
std::unique_lock<lock_type> sl( m_Lock );
- if ( ep.m_p && m_Buffer.push( ep ) )
+ if ( ep.m_p && m_Buffer.push( ep ))
return false;
nEpoch = m_nCurEpoch.fetch_add( 1, atomics::memory_order_relaxed );
flip_and_wait();
/// Destroys singleton object
static void Destruct( bool bDetachAll = false )
{
- if ( isUsed() ) {
+ if ( isUsed()) {
if ( bDetachAll )
instance()->m_ThreadList.detach_all();
delete instance();
/// Returns singleton instance
static general_threaded * instance()
{
- return static_cast<general_threaded *>( base_class::instance() );
+ return static_cast<general_threaded *>( base_class::instance());
}
/// Checks if the singleton is created and ready to use
static bool isUsed()
bool push_buffer( epoch_retired_ptr&& p )
{
bool bPushed = m_Buffer.push( p );
- if ( !bPushed || m_Buffer.size() >= capacity() ) {
+ if ( !bPushed || m_Buffer.size() >= capacity()) {
synchronize();
if ( !bPushed )
p.free();
static void Construct( size_t nBufferCapacity = 256 )
{
if ( !singleton_ptr::s_pRCU ) {
- std::unique_ptr< general_threaded, scoped_disposer > pRCU( new general_threaded( nBufferCapacity ) );
+ std::unique_ptr< general_threaded, scoped_disposer > pRCU( new general_threaded( nBufferCapacity ));
pRCU->m_DisposerThread.start();
singleton_ptr::s_pRCU = pRCU.release();
/// Destroys singleton object and terminates internal reclamation thread
static void Destruct( bool bDetachAll = false )
{
- if ( isUsed() ) {
+ if ( isUsed()) {
general_threaded * pThis = instance();
if ( bDetachAll )
pThis->m_ThreadList.detach_all();
template <typename RCUtag>
inline sh_thread_gc<RCUtag>::sh_thread_gc()
{
- if ( !threading::Manager::isThreadAttached() )
+ if ( !threading::Manager::isThreadAttached())
cds::threading::Manager::attachThread();
}
/// Retire pointer \p by the disposer \p pFunc
template <typename T>
- static void retire( T * p, void (* pFunc)(T *) )
+ static void retire( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire( rp );
}
/// Returns singleton instance
static signal_buffered * instance()
{
- return static_cast<signal_buffered *>( base_class::instance() );
+ return static_cast<signal_buffered *>( base_class::instance());
}
/// Checks if the singleton is created and ready to use
static bool isUsed()
~signal_buffered()
{
- clear_buffer( std::numeric_limits< uint64_t >::max() );
+ clear_buffer( std::numeric_limits< uint64_t >::max());
}
void clear_buffer( uint64_t nEpoch )
p.free();
}
else {
- push_buffer( std::move(p) );
+ push_buffer( std::move(p));
break;
}
}
bool push_buffer( epoch_retired_ptr&& ep )
{
bool bPushed = m_Buffer.push( ep );
- if ( !bPushed || m_Buffer.size() >= capacity() ) {
+ if ( !bPushed || m_Buffer.size() >= capacity()) {
synchronize();
if ( !bPushed ) {
ep.free();
/// Destroys singleton object
static void Destruct( bool bDetachAll = false )
{
- if ( isUsed() ) {
+ if ( isUsed()) {
instance()->clear_buffer( std::numeric_limits< uint64_t >::max());
if ( bDetachAll )
instance()->m_ThreadList.detach_all();
/// Returns singleton instance
static signal_threaded * instance()
{
- return static_cast<signal_threaded *>( base_class::instance() );
+ return static_cast<signal_threaded *>( base_class::instance());
}
/// Checks if the singleton is created and ready to use
static bool isUsed()
bool push_buffer( epoch_retired_ptr&& p )
{
bool bPushed = m_Buffer.push( p );
- if ( !bPushed || m_Buffer.size() >= capacity() ) {
+ if ( !bPushed || m_Buffer.size() >= capacity()) {
synchronize();
if ( !bPushed ) {
p.free();
static void Construct( size_t nBufferCapacity = 256, int nSignal = SIGUSR1 )
{
if ( !singleton_ptr::s_pRCU ) {
- std::unique_ptr< signal_threaded, scoped_disposer > pRCU( new signal_threaded( nBufferCapacity, nSignal ) );
+ std::unique_ptr< signal_threaded, scoped_disposer > pRCU( new signal_threaded( nBufferCapacity, nSignal ));
pRCU->m_DisposerThread.start();
singleton_ptr::s_pRCU = pRCU.release();
/// Destroys singleton object and terminates internal reclamation thread
static void Destruct( bool bDetachAll = false )
{
- if ( isUsed() ) {
+ if ( isUsed()) {
signal_threaded * pThis = instance();
if ( bDetachAll )
pThis->m_ThreadList.detach_all();
while ( ( p = pBuf->front()) != nullptr ) {
if ( p->m_nEpoch <= nCurEpoch ) {
p->free();
- CDS_VERIFY( pBuf->pop_front() );
+ CDS_VERIFY( pBuf->pop_front());
}
else
break;
/// Disposes the pointer. Should be called only outside of RCU critical section
void release()
{
- if ( !empty() ) {
- assert( !rcu::is_locked() );
+ if ( !empty()) {
+ assert( !rcu::is_locked());
rcu::template retire_ptr<disposer>( m_pNode );
m_pNode = nullptr;
}
If the buffer is full, \ref synchronize function is invoked.
*/
template <typename T>
- static void retire_ptr( T * p, void (* pFunc)(T *) )
+ static void retire_ptr( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire_ptr( rp );
}
and then evaluates disposing expression <tt>pFunc( p )</tt>
*/
template <typename T>
- static void retire_ptr( T * p, void (* pFunc)(T *) )
+ static void retire_ptr( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire_ptr( rp );
}
If the buffer is full, \ref synchronize function is invoked.
*/
template <typename T>
- static void retire_ptr( T * p, void (* pFunc)(T *) )
+ static void retire_ptr( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire_ptr( rp );
}
If the buffer is full, \ref synchronize function is invoked.
*/
template <typename T>
- static void retire_ptr( T * p, void (* pFunc)(T *) )
+ static void retire_ptr( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire_ptr( rp );
}
If the buffer is full, \ref synchronize function is invoked.
*/
template <typename T>
- static void retire_ptr( T * p, void (* pFunc)(T *) )
+ static void retire_ptr( T * p, void (* pFunc)(T *))
{
- retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ) );
+ retired_ptr rp( reinterpret_cast<void *>( p ), reinterpret_cast<free_retired_ptr_func>( pFunc ));
retire_ptr( rp );
}
details::retired_ptr_node * pBusyLast = &dummy;
size_t nBusyCount = 0;
- for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(atomics::memory_order_acquire) )
+ for ( details::guard_data * pGuard = m_GuardPool.begin(); pGuard; pGuard = pGuard->pGlobalNext.load(atomics::memory_order_acquire))
{
// get guarded pointer
details::guard_data::guarded_ptr valGuarded = pGuard->pPost.load(atomics::memory_order_acquire);
if (buffer)
free(buffer);
- buffer = reinterpret_cast<PSYSTEM_LOGICAL_PROCESSOR_INFORMATION>( ::malloc( returnLength ) );
+ buffer = reinterpret_cast<PSYSTEM_LOGICAL_PROCESSOR_INFORMATION>( ::malloc( returnLength ));
if ( buffer == nullptr ) {
// allocation failed
// Build relationship processor -> cell
/*
s_arrProcessorCellRelationship = new unsigned int[s_nProcessorCount];
- memset( s_arrProcessorCellRelationship, 0, s_nProcessorCount * sizeof(s_arrProcessorCellRelationship[0]) );
+ memset( s_arrProcessorCellRelationship, 0, s_nProcessorCount * sizeof(s_arrProcessorCellRelationship[0]));
byteOffset = 0;
ptr = buffer;
while (byteOffset + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) <= returnLength)
case RelationNumaNode:
// Non-NUMA systems report a single record of this type.
for ( unsigned int i = 0; i < sizeof(ptr->ProcessorMask) * 8; ++i ) {
- if ( ptr->ProcessorMask & (1 << i) ) {
+ if ( ptr->ProcessorMask & (1 << i)) {
assert( i < s_nProcessorCount );
assert( ptr->NumaNode.NodeNumber < s_nProcessorGroupCount );
if ( i < s_nProcessorCount )
for ( hplist_node * hprec = pHead; hprec; hprec = pNext ) {
assert( hprec->m_idOwner.load( atomics::memory_order_relaxed ) == nullThreadId
|| hprec->m_idOwner.load( atomics::memory_order_relaxed ) == mainThreadId
- || !cds::OS::is_thread_alive( hprec->m_idOwner.load( atomics::memory_order_relaxed ) )
+ || !cds::OS::is_thread_alive( hprec->m_idOwner.load( atomics::memory_order_relaxed ))
);
details::retired_vector& vect = hprec->m_arrRetired;
details::retired_vector::iterator itRetired = vect.begin();
// First try to reuse a retired (non-active) HP record
for ( hprec = m_pListHead.load( atomics::memory_order_acquire ); hprec; hprec = hprec->m_pNextNode ) {
cds::OS::ThreadId thId = nullThreadId;
- if ( !hprec->m_idOwner.compare_exchange_strong( thId, curThreadId, atomics::memory_order_seq_cst, atomics::memory_order_relaxed ) )
+ if ( !hprec->m_idOwner.compare_exchange_strong( thId, curThreadId, atomics::memory_order_seq_cst, atomics::memory_order_relaxed ))
continue;
hprec->m_bFree.store( false, atomics::memory_order_release );
return hprec;
}
// Sort plist to simplify search in
- std::sort( plist.begin(), plist.end() );
+ std::sort( plist.begin(), plist.end());
// Stage 2: Search plist
details::retired_vector& arrRetired = pRec->m_arrRetired;
std::vector< void * >::iterator itEnd = plist.end();
size_t nDeferredCount = 0;
while ( itRetired != itRetiredEnd ) {
- if ( std::binary_search( itBegin, itEnd, itRetired->m_p ) ) {
+ if ( std::binary_search( itBegin, itEnd, itRetired->m_p )) {
arrRetired.push( *itRetired );
++nDeferredCount;
}
{
details::retired_ptr dummyRetired;
while ( pNode ) {
- if ( !pNode->m_bFree.load( atomics::memory_order_acquire ) ) {
+ if ( !pNode->m_bFree.load( atomics::memory_order_acquire )) {
for ( size_t i = 0; i < m_nHazardPointerCount; ++i ) {
pRec->sync();
void * hptr = pNode->m_hzp[i].get();
{
CDS_HAZARDPTR_STATISTIC( ++m_Stat.m_HelpScanCallCount )
- assert( static_cast<hplist_node *>(pThis)->m_idOwner.load(atomics::memory_order_relaxed) == cds::OS::get_current_thread_id() );
+ assert( static_cast<hplist_node *>(pThis)->m_idOwner.load(atomics::memory_order_relaxed) == cds::OS::get_current_thread_id());
const cds::OS::ThreadId nullThreadId = cds::OS::c_NullThreadId;
const cds::OS::ThreadId curThreadId = cds::OS::get_current_thread_id();
for ( hplist_node * hprec = m_pListHead.load(atomics::memory_order_acquire); hprec; hprec = hprec->m_pNextNode ) {
// If m_bFree == true then hprec->m_arrRetired is empty - we don't need to see it
- if ( hprec->m_bFree.load(atomics::memory_order_acquire) )
+ if ( hprec->m_bFree.load(atomics::memory_order_acquire))
continue;
// Owns hprec if it is empty.
++stat.nHPRecAllocated;
stat.nTotalRetiredPtrCount += hprec->m_arrRetired.size();
- if ( hprec->m_bFree.load(atomics::memory_order_relaxed) ) {
+ if ( hprec->m_bFree.load(atomics::memory_order_relaxed)) {
// Free HP record
stat.nRetiredPtrInFreeHPRecs += hprec->m_arrRetired.size();
}
std::string line;
unsigned int nProcCount = 0;
- while ( !cpuinfo.eof() ) {
+ while ( !cpuinfo.eof()) {
std::getline(cpuinfo,line);
if (!line.size())
continue;
static void shuffle( RandomIt first, RandomIt last )
{
static std::random_device random_dev;
- static std::mt19937 random_gen( random_dev() );
+ static std::mt19937 random_gen( random_dev());
std::shuffle( first, last, random_gen );
}
static inline unsigned int rand( unsigned int nMax )
{
- double rnd = double( std::rand() ) / double( RAND_MAX );
+ double rnd = double( std::rand()) / double( RAND_MAX );
unsigned int n = (unsigned int)(rnd * nMax);
return n < nMax ? n : (n - 1);
}
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 CDSUNIT_HASH_FUNC_H
hash_type operator()( std::string const& s ) const
{
- return CityHash32( s.c_str(), s.length() );
+ return CityHash32( s.c_str(), s.length());
}
template <typename T>
hash_type operator()( std::string const& s ) const
{
- return CityHash64( s.c_str(), s.length() );
+ return CityHash64( s.c_str(), s.length());
}
template <typename T>
hash_type operator()( std::string const& s ) const
{
- return CityHash128( s.c_str(), s.length() );
+ return CityHash128( s.c_str(), s.length());
}
template <typename T>
# define CDSSTRESS_LEVELSTAT_OUT( level, field ) \
CDSSTRESS_STAT_OUT_( "level_stat." + std::to_string(level) + "." + #field, it->field )
- o << CDSSTRESS_STAT_OUT_( "stat.level_count", level_stat.size() );
+ o << CDSSTRESS_STAT_OUT_( "stat.level_count", level_stat.size());
size_t i = 0;
for ( auto it = level_stat.begin(); it != level_stat.end(); ++it, ++i ) {
o << CDSSTRESS_LEVELSTAT_OUT( i, array_node_count )
static inline property_stream& operator <<( property_stream& o, cds::algo::flat_combining::stat<> const& s )
{
return o
- << CDSSTRESS_STAT_OUT_( "combining_factor", s.combining_factor() )
+ << CDSSTRESS_STAT_OUT_( "combining_factor", s.combining_factor())
<< CDSSTRESS_STAT_OUT( s, m_nOperationCount )
<< CDSSTRESS_STAT_OUT( s, m_nCombiningCount )
<< CDSSTRESS_STAT_OUT( s, m_nCompactPublicationList )
return o;
}
-# define CDSSTRESS_POOLMONITOR_STAT_OUT( s, field ) CDSSTRESS_STAT_OUT_( "pool_monitor." #field, s.field.get() )
+# define CDSSTRESS_POOLMONITOR_STAT_OUT( s, field ) CDSSTRESS_STAT_OUT_( "pool_monitor." #field, s.field.get())
static inline property_stream& operator <<( property_stream& o, cds::sync::pool_monitor_traits::stat<> const& s )
{
{
std::string strParamName( pszParamName );
auto it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return std::string( pszDefVal ); // param not found -> returns default value
return it->second;
}
{
std::string strParamName( pszParamName );
cfg_map::const_iterator it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return defVal; // param not found -> returns default value
return atoi( it->second.c_str());
}
{
std::string strParamName( pszParamName );
cfg_map::const_iterator it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return defVal; // param not found -> returns default value
return static_cast<unsigned int>( strtoul( it->second.c_str(), NULL, 10 ));
}
{
std::string strParamName( pszParamName );
cfg_map::const_iterator it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return defVal; // param not found -> returns default value
return strtol( it->second.c_str(), NULL, 10 );
}
{
std::string strParamName( pszParamName );
cfg_map::const_iterator it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return defVal; // param not found -> returns default value
return strtoul( it->second.c_str(), NULL, 10 );
}
{
std::string strParamName( pszParamName );
cfg_map::const_iterator it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return defVal; // param not found -> returns default value
return static_cast<size_t>( strtoul( it->second.c_str(), NULL, 10 ));
}
{
std::string strParamName( pszParamName );
cfg_map::const_iterator it = m_Cfg.find( strParamName );
- if ( it == m_Cfg.end() )
+ if ( it == m_Cfg.end())
return defVal; // param not found -> returns default value
return !( it->second.empty()
|| it->second == "0"
{
std::stringstream ss;
ss << prop.second;
- ::testing::Test::RecordProperty( prop.first.c_str(), ss.str().c_str() );
+ ::testing::Test::RecordProperty( prop.first.c_str(), ss.str().c_str());
return s;
}
{
std::stringstream ss;
ss << prop.second.count();
- ::testing::Test::RecordProperty( prop.first, ss.str().c_str() );
+ ::testing::Test::RecordProperty( prop.first, ss.str().c_str());
return s;
}
std::chrono::milliseconds run()
{
- return run( std::chrono::seconds::zero() );
+ return run( std::chrono::seconds::zero());
}
std::chrono::milliseconds run( std::chrono::seconds duration )
m_bStopped = false;
m_doneCount = 0;
- while ( m_readyCount.load() != m_threads.size() )
+ while ( m_readyCount.load() != m_threads.size())
std::this_thread::yield();
m_bTimeElapsed.store( false, std::memory_order_release );
m_cvStart.notify_all();
}
- if ( duration != std::chrono::seconds::zero() ) {
+ if ( duration != std::chrono::seconds::zero()) {
for ( ;; ) {
std::this_thread::sleep_for( native_duration );
auto time_now = std::chrono::steady_clock::now();
{
scoped_lock l( m_cvMutex );
- while ( m_doneCount != m_threads.size() )
+ while ( m_doneCount != m_threads.size())
m_cvDone.wait( l );
m_bStopped = true;
}
inline thread::thread( thread const& sample )
: m_pool( sample.m_pool )
, m_type( sample.m_type )
- , m_id( m_pool.get_next_id() )
+ , m_id( m_pool.get_next_id())
, m_impl( &thread::run, this )
{}
config const& operator[]( const std::string& testName ) const\r
{\r
auto it = m_cfg.find( testName );\r
- if ( it != m_cfg.end() )\r
+ if ( it != m_cfg.end())\r
return it->second;\r
return m_emptyCfg;\r
}\r
{\r
std::ifstream s;\r
s.open( fileName );\r
- if ( !s.is_open() ) {\r
+ if ( !s.is_open()) {\r
std::cerr << "WARNING: Cannot open test cfg file " << fileName\r
<< "\n\tUse default settings"\r
<< std::endl;\r
char buf[4096];\r
\r
config * pMap = nullptr;\r
- while ( !s.eof() ) {\r
- s.getline( buf, sizeof( buf ) / sizeof( buf[0] ) );\r
+ while ( !s.eof()) {\r
+ s.getline( buf, sizeof( buf ) / sizeof( buf[0] ));\r
char * pszStr = buf;\r
// trim left\r
- while ( *pszStr != 0 && (*pszStr == ' ' || *pszStr == '\t') ) ++pszStr;\r
+ while ( *pszStr != 0 && (*pszStr == ' ' || *pszStr == '\t')) ++pszStr;\r
// trim right\r
char * pszEnd = strchr( pszStr, 0 );\r
if ( pszEnd == pszStr ) // empty srtring\r
continue;\r
--pszEnd;\r
- while ( pszEnd != pszStr && (*pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\n' || *pszEnd == '\r') ) --pszEnd;\r
+ while ( pszEnd != pszStr && (*pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\n' || *pszEnd == '\r')) --pszEnd;\r
\r
if ( pszStr == pszEnd ) // empty string\r
continue;\r
continue;\r
\r
pszEnd = pszEq;\r
- while ( pszStr <= --pszEnd && (*pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\n' || *pszEnd == '\r') );\r
+ while ( pszStr <= --pszEnd && (*pszEnd == ' ' || *pszEnd == '\t' || *pszEnd == '\n' || *pszEnd == '\r'));\r
\r
if ( pszEnd <= pszStr )\r
continue;\r
std::ifstream s;\r
char const* filename = "./dictionary.txt";\r
s.open( filename );\r
- if ( !s.is_open() ) {\r
+ if ( !s.is_open()) {\r
std::cerr << "WARNING: Cannot open test file " << filename << std::endl;\r
return arrString;\r
}\r
\r
arrString.reserve( std::stoul( line ));\r
\r
- while ( !s.eof() ) {\r
+ while ( !s.eof()) {\r
std::getline( s, line );\r
- if ( !line.empty() )\r
+ if ( !line.empty())\r
arrString.push_back( std::move( line ));\r
}\r
\r
};
atomics::atomic<tagged_ptr> tp;
- if ( tp.is_lock_free() ) {
+ if ( tp.is_lock_free()) {
cds::intrusive::TaggedFreeList fl;
test( fl );
}
};
atomics::atomic<tagged_ptr> tp;
- if ( tp.is_lock_free() ) {
+ if ( tp.is_lock_free()) {
cds::intrusive::TaggedFreeList fl;
test( fl );
}
m_arrInsert[i] = i;
m_arrRemove[i] = i;
}
- shuffle( m_arrInsert.begin(), m_arrInsert.end() );
- shuffle( m_arrRemove.begin(), m_arrRemove.end() );
+ shuffle( m_arrInsert.begin(), m_arrInsert.end());
+ shuffle( m_arrRemove.begin(), m_arrRemove.end());
}
void Map_DelOdd::TearDownTestCase()
return lf;
}
- INSTANTIATE_TEST_CASE_P( a, Map_DelOdd_LF, ::testing::ValuesIn( Map_DelOdd_LF::get_load_factors() ) );
+ INSTANTIATE_TEST_CASE_P( a, Map_DelOdd_LF, ::testing::ValuesIn( Map_DelOdd_LF::get_load_factors()) );
} // namespace map
std::vector<size_t>& arrData = fixture.m_arrInsert;
for ( size_t i = 0; i < arrData.size(); ++i ) {
- if ( rMap.insert( key_type( arrData[i], id() )))
+ if ( rMap.insert( key_type( arrData[i], id())))
++m_nInsertSuccess;
else
++m_nInsertFailed;
ensure_func f;
for ( size_t i = arrData.size() - 1; i > 0; --i ) {
if ( arrData[i] & 1 ) {
- rMap.update( key_type( arrData[i], id() ), f );
+ rMap.update( key_type( arrData[i], id()), f );
}
}
cds_test::thread_pool& pool = get_pool();
pool.add( new insert_thread( pool, testMap ), s_nInsThreadCount );
- pool.add( new delete_thread( pool, testMap ), s_nDelThreadCount ? s_nDelThreadCount : cds::OS::topology::processor_count() );
+ pool.add( new delete_thread( pool, testMap ), s_nDelThreadCount ? s_nDelThreadCount : cds::OS::topology::processor_count());
propout() << std::make_pair( "insert_thread_count", s_nInsThreadCount )
<< std::make_pair( "delete_thread_count", s_nDelThreadCount )
size_t nExtractFailed = 0;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case inserter_thread:
{
insert_thread& inserter = static_cast<insert_thread&>(thr);
{
for ( size_t n = 0; n < s_nMapSize; n +=2 ) {
for ( size_t i = 0; i < s_nInsThreadCount; ++i ) {
- EXPECT_TRUE( testMap.contains( key_type( n, i ) ) ) << "key=" << n << "/" << i;
+ EXPECT_TRUE( testMap.contains( key_type( n, i )) ) << "key=" << n << "/" << i;
}
}
}
check_before_cleanup( testMap );
testMap.clear();
- EXPECT_TRUE( testMap.empty() ) << "map.size=" << testMap.size();
+ EXPECT_TRUE( testMap.empty()) << "map.size=" << testMap.size();
additional_check( testMap );
additional_cleanup( testMap );
if ( s_Data[i].bExists )
++s_nRealMapSize;
}
- shuffle( s_Data.begin(), s_Data.end() );
+ shuffle( s_Data.begin(), s_Data.end());
}
void Map_find_int::SetUpTestCase()
return lf;
}
- INSTANTIATE_TEST_CASE_P( a, Map_find_int_LF, ::testing::ValuesIn( Map_find_int_LF::get_load_factors() ) );
+ INSTANTIATE_TEST_CASE_P( a, Map_find_int_LF, ::testing::ValuesIn( Map_find_int_LF::get_load_factors()) );
} // namespace map
hasher h;
for ( size_t i = 0; i < s_arrString.size(); ++i ) {
hash_type hash = h( s_arrString.at( i ));
- if ( mapHash.insert( std::make_pair( hash, i ) ).second ) {
+ if ( mapHash.insert( std::make_pair( hash, i )).second ) {
if ( ++nDiffHash >= nSize )
break;
bool bExists = rand( 100 ) <= s_nPercentExists;
return lf;
}
- INSTANTIATE_TEST_CASE_P( a, Map_find_string_LF, ::testing::ValuesIn( Map_find_string::get_load_factors() ) );
+ INSTANTIATE_TEST_CASE_P( a, Map_find_string_LF, ::testing::ValuesIn( Map_find_string::get_load_factors()) );
} // namespace map
if ( id() & 1 ) {
auto itEnd = s_Data.cend();
for ( auto it = s_Data.cbegin(); it != itEnd; ++it ) {
- auto bFound = rMap.contains( *(it->pKey) );
+ auto bFound = rMap.contains( *(it->pKey));
if ( it->bExists ) {
if ( check_result(bFound, rMap))
++m_KeyExists.nSuccess;
else {
auto itEnd = s_Data.crend();
for ( auto it = s_Data.crbegin(); it != itEnd; ++it ) {
- auto bFound = rMap.contains( *(it->pKey) );
+ auto bFound = rMap.contains( *(it->pKey));
if ( it->bExists ) {
if ( check_result(bFound, rMap))
++m_KeyExists.nSuccess;
s_arrKeys.reserve( s_nMapSize );
for ( size_t i = 0; i < s_nMapSize; ++i )
s_arrKeys.push_back( i );
- shuffle( s_arrKeys.begin(), s_arrKeys.end() );
+ shuffle( s_arrKeys.begin(), s_arrKeys.end());
}
void Map_InsDel_func::TearDownTestCase()
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
inserter& t = static_cast<inserter&>( thr );
<< std::make_pair( "update_failed", nUpdateFailed )
<< std::make_pair( "update_functor_create", nEnsFuncCreated )
<< std::make_pair( "update_functor_modify", nEnsFuncModified )
- << std::make_pair( "finish_map_size", testMap.size() );
+ << std::make_pair( "finish_map_size", testMap.size());
EXPECT_EQ( nDelValueFailed, 0u );
EXPECT_EQ( nDelValueSuccess, nDeleteSuccess );
s_arrKeys.reserve( s_nMapSize );
for ( size_t i = 0; i < s_nMapSize; ++i )
s_arrKeys.push_back( i );
- shuffle( s_arrKeys.begin(), s_arrKeys.end() );
+ shuffle( s_arrKeys.begin(), s_arrKeys.end());
}
void Map_InsDel_int::TearDownTestCase()
if ( id() & 1 ) {
for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) {
for ( key_array::const_iterator it = s_arrKeys.cbegin(), itEnd = s_arrKeys.cend(); it != itEnd; ++it ) {
- if ( rMap.insert( *it, *it * 8 ) )
+ if ( rMap.insert( *it, *it * 8 ))
++m_nInsertSuccess;
else
++m_nInsertFailed;
else {
for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) {
for ( key_array::const_reverse_iterator it = s_arrKeys.crbegin(), itEnd = s_arrKeys.crend(); it != itEnd; ++it ) {
- if ( rMap.insert( *it, *it * 8 ) )
+ if ( rMap.insert( *it, *it * 8 ))
++m_nInsertSuccess;
else
++m_nInsertFailed;
if ( id() & 1 ) {
for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) {
for ( key_array::const_iterator it = s_arrKeys.cbegin(), itEnd = s_arrKeys.cend(); it != itEnd; ++it ) {
- if ( rMap.erase( *it ) )
+ if ( rMap.erase( *it ))
++m_nDeleteSuccess;
else
++m_nDeleteFailed;
else {
for ( size_t nPass = 0; nPass < s_nThreadPassCount; ++nPass ) {
for ( key_array::const_reverse_iterator it = s_arrKeys.crbegin(), itEnd = s_arrKeys.crend(); it != itEnd; ++it ) {
- if ( rMap.erase( *it ) )
+ if ( rMap.erase( *it ))
++m_nDeleteSuccess;
else
++m_nDeleteFailed;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
inserter& t = static_cast<inserter&>( thr );
<< std::make_pair( "insert_failed", nInsertFailed )
<< std::make_pair( "delete_success", nDeleteSuccess )
<< std::make_pair( "delete_failed", nDeleteFailed )
- << std::make_pair( "finish_map_size", testMap.size() );
+ << std::make_pair( "finish_map_size", testMap.size());
check_before_cleanup( testMap );
v.reserve( s_nMapSize );
for ( size_t i = 0; i < s_nMapSize; ++i )
v.push_back( i );
- shuffle( v.begin(), v.end() );
+ shuffle( v.begin(), v.end());
for ( auto i: v )
EXPECT_TRUE( testMap.insert( i, i ));
}
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
inserter& t = static_cast<inserter&>(thr);
// Check if the map contains all items
for ( size_t i = 0; i < s_nMapSize; ++i )
- EXPECT_TRUE( testMap.contains( i ) ) << "key=" << i;
+ EXPECT_TRUE( testMap.contains( i )) << "key=" << i;
check_before_cleanup( testMap );
s_arrKeys.reserve( s_nMapSize );
std::vector<std::string> dict = load_dictionary();
for ( size_t i = 0; i < s_nMapSize; ++i )
- s_arrKeys.push_back( std::move( dict.at(i) ));
+ s_arrKeys.push_back( std::move( dict.at(i)));
}
void Map_InsDel_string::TearDownTestCase()
size_t nDiffHash = 0;
hasher h;
for ( size_t i = 0; i < dict.size(); ++i ) {
- hash_type hash = h( dict.at( i ) );
- if ( mapHash.insert( std::make_pair( hash, i ) ).second ) {
+ hash_type hash = h( dict.at( i ));
+ if ( mapHash.insert( std::make_pair( hash, i )).second ) {
if ( ++nDiffHash >= nSize )
break;
- s_arrKeys.push_back( std::move( dict.at( i ) ));
+ s_arrKeys.push_back( std::move( dict.at( i )));
}
}
s_nMapSize = dict.size();
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
inserter& t = static_cast<inserter&>(thr);
<< std::make_pair( "insert_failed", nInsertFailed )
<< std::make_pair( "delete_success", nDeleteSuccess )
<< std::make_pair( "delete_failed", nDeleteFailed )
- << std::make_pair( "finish_map_size", testMap.size() );
+ << std::make_pair( "finish_map_size", testMap.size());
check_before_cleanup( testMap );
//testMap.clear();
for ( auto const& str: s_arrKeys )
testMap.erase( str );
- EXPECT_TRUE( testMap.empty() );
+ EXPECT_TRUE( testMap.empty());
EXPECT_EQ( testMap.size(), 0u );
additional_check( testMap );
size_t const nNormalize = size_t(-1) / ( s_nMapSize * 2 );
size_t nRand = 0;
- while ( !time_elapsed() ) {
+ while ( !time_elapsed()) {
nRand = cds::bitop::RandXorShift( nRand );
size_t n = nRand / nNormalize;
switch ( s_arrShuffle[i] ) {
arr.reserve( s_nMapSize );
for ( size_t i = 0; i < s_nMapSize; ++i )
arr.push_back( i * 2 + 1);
- shuffle( arr.begin(), arr.end() );
+ shuffle( arr.begin(), arr.end());
for ( size_t i = 0; i < s_nMapSize; ++i )
testMap.insert( arr[i], arr[i] );
}
<< std::make_pair( "delete_failed", nDeleteFailed )
<< std::make_pair( "find_success", nFindSuccess )
<< std::make_pair( "find_failed", nFindFailed )
- << std::make_pair( "finish_map_size", testMap.size() );
+ << std::make_pair( "finish_map_size", testMap.size());
{
ASSERT_TRUE( std::chrono::duration_cast<std::chrono::seconds>(duration).count() > 0 );
size_t nItem = id();
for ( size_t i = 0; i < nSize; nItem += nThreadCount, ++i )
m_arrVal[i] = nItem;
- shuffle( m_arrVal.begin(), m_arrVal.end() );
+ shuffle( m_arrVal.begin(), m_arrVal.end());
}
public:
size_t m_nInsertSuccess = 0;
<< std::make_pair( "insert_failed", nInsertFailed )
<< std::make_pair( "find_success", nFindSuccess )
<< std::make_pair( "find_failed", nFindFailed )
- << std::make_pair( "finish_map_size", testMap.size() );
+ << std::make_pair( "finish_map_size", testMap.size());
EXPECT_EQ( nInsertFailed, 0u );
EXPECT_EQ( nFindFailed, 0u );
struct cmp {
int operator ()(Key const& k1, Key const& k2) const
{
- if ( less<Key>( k1, k2 ) )
+ if ( less<Key>( k1, k2 ))
return -1;
return less<Key>( k2, k1 ) ? 1 : 0;
}
template <typename Q, typename Pred>
bool erase_with( Q const& key, Pred /*pred*/ )
{
- return base_class::erase_with( key, typename std::conditional< base_class::c_isSorted, Pred, typename Pred::equal_to>::type() );
+ return base_class::erase_with( key, typename std::conditional< base_class::c_isSorted, Pred, typename Pred::equal_to>::type());
}
// for testing
static inline void print_stat( cds_test::property_stream& o, CuckooMap< Key, V, Traits > const& s )
{
typedef CuckooMap< Key, V, Traits > map_type;
- print_stat( o, static_cast<typename map_type::base_class const&>(s) );
+ print_stat( o, static_cast<typename map_type::base_class const&>(s));
}
} // namespace map
static inline void additional_check( EllenBinTreeMap<GC, Key, T, Traits>& m )
{
GC::force_dispose();
- ellen_bintree_check::check_stat( m.statistics() );
+ ellen_bintree_check::check_stat( m.statistics());
}
template <typename GC, typename Key, typename T, typename Traits>
static inline void check_before_cleanup( EllenBinTreeMap<GC, Key, T, Traits>& m )
{
- EXPECT_TRUE( m.check_consistency() );
+ EXPECT_TRUE( m.check_consistency());
}
} // namespace map
bool insert( const Key& key, const Value& val )
{
scoped_lock al( m_lock );
- return base_class::insert( typename base_class::value_type( key, val ) ).second;
+ return base_class::insert( typename base_class::value_type( key, val )).second;
}
template <typename T, typename Func>
bool insert( const Key& key, const T& val, Func func )
{
scoped_lock al( m_lock );
- std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value() ) );
+ std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value()) );
if ( pRet.second ) {
func( pRet.first->second, val );
return true;
std::pair<bool, bool> update( const T& key, Func func, bool /*bAllowInsert*/ = true )
{
scoped_lock al( m_lock );
- std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value() ) );
+ std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value()) );
if ( pRet.second ) {
func( true, *pRet.first );
return std::make_pair( true, true );
{
scoped_lock al( m_lock );
typename base_class::iterator it = base_class::find( key );
- if ( it != base_class::end() ) {
- func( (*it) );
+ if ( it != base_class::end()) {
+ func( (*it));
base_class::erase( it );
return true;
}
bool insert( const Key& key, const T& val, Func func )
{
scoped_lock al( m_lock );
- std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value() ));
+ std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type(key, Value()));
if ( pRet.second ) {
func( pRet.first->second, val );
return true;
std::pair<bool, bool> update( const T& key, Func func, bool /*bAllowInsert*/ = true )
{
scoped_lock al( m_lock );
- std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value() ));
+ std::pair<typename base_class::iterator, bool> pRet = base_class::insert( typename base_class::value_type( key, Value()));
if ( pRet.second ) {
func( true, *pRet.first );
return std::make_pair( true, true );
{
scoped_lock al( m_lock );
typename base_class::iterator it = base_class::find( key );
- if ( it != base_class::end() ) {
+ if ( it != base_class::end()) {
func( *it );
return base_class::erase( key ) != 0;
}
public:
template <class Config>
StripedHashMap_seq( Config const& cfg )
- : base_class( cfg.s_nMapSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )) )
+ : base_class( cfg.s_nMapSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )))
{}
empty_stat statistics() const
public:
template <class Config>
StripedHashMap_ord( Config const& cfg )
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )) )
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )))
{}
empty_stat statistics() const
public:
template <class Config>
RefinableHashMap_ord( Config const& cfg )
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )) )
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )))
{}
empty_stat statistics() const
arr.reserve( s_nQueueSize );
for ( size_t i = 0; i < s_nQueueSize; ++i )
arr.push_back( i );
- shuffle( arr.begin(), arr.end() );
+ shuffle( arr.begin(), arr.end());
size_t nPushError = 0;
typedef typename PQueue::value_type value_type;
for ( auto it = arr.begin(); it != arr.end(); ++it ) {
- if ( !q.push( value_type( *it ) ))
+ if ( !q.push( value_type( *it )))
++nPushError;
}
s_nQueueSize -= nPushError;
nTotalErrorEq += cons.m_nPopErrorEq;
nTotalFailed += cons.m_nPopFailed;
- if ( !cons.m_arrFailedPops.empty() ) {
+ if ( !cons.m_arrFailedPops.empty()) {
std::cerr << "Priority violations, thread " << i;
for ( size_t k = 0; k < cons.m_arrFailedPops.size(); ++k ) {
std::cerr << "\n " << "prev_key=" << cons.m_arrFailedPops[k].prev_key << " popped_key=" << cons.m_arrFailedPops[k].popped_key;
- if ( cons.m_arrFailedPops[k].next_key != static_cast<size_t>(-1) )
+ if ( cons.m_arrFailedPops[k].next_key != static_cast<size_t>(-1))
std::cerr << " next_key=" << cons.m_arrFailedPops[k].next_key;
else
std::cerr << " next_key unspecified";
{ \
typedef pqueue::Types<pqueue::simple_value>::pqueue_t pqueue_type; \
std::unique_ptr< pqueue_type > pq( new pqueue_type ); \
- test( *pq.get() ); \
+ test( *pq.get()); \
}
//CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_static_less )
//CDSSTRESS_MSPriorityQueue( pqueue_pop, MSPriorityQueue_static_less_stat )
bool pop( value_type& dest )
{
scoped_lock l( m_Lock );
- if ( !m_PQueue.empty() ) {
+ if ( !m_PQueue.empty()) {
dest = m_PQueue.top();
m_PQueue.pop();
return true;
bool pop_with( Q& dest, MoveFunc f )
{
scoped_lock l( m_Lock );
- if ( !m_PQueue.empty() ) {
- f( dest, m_PQueue.top() );
+ if ( !m_PQueue.empty()) {
+ f( dest, m_PQueue.top());
m_PQueue.pop();
return true;
}
void clear()
{
scoped_lock l( m_Lock );
- while ( !m_PQueue.empty() )
+ while ( !m_PQueue.empty())
m_PQueue.pop();
}
void clear_with( Func f )
{
scoped_lock l( m_Lock );
- while ( !m_PQueue.empty() ) {
- f( m_PQueue.top() );
+ while ( !m_PQueue.empty()) {
+ f( m_PQueue.top());
m_PQueue.pop();
}
}
template <typename T, typename Tree>
bool operator()( T& dest, Tree& container ) const
{
- typename Tree::guarded_ptr gp( container.extract_max() );
+ typename Tree::guarded_ptr gp( container.extract_max());
if ( gp )
dest = *gp;
return !gp.empty();
template <typename T, typename Tree>
bool operator()( T& dest, Tree& container ) const
{
- typename Tree::exempt_ptr ep( container.extract_max() );
+ typename Tree::exempt_ptr ep( container.extract_max());
if ( ep )
dest = *ep;
return !ep.empty();
template <typename T, typename Tree>
bool operator()( T& dest, Tree& container ) const
{
- typename Tree::guarded_ptr gp( container.extract_min() );
+ typename Tree::guarded_ptr gp( container.extract_min());
if ( gp )
dest = *gp;
return !gp.empty();
template <typename T, typename Tree>
bool operator()( T& dest, Tree& container ) const
{
- typename Tree::exempt_ptr ep( container.extract_min() );
+ typename Tree::exempt_ptr ep( container.extract_min());
if ( ep )
dest = *ep;
return !ep.empty();
template <typename T, typename Set>
bool operator()( T& dest, Set& container ) const
{
- typename Set::guarded_ptr gp( container.extract_max() );
+ typename Set::guarded_ptr gp( container.extract_max());
if ( gp )
dest = *gp;
return !gp.empty();
template <typename T, typename Set>
bool operator()( T& dest, Set& container ) const
{
- typename Set::exempt_ptr ep( container.extract_max() );
+ typename Set::exempt_ptr ep( container.extract_max());
if ( ep )
dest = *ep;
return !ep.empty();
template <typename T, typename Set>
bool operator()( T& dest, Set& container ) const
{
- typename Set::guarded_ptr gp( container.extract_min() );
+ typename Set::guarded_ptr gp( container.extract_min());
if ( gp )
dest = *gp;
return !gp.empty();
template <typename T, typename Set>
bool operator()( T& dest, Set& container ) const
{
- typename Set::exempt_ptr ep( container.extract_min() );
+ typename Set::exempt_ptr ep( container.extract_min());
if ( ep )
dest = *ep;
return !ep.empty();
typedef typename PQueue::value_type value_type;
for ( auto it = m_arr.begin(); it != m_arr.end(); ++it ) {
- if ( !m_Queue.push( value_type( *it ) ))
+ if ( !m_Queue.push( value_type( *it )))
++m_nPushError;
}
}
m_arr.reserve( nEnd - nStart );
for ( size_t i = nStart; i < nEnd; ++i )
m_arr.push_back( i );
- shuffle( m_arr.begin(), m_arr.end() );
+ shuffle( m_arr.begin(), m_arr.end());
}
public:
{ \
typedef pqueue::Types<pqueue::simple_value>::pqueue_t pqueue_type; \
std::unique_ptr< pqueue_type > pq( new pqueue_type ); \
- test( *pq.get() ); \
+ test( *pq.get()); \
}
//CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_static_less )
//CDSSTRESS_MSPriorityQueue( pqueue_push, MSPriorityQueue_static_less_stat )
m_arr.reserve( nEnd - nStart );
for ( size_t i = nStart; i < nEnd; ++i )
m_arr.push_back( i );
- shuffle( m_arr.begin(), m_arr.end() );
+ shuffle( m_arr.begin(), m_arr.end());
}
public:
virtual void test()
{
typename PQueue::value_type val;
- while ( s_nProducerCount.load( atomics::memory_order_relaxed ) != 0 || !m_Queue.empty() ) {
+ while ( s_nProducerCount.load( atomics::memory_order_relaxed ) != 0 || !m_Queue.empty()) {
if ( m_Queue.pop( val ))
++m_nPopSuccess;
else
EXPECT_EQ( nTotalPopped, s_nQueueSize );
EXPECT_EQ( nPushFailed, 0u );
- //check_statistics( testQueue.statistics() );
+ //check_statistics( testQueue.statistics());
propout() << q.statistics();
}
{ \
typedef pqueue::Types<pqueue::simple_value>::pqueue_t pqueue_type; \
std::unique_ptr< pqueue_type > pq( new pqueue_type ); \
- test( *pq.get() ); \
+ test( *pq.get()); \
}
//CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_static_less )
//CDSSTRESS_MSPriorityQueue( pqueue_push_pop, MSPriorityQueue_static_less_stat )
}
else {
++m_nPopEmpty;
- if ( s_nProducerCount.load( atomics::memory_order_acquire ) == 0 && m_Queue.empty() )
+ if ( s_nProducerCount.load( atomics::memory_order_acquire ) == 0 && m_Queue.empty())
break;
}
}
typedef typename Reader::const_data_iterator ReaderIterator;
size_t nPostTestPops = 0;
- while ( testQueue.pop() )
+ while ( testQueue.pop())
++nPostTestPops;
size_t nTotalPops = 0;
size_t nQueueSize = s_nThreadPushCount * s_nWriterThreadCount;
EXPECT_EQ( nTotalPops + nPostTestPops, nQueueSize );
- EXPECT_TRUE( testQueue.empty() );
+ EXPECT_TRUE( testQueue.empty());
// Test that all items have been popped
// Test FIFO order
for ( it = arrReaders[nReader]->m_WriterData[nWriter].begin(); it != itEnd; ++it )
arrData.push_back( *it );
}
- std::sort( arrData.begin(), arrData.end() );
+ std::sort( arrData.begin(), arrData.end());
for ( size_t i=1; i < arrData.size(); ++i ) {
if ( arrData[i-1] + 1 != arrData[i] ) {
EXPECT_EQ( arrData[i-1] + 1, arrData[i] ) << "Writer " << nWriter << ": [" << (i-1) << "]=" << arrData[i-1]
INSTANTIATE_TEST_CASE_P( SQ,
intrusive_segmented_queue_push_pop,
- ::testing::ValuesIn( intrusive_segmented_queue_push_pop::get_test_parameters() ) );
+ ::testing::ValuesIn( intrusive_segmented_queue_push_pop::get_test_parameters()) );
} // namespace
value_type * pop()
{
lock_guard l( m_Lock );
- if ( m_List.empty() )
+ if ( m_List.empty())
return nullptr;
value_type& v = m_List.front();
m_List.pop_front();
typedef typename Queue::value_type value_type;
value_type value;
size_t nPopCount = 0;
- while ( m_Queue.pop( value ) ) {
+ while ( m_Queue.pop( value )) {
++m_arr[ value.nNo ];
++nPopCount;
}
Producer<Queue>& thread = static_cast<Producer<Queue>&>(pool.get( i ));
EXPECT_EQ( thread.m_nPushError, 0u ) << " producer thread " << i;
}
- EXPECT_TRUE( !q.empty() );
+ EXPECT_TRUE( !q.empty());
std::unique_ptr< uint8_t[] > arr( new uint8_t[s_nQueueSize] );
memset( arr.get(), 0, sizeof(arr[0]) * s_nQueueSize );
const size_t nTotalWriters = s_nProducerThreadCount;
value_type v;
while ( true ) {
- if ( m_Queue.pop( v ) ) {
+ if ( m_Queue.pop( v )) {
++m_nPopped;
if ( v.nWriterNo < nTotalWriters )
m_WriterData[ v.nWriterNo ].push_back( v.nNo );
++m_nPopEmpty;
if ( s_nProducerDone.load() >= nTotalWriters ) {
- if ( m_Queue.empty() )
+ if ( m_Queue.empty())
break;
}
}
EXPECT_EQ( nTotalPops, nPoppedItems );
EXPECT_EQ( nTotalPops + nPostTestPops, s_nQueueSize ) << "nTotalPops=" << nTotalPops << ", nPostTestPops=" << nPostTestPops;
- EXPECT_TRUE( q.empty() );
+ EXPECT_TRUE( q.empty());
// Test consistency of popped sequence
for ( size_t nWriter = 0; nWriter < s_nProducerThreadCount; ++nWriter ) {
arrData.push_back( *it );
}
- std::sort( arrData.begin(), arrData.end() );
+ std::sort( arrData.begin(), arrData.end());
for ( size_t i=1; i < arrData.size(); ++i ) {
EXPECT_EQ( arrData[i - 1] + 1, arrData[i] ) << "producer=" << nWriter;
}
template <class Queue>
void analyze( Queue& q )
{
- EXPECT_TRUE( q.empty() );
+ EXPECT_TRUE( q.empty());
std::vector< size_t > arrPushCount;
arrPushCount.resize( s_nThreadCount, 0 );
bool dequeue( T& data )
{
std::unique_lock<Lock> a(m_Locker);
- if ( base_class::empty() )
+ if ( base_class::empty())
return false;
data = base_class::front();
m_arrData.resize( s_nSetSize );
for ( size_t i = 0; i < s_nSetSize; ++i )
m_arrData[i] = i;
- shuffle( m_arrData.begin(), m_arrData.end() );
+ shuffle( m_arrData.begin(), m_arrData.end());
}
void Set_DelOdd::TearDownTestCase()
return lf;
}
- INSTANTIATE_TEST_CASE_P( a, Set_DelOdd_LF, ::testing::ValuesIn( Set_DelOdd_LF::get_load_factors() ) );
+ INSTANTIATE_TEST_CASE_P( a, Set_DelOdd_LF, ::testing::ValuesIn( Set_DelOdd_LF::get_load_factors()) );
} // namespace set
std::vector<size_t>& arrData = fixture.m_arrData;
for ( size_t i = 0; i < arrData.size(); ++i ) {
- if ( rSet.insert( key_type( arrData[i], id() )))
+ if ( rSet.insert( key_type( arrData[i], id())))
++m_nInsertSuccess;
else
++m_nInsertFailed;
update_functor f;
for ( size_t i = arrData.size() - 1; i > 0; --i ) {
if ( arrData[i] & 1 )
- rSet.update( key_type( arrData[i], id() ), f, true );
+ rSet.update( key_type( arrData[i], id()), f, true );
}
fixture.m_nInsThreadCount.fetch_sub( 1, atomics::memory_order_release );
struct eraser {
static bool erase( SetType& s, size_t key, size_t /*thread*/)
{
- return s.erase_with( key, key_less() );
+ return s.erase_with( key, key_less());
}
};
size_t nExtractFailed = 0;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case inserter_thread:
{
insert_thread& inserter = static_cast<insert_thread&>( thr );
check_before_clear( testSet );
testSet.clear();
- EXPECT_TRUE( testSet.empty() ) << "set.size=" << testSet.size();
+ EXPECT_TRUE( testSet.empty()) << "set.size=" << testSet.size();
additional_check( testSet );
print_stat( propout(), testSet );
size_t const nNormalize = size_t(-1) / ( fixture.s_nSetSize * 2);
size_t nRand = 0;
- while ( !time_elapsed() ) {
+ while ( !time_elapsed()) {
nRand = cds::bitop::RandXorShift(nRand);
size_t n = nRand / nNormalize;
switch ( pAct[i] ) {
pInitArr[i] = i * 2 + 1;
shuffle( pInitArr, pEnd );
for ( size_t * p = pInitArr; p < pEnd; ++p )
- testSet.insert( typename Set::value_type( *p, *p ) );
+ testSet.insert( typename Set::value_type( *p, *p ));
delete [] pInitArr;
}
{
ASSERT_TRUE( std::chrono::duration_cast<std::chrono::seconds>(duration).count() > 0 );
size_t nTotalOps = nInsertSuccess + nInsertFailed + nDeleteSuccess + nDeleteFailed + nFindSuccess + nFindFailed;
- propout() << std::make_pair( "avg_speed", nTotalOps / std::chrono::duration_cast<std::chrono::seconds>(duration).count() );
+ propout() << std::make_pair( "avg_speed", nTotalOps / std::chrono::duration_cast<std::chrono::seconds>(duration).count());
}
, nData(0)
, nUpdateCall(0)
, bInitialized( false )
- , threadId( cds::OS::get_current_thread_id() )
+ , threadId( cds::OS::get_current_thread_id())
{}
value( value const& s )
, nData(s.nData)
, nUpdateCall(s.nUpdateCall.load(atomics::memory_order_relaxed))
, bInitialized( s.bInitialized )
- , threadId( cds::OS::get_current_thread_id() )
+ , threadId( cds::OS::get_current_thread_id())
, m_access()
{}
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
InserterThread& inserter = static_cast<InserterThread&>( thr );
<< std::make_pair( "update_created", nUpdateCreated )
<< std::make_pair( "update_modified", nUpdateModified )
<< std::make_pair( "update_failed", nUpdateFailed )
- << std::make_pair( "final_set_size", testSet.size() );
+ << std::make_pair( "final_set_size", testSet.size());
EXPECT_EQ( nDelValueFailed, 0u );
for ( size_t * p = m_pKeyFirst; p != m_pKeyLast; ++p )
testSet.erase( *p );
- EXPECT_TRUE( testSet.empty() );
+ EXPECT_TRUE( testSet.empty());
EXPECT_EQ( testSet.size(), 0u );
additional_check( testSet );
size_t nDeleteFailed = 0;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
InserterThread& inserter = static_cast<InserterThread&>( thr );
<< std::make_pair( "delete_success", nDeleteSuccess )
<< std::make_pair( "insert_failed", nInsertFailed )
<< std::make_pair( "delete_failed", nDeleteFailed )
- << std::make_pair( "final_set_size", testSet.size() );
+ << std::make_pair( "final_set_size", testSet.size());
//testSet.clear();
for (auto const& str: m_arrString )
testSet.erase( str );
- EXPECT_TRUE( testSet.empty() );
+ EXPECT_TRUE( testSet.empty());
EXPECT_EQ( testSet.size(), 0u );
additional_check( testSet );
size_t nExtractFailed = 0;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
InserterThread& inserter = static_cast<InserterThread&>(thr);
<< std::make_pair( "insert_failed", nInsertFailed )
<< std::make_pair( "delete_failed", nDeleteFailed )
<< std::make_pair( "extract_failed", nExtractFailed )
- << std::make_pair( "final_set_size", testSet.size() );
+ << std::make_pair( "final_set_size", testSet.size());
//testSet.clear();
for ( auto const& str : m_arrString )
testSet.erase( str );
- EXPECT_TRUE( testSet.empty() );
+ EXPECT_TRUE( testSet.empty());
EXPECT_EQ( testSet.size(), 0u );
additional_check( testSet );
Set& rSet = m_Set;
Set_Iteration& fixture = pool().template fixture<Set_Iteration>();
- while ( !fixture.all_modifiers_done() ) {
+ while ( !fixture.all_modifiers_done()) {
++m_nPassCount;
typename Set::iterator it;
typename Set::iterator itEnd;
Set& rSet = m_Set;
Set_Iteration& fixture = pool().template fixture<Set_Iteration>();
- while ( !fixture.all_modifiers_done() ) {
+ while ( !fixture.all_modifiers_done()) {
++m_nPassCount;
typename Set::rcu_lock l;
for ( auto it = rSet.begin(); it != rSet.end(); ++it ) {
#if CDS_BUILD_BITS == 64
- it->val.hash = CityHash64( it->key.c_str(), it->key.length() );
+ it->val.hash = CityHash64( it->key.c_str(), it->key.length());
#else
it->val.hash = std::hash<std::string>()(it->key);
#endif
size_t nIteratorVisitCount = 0;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
InserterThread& inserter = static_cast<InserterThread&>( thr );
<< std::make_pair( "delete_failed", nDeleteFailed )
<< std::make_pair( "iterator_pass_count", nIteratorPassCount )
<< std::make_pair( "iterator_visit_count", nIteratorVisitCount )
- << std::make_pair( "final_set_size", testSet.size() );
+ << std::make_pair( "final_set_size", testSet.size());
testSet.clear();
- EXPECT_TRUE( testSet.empty() );
+ EXPECT_TRUE( testSet.empty());
additional_check( testSet );
print_stat( propout(), testSet );
size_t nIteratorVisitCount = 0;
for ( size_t i = 0; i < pool.size(); ++i ) {
cds_test::thread& thr = pool.get( i );
- switch ( thr.type() ) {
+ switch ( thr.type()) {
case insert_thread:
{
InserterThread& inserter = static_cast<InserterThread&>(thr);
<< std::make_pair( "extract_failed", nExtractFailed )
<< std::make_pair( "iterator_pass_count", nIteratorPassCount )
<< std::make_pair( "iterator_visit_count", nIteratorVisitCount )
- << std::make_pair( "final_set_size", testSet.size() );
+ << std::make_pair( "final_set_size", testSet.size());
testSet.clear();
- EXPECT_TRUE( testSet.empty() );
+ EXPECT_TRUE( testSet.empty());
additional_check( testSet );
print_stat( propout(), testSet );
{
int operator ()(Key const& k1, Key const& k2) const
{
- if ( less<Key>( k1, k2 ) )
+ if ( less<Key>( k1, k2 ))
return -1;
return less<Key>( k2, k1 ) ? 1 : 0;
}
template <typename Q, typename Pred>
bool erase_with( Q const& key, Pred /*pred*/ )
{
- return cuckoo_base_class::erase_with( key, typename std::conditional< cuckoo_base_class::c_isSorted, Pred, typename Pred::equal_to>::type() );
+ return cuckoo_base_class::erase_with( key, typename std::conditional< cuckoo_base_class::c_isSorted, Pred, typename Pred::equal_to>::type());
}
// for testing
static inline void print_stat( cds_test::property_stream& o, CuckooSet< V, Traits > const& s )
{
typedef CuckooSet< V, Traits > set_type;
- print_stat( o, static_cast<typename set_type::cuckoo_base_class const&>(s) );
+ print_stat( o, static_cast<typename set_type::cuckoo_base_class const&>(s));
}
} // namespace set
{
EXPECT_EQ( stat.m_nInternalNodeCreated, stat.m_nInternalNodeDeleted );
EXPECT_EQ( stat.m_nUpdateDescCreated, stat.m_nUpdateDescDeleted );
- //EXPECT_EQ( ellen_bintree_pool::internal_node_counter::m_nAlloc.get(), ellen_bintree_pool::internal_node_counter::m_nFree.get() );
+ //EXPECT_EQ( ellen_bintree_pool::internal_node_counter::m_nAlloc.get(), ellen_bintree_pool::internal_node_counter::m_nFree.get());
EXPECT_EQ( ellen_bintree_pool::internal_node_counter::m_nAlloc.get(), stat.m_nInternalNodeCreated );
// true if RCU is not threaded
- //EXPECT_EQ( stat.m_nInternalNodeDeleted, ellen_bintree_pool::internal_node_counter::m_nFree.get() );
+ //EXPECT_EQ( stat.m_nInternalNodeDeleted, ellen_bintree_pool::internal_node_counter::m_nFree.get());
}
} // namespace ellen_bintree_check
template <typename GC, typename Key, typename T, typename Traits>
static inline void check_before_clear( cds::container::EllenBinTreeSet<GC, Key, T, Traits>& s )
{
- EXPECT_TRUE( s.check_consistency() );
+ EXPECT_TRUE( s.check_consistency());
}
} // namespace set
template <typename Q>
extracted_ptr extract(Q const& key)
{
- return base_class::extract( hasher()(key) );
+ return base_class::extract( hasher()(key));
}
template <typename Q>
bool contains( Q const& key )
{
- return base_class::contains( hasher()(key) );
+ return base_class::contains( hasher()(key));
}
// for testing
bool contains( const Key& key )
{
scoped_lock al( m_lock );
- return base_class::find( value_type(key) ) != base_class::end();
+ return base_class::find( value_type(key)) != base_class::end();
}
template <typename Key>
bool erase( const Key& key )
{
scoped_lock al( m_lock );
- return base_class::erase( value_type(key) ) != 0;
+ return base_class::erase( value_type(key)) != 0;
}
template <typename T, typename Func>
bool erase( const T& key, Func func )
{
scoped_lock al( m_lock );
- typename base_class::iterator it = base_class::find( value_type(key) );
- if ( it != base_class::end() ) {
+ typename base_class::iterator it = base_class::find( value_type(key));
+ if ( it != base_class::end()) {
func( *it );
return base_class::erase( it ) != base_class::end();
}
bool erase( const Key& key )
{
scoped_lock al( m_lock );
- return base_class::erase( value_type(key) ) != 0;
+ return base_class::erase( value_type(key)) != 0;
}
template <typename T, typename Func>
bool erase( const T& key, Func func )
{
scoped_lock al( m_lock );
- typename base_class::iterator it = base_class::find( value_type(key) );
- if ( it != base_class::end() ) {
+ typename base_class::iterator it = base_class::find( value_type(key));
+ if ( it != base_class::end()) {
func( *it );
base_class::erase( it );
public:
template <class Config>
StripedHashSet_seq( Config const& cfg )
- : base_class( cfg.s_nSetSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )) )
+ : base_class( cfg.s_nSetSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )))
{}
empty_stat statistics() const
public:
template <class Config>
StripedHashSet_seq_rational( Config const& cfg ) // LoadFactor = 1 / nDenominator
- : base_class( cfg.s_nSetSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( 1, cfg.s_nLoadFactor )) )
+ : base_class( cfg.s_nSetSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( 1, cfg.s_nLoadFactor )))
{}
empty_stat statistics() const
public:
template <class Config>
StripedHashSet_ord( Config const& cfg )
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )) )
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )))
{}
empty_stat statistics() const
public:
template <class Config>
RefinableHashSet_seq( Config const& cfg )
- : base_class( cfg.s_nSetSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )) )
+ : base_class( cfg.s_nSetSize / cfg.s_nLoadFactor / 16, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nLoadFactor )))
{}
empty_stat statistics() const
public:
template <class Config>
RefinableHashSet_ord( Config const& cfg )
- : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )) )
+ : base_class( 0, *(new(&m_placeHolder) resizing_policy_t( cfg.s_nMaxLoadFactor * 1024 )))
{}
empty_stat statistics() const
{
EXPECT_EQ( s.m_PushCount.get() + s.m_ActivePushCollision.get() + s.m_PassivePushCollision.get(), s_nStackSize );
EXPECT_EQ( s.m_PopCount.get() + s.m_ActivePopCollision.get() + s.m_PassivePopCollision.get(), s_nStackSize );
- EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get() );
- EXPECT_EQ( s.m_ActivePopCollision.get(), s.m_PassivePushCollision.get() );
- EXPECT_EQ( s.m_ActivePushCollision.get(), s.m_PassivePopCollision.get() );
+ EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get());
+ EXPECT_EQ( s.m_ActivePopCollision.get(), s.m_PassivePushCollision.get());
+ EXPECT_EQ( s.m_ActivePushCollision.get(), s.m_PassivePopCollision.get());
}
template <typename Stack>
{
Stack stack( s_nEliminationSize );
do_test( stack, arrValue );
- check_elimination_stat( stack.statistics() );
+ check_elimination_stat( stack.statistics());
}
Stack::gc::force_dispose();
}
}
}
- if ( args.empty() ) {
+ if ( args.empty()) {
if ( nFCCompactFactor && nFCCombinePassCount )
args.push_back( { nFCCompactFactor, nFCCombinePassCount } );
else
virtual void test()
{
m_nPushError = 0;
- memset( m_arrPush, 0, sizeof( m_arrPush ) );
+ memset( m_arrPush, 0, sizeof( m_arrPush ));
size_t i = 0;
for ( typename Stack::value_type * p = m_pStart; p < m_pEnd; ++p, ++i ) {
p->nProducer = id();
size_t no;
p->nNo.store( no = i % c_nValArraySize, atomics::memory_order_release );
- if ( m_Stack.push( *p ) )
+ if ( m_Stack.push( *p ))
++m_arrPush[no];
else
++m_nPushError;
m_nPopEmpty = 0;
m_nPopCount = 0;
m_nDirtyPop = 0;
- memset( m_arrPop, 0, sizeof( m_arrPop ) );
+ memset( m_arrPop, 0, sizeof( m_arrPop ));
- while ( !(s_nWorkingProducers.load( atomics::memory_order_acquire ) == 0 && m_Stack.empty()) ) {
+ while ( !(s_nWorkingProducers.load( atomics::memory_order_acquire ) == 0 && m_Stack.empty())) {
typename Stack::value_type * p = m_Stack.pop();
if ( p ) {
p->nConsumer = id();
++m_nPopCount;
size_t no = p->nNo.load( atomics::memory_order_acquire );
- if ( no < sizeof( m_arrPop ) / sizeof( m_arrPop[0] ) )
+ if ( no < sizeof( m_arrPop ) / sizeof( m_arrPop[0] ))
++m_arrPop[no];
else
++m_nDirtyPop;
size_t nPopEmpty = 0;
size_t nPopCount = 0;
size_t arrVal[c_nValArraySize];
- memset( arrVal, 0, sizeof( arrVal ) );
+ memset( arrVal, 0, sizeof( arrVal ));
size_t nDirtyPop = 0;
for ( size_t threadNo = 0; threadNo < pool.size(); ++threadNo ) {
T * pop()
{
unique_lock l( m_Lock );
- if ( !m_Impl.empty() ) {
+ if ( !m_Impl.empty()) {
T * v = m_Impl.top();
m_Impl.pop();
return v;
value_type v;
v.nThread = id();
for ( v.nNo = m_nStartItem; v.nNo < m_nEndItem; ++v.nNo ) {
- if ( !m_stack.push( v ) )
+ if ( !m_stack.push( v ))
++m_nPushError;
}
}
void test_elimination( Stack& stack )
{
test( stack );
- check_elimination_stat( stack.statistics() );
+ check_elimination_stat( stack.statistics());
}
void check_elimination_stat( cds::container::treiber_stack::empty_stat const& )
void check_elimination_stat( cds::container::treiber_stack::stat<> const& s )
{
- EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get() );
+ EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get());
}
template <class Stack>
virtual void test()
{
- memset( m_arrPush, 0, sizeof( m_arrPush ) );
+ memset( m_arrPush, 0, sizeof( m_arrPush ));
value_type v;
v.nThread = id();
for ( size_t i = 0; i < m_nItemCount; ++i ) {
v.nNo = i % c_nValArraySize;
- if ( m_stack.push( v ) )
+ if ( m_stack.push( v ))
++m_arrPush[v.nNo];
else
++m_nPushError;
virtual void test()
{
- memset( m_arrPop, 0, sizeof( m_arrPop ) );
+ memset( m_arrPop, 0, sizeof( m_arrPop ));
value_type v;
- while ( !( s_nWorkingProducers.load( atomics::memory_order_acquire ) == 0 && m_stack.empty()) ) {
- if ( m_stack.pop( v ) ) {
+ while ( !( s_nWorkingProducers.load( atomics::memory_order_acquire ) == 0 && m_stack.empty())) {
+ if ( m_stack.pop( v )) {
++m_nPopCount;
- if ( v.nNo < sizeof( m_arrPop ) / sizeof( m_arrPop[0] ) )
+ if ( v.nNo < sizeof( m_arrPop ) / sizeof( m_arrPop[0] ))
++m_arrPop[v.nNo];
else
++m_nDirtyPop;
void test_elimination( Stack& stack )
{
test( stack );
- check_elimination_stat( stack.statistics() );
+ check_elimination_stat( stack.statistics());
}
void check_elimination_stat( cds::container::treiber_stack::empty_stat const& )
{
EXPECT_EQ( s.m_PushCount.get() + s.m_ActivePushCollision.get() + s.m_PassivePushCollision.get(), s_nStackSize );
EXPECT_EQ( s.m_PopCount.get() + s.m_ActivePopCollision.get() + s.m_PassivePopCollision.get(), s_nStackSize );
- EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get() );
- EXPECT_EQ( s.m_ActivePopCollision.get(), s.m_PassivePushCollision.get() );
- EXPECT_EQ( s.m_ActivePushCollision.get(), s.m_PassivePopCollision.get() );
+ EXPECT_EQ( s.m_PushCount.get(), s.m_PopCount.get());
+ EXPECT_EQ( s.m_ActivePopCollision.get(), s.m_PassivePushCollision.get());
+ EXPECT_EQ( s.m_ActivePushCollision.get(), s.m_PassivePopCollision.get());
}
template< class Stack>
size_t nPopEmpty = 0;
size_t nPopCount = 0;
size_t arrVal[c_nValArraySize];
- memset( arrVal, 0, sizeof( arrVal ) );
+ memset( arrVal, 0, sizeof( arrVal ));
size_t nDirtyPop = 0;
for ( size_t threadNo = 0; threadNo < pool.size(); ++threadNo ) {
bool pop( T& v )
{
unique_lock l( m_Lock );
- if ( !m_Impl.empty() ) {
+ if ( !m_Impl.empty()) {
v = m_Impl.top();
m_Impl.pop();
return true;
// push_front/pop_front
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_front( i ) );
+ EXPECT_TRUE( dq.push_front( i ));
EXPECT_EQ( dq.size(), c_nSize );
size_t nCount = 0;
int val;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_front( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_front( val ));
++nCount;
EXPECT_EQ( static_cast<int>(c_nSize - nCount), val );
}
// push_back/pop_back
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_back( i ) );
+ EXPECT_TRUE( dq.push_back( i ));
EXPECT_EQ( dq.size(), c_nSize );
nCount = 0;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_back( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_back( val ));
++nCount;
EXPECT_EQ( static_cast<int>(c_nSize - nCount), val );
}
// push_back/pop_front
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_back( i ) );
+ EXPECT_TRUE( dq.push_back( i ));
EXPECT_EQ( dq.size(), c_nSize );
nCount = 0;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_front( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_front( val ));
EXPECT_EQ( static_cast<int>( nCount ), val );
++nCount;
}
// push_front/pop_back
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_front( i ) );
+ EXPECT_TRUE( dq.push_front( i ));
EXPECT_EQ( dq.size(), c_nSize );
nCount = 0;
- while ( !dq.empty() ) {
- EXPECT_TRUE( dq.pop_back( val ) );
+ while ( !dq.empty()) {
+ EXPECT_TRUE( dq.pop_back( val ));
EXPECT_EQ( static_cast<int>( nCount ), val );
++nCount;
}
// clear
for ( int i = 0; i < static_cast<int>( c_nSize ); ++i )
- EXPECT_TRUE( dq.push_front( i ) );
+ EXPECT_TRUE( dq.push_front( i ));
EXPECT_EQ( dq.size(), c_nSize );
- EXPECT_FALSE( dq.empty() );
+ EXPECT_FALSE( dq.empty());
dq.clear();
- EXPECT_TRUE( dq.empty() );
+ EXPECT_TRUE( dq.empty());
}
};
stat& operator =( const stat& s )
{
- memcpy( this, &s, sizeof( s ) );
+ memcpy( this, &s, sizeof( s ));
return *this;
}
};
struct cmp {
int operator ()( const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()( const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
shuffle( arr, arr + nSize );
shuffle( arr2, arr2 + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
typedef typename List::iterator iterator;
EXPECT_TRUE( l.contains( i.nKey ));
EXPECT_TRUE( l.contains( i ));
EXPECT_TRUE( l.contains( other_item( i.nKey ), other_less()));
- EXPECT_FALSE( l.find( i.nKey ) == l.end() );
+ EXPECT_FALSE( l.find( i.nKey ) == l.end());
EXPECT_TRUE( l.find( i.nKey, []( value_type& item, int ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 1 );
EXPECT_TRUE( l.find( i, []( value_type& item, value_type const& ) { ++item.s.nFindCall; } ));
EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less(), []( value_type& item, other_item const& ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 3 );
- EXPECT_FALSE( l.insert( i ) );
- ASSERT_FALSE( l.empty() );
+ EXPECT_FALSE( l.insert( i ));
+ ASSERT_FALSE( l.empty());
int const ckey = i.nKey;
iterator it = l.find( ckey );
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( (*it).nVal, i.nVal );
- check_ordered( it, l.end() );
+ check_ordered( it, l.end());
it = l.find( i.nKey );
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( (*it).nVal, i.nVal );
- check_ordered( it, l.end() );
+ check_ordered( it, l.end());
- it = l.find_with( other_item( i.nKey ), other_less() );
- ASSERT_FALSE( it == l.end() );
+ it = l.find_with( other_item( i.nKey ), other_less());
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nVal );
- check_ordered( it, l.end() );
+ check_ordered( it, l.end());
}
ASSERT_CONTAINER_SIZE( l, nSize );
EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less(), []( value_type& item, other_item const& ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 6 );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// update existing test
for ( auto& i : arr2 ) {
EXPECT_EQ( i.s.nUpdateExistsCall, 0 );
- std::pair<bool, bool> ret = l.update( i, update_functor() );
+ std::pair<bool, bool> ret = l.update( i, update_functor());
EXPECT_TRUE( ret.first );
EXPECT_FALSE( ret.second );
EXPECT_EQ( i.s.nUpdateExistsCall, 1 );
// update with the same value must be empty - no functor is called
for ( auto& i : arr2 ) {
EXPECT_EQ( i.s.nUpdateExistsCall, 1 );
- std::pair<bool, bool> ret = l.update( i, update_functor() );
+ std::pair<bool, bool> ret = l.update( i, update_functor());
EXPECT_TRUE( ret.first );
EXPECT_FALSE( ret.second );
EXPECT_EQ( i.s.nUpdateExistsCall, 1 );
if ( i.nKey & 1 )
EXPECT_TRUE( l.erase( i.nKey ));
else
- EXPECT_TRUE( l.erase_with( other_item( i.nKey ), other_less() ));
+ EXPECT_TRUE( l.erase_with( other_item( i.nKey ), other_less()));
EXPECT_FALSE( l.contains( i ));
}
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
EXPECT_TRUE( ret.second );
EXPECT_EQ( i.s.nUpdateNewCall, updateNewCall + 1 );
}
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nEraseCall, 1 );
EXPECT_FALSE( l.contains( i.nKey ));
}
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
for ( auto& i : arr )
EXPECT_TRUE( l.insert( i ));
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
// unlink test
for ( auto& i : arr )
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
for ( auto& i : arr ) {
value_type val( i );
EXPECT_TRUE( l.contains( val ));
EXPECT_FALSE( l.unlink( val ));
- EXPECT_TRUE( l.contains( val ) );
+ EXPECT_TRUE( l.contains( val ));
EXPECT_TRUE( l.unlink( i ));
EXPECT_FALSE( l.unlink( i ));
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 5 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
// Iterators on empty list
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
int key = 0;
for ( auto it = l.begin(); it != l.end(); ++it ) {
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
typedef typename List::guarded_ptr guarded_ptr;
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
guarded_ptr gp;
for ( auto& i : arr ) {
gp = l.get( i.nKey );
EXPECT_TRUE( !gp );
- gp = l.get_with( other_item( i.nKey ), other_less() );
+ gp = l.get_with( other_item( i.nKey ), other_less());
EXPECT_TRUE( !gp );
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
gp = l.get( i.nKey );
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->nKey, i.nKey );
EXPECT_EQ( gp->nVal, i.nVal );
- gp = l.get_with( other_item( i.nKey ), other_less() );
+ gp = l.get_with( other_item( i.nKey ), other_less());
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->nKey, i.nKey );
EXPECT_EQ( gp->nVal, i.nVal );
if ( i & 1 )
gp = l.extract( i );
else
- gp = l.extract_with( other_item( i ), other_less() );
+ gp = l.extract_with( other_item( i ), other_less());
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->nKey, i );
gp = l.extract( i );
EXPECT_TRUE( !gp );
- gp = l.extract_with( other_item( i ), other_less() );
+ gp = l.extract_with( other_item( i ), other_less());
EXPECT_TRUE( !gp );
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
};
stat& operator =( const stat& s )
{
- memcpy( this, &s, sizeof( s ) );
+ memcpy( this, &s, sizeof( s ));
return *this;
}
};
struct cmp {
int operator ()( const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()( const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert / find
EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less(), []( value_type& item, other_item const& ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 3 );
- EXPECT_FALSE( l.insert( i ) );
- ASSERT_FALSE( l.empty() );
+ EXPECT_FALSE( l.insert( i ));
+ ASSERT_FALSE( l.empty());
}
ASSERT_CONTAINER_SIZE( l, nSize );
EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less(), []( value_type& item, other_item const& ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 6 );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// update existing test
for ( auto& i : arr ) {
EXPECT_EQ( i.s.nUpdateExistsCall, 0 );
- std::pair<bool, bool> ret = l.update( i, update_functor() );
+ std::pair<bool, bool> ret = l.update( i, update_functor());
EXPECT_TRUE( ret.first );
EXPECT_FALSE( ret.second );
EXPECT_EQ( i.s.nUpdateExistsCall, 1 );
if ( i.nKey & 1 )
EXPECT_TRUE( l.erase( i.nKey ));
else
- EXPECT_TRUE( l.erase_with( other_item( i.nKey ), other_less() ));
+ EXPECT_TRUE( l.erase_with( other_item( i.nKey ), other_less()));
EXPECT_FALSE( l.contains( i ));
}
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
EXPECT_TRUE( ret.second );
EXPECT_EQ( i.s.nUpdateNewCall, 1 );
}
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nEraseCall, 1 );
EXPECT_FALSE( l.contains( i.nKey ));
}
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
for ( auto& i : arr )
EXPECT_TRUE( l.insert( i ));
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
// unlink test
for ( auto& i : arr )
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
for ( auto& i : arr ) {
value_type val( i );
EXPECT_TRUE( l.contains( val ));
EXPECT_FALSE( l.unlink( val ));
- EXPECT_TRUE( l.contains( val ) );
+ EXPECT_TRUE( l.contains( val ));
EXPECT_TRUE( l.unlink( i ));
EXPECT_FALSE( l.unlink( i ));
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 4 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
// Iterators on empty list
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
int key = 0;
for ( auto it = l.begin(); it != l.end(); ++it ) {
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
};
typedef typename List::guarded_ptr guarded_ptr;
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
guarded_ptr gp;
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->nKey, i.nKey );
EXPECT_EQ( gp->nVal, i.nVal );
- gp = l.get_with( other_item( i.nKey ), other_less() );
+ gp = l.get_with( other_item( i.nKey ), other_less());
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->nKey, i.nKey );
EXPECT_EQ( gp->nVal, i.nVal );
gp = l.extract( i );
EXPECT_TRUE( !gp );
- gp = l.extract_with( other_item( i ), other_less() );
+ gp = l.extract_with( other_item( i ), other_less());
EXPECT_TRUE( !gp );
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
};
stat& operator =( const stat& s )
{
- memcpy( this, &s, sizeof( s ) );
+ memcpy( this, &s, sizeof( s ));
return *this;
}
};
struct cmp {
int operator ()( const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()( const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert / find
EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less(), []( value_type& item, other_item const& ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 3 );
- EXPECT_FALSE( l.insert( i ) );
- ASSERT_FALSE( l.empty() );
+ EXPECT_FALSE( l.insert( i ));
+ ASSERT_FALSE( l.empty());
}
ASSERT_CONTAINER_SIZE( l, nSize );
EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less(), []( value_type& item, other_item const& ) { ++item.s.nFindCall; } ));
EXPECT_EQ( i.s.nFindCall, 6 );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// update existing test
for ( auto& i : arr ) {
EXPECT_EQ( i.s.nUpdateExistsCall, 0 );
- std::pair<bool, bool> ret = l.update( i, update_functor() );
+ std::pair<bool, bool> ret = l.update( i, update_functor());
EXPECT_TRUE( ret.first );
EXPECT_FALSE( ret.second );
EXPECT_EQ( i.s.nUpdateExistsCall, 1 );
// clear() test
l.clear();
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
EXPECT_EQ( i.s.nUpdateNewCall, 1 );
}
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear( mock_disposer2());
- EXPECT_TRUE( l.empty() );
+ EXPECT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// Apply retired pointer to clean links
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
int key = 0;
for ( auto it = l.begin(); it != l.end(); ++it ) {
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
size_t idx = 0;
for ( auto it = l.begin(); it != l.end(); ++it, ++idx ) {
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
};
typedef typename List::raw_ptr raw_ptr;
typedef typename List::rcu_lock rcu_lock;
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// get() test
}
{
rcu_lock lock;
- raw_ptr rp = l.get_with( other_item( i.nKey ), other_less() );
+ raw_ptr rp = l.get_with( other_item( i.nKey ), other_less());
ASSERT_FALSE( !rp );
EXPECT_EQ( rp->nKey, i.nKey );
EXPECT_EQ( rp->nVal, i.nVal );
gp = l.extract( i );
EXPECT_TRUE( !gp );
- gp = l.extract_with( other_item( i ), other_less() );
+ gp = l.extract_with( other_item( i ), other_less());
EXPECT_TRUE( !gp );
}
}
if ( i & 1 )
gp = l.extract( i );
else
- gp = l.extract_with( other_item( i ), other_less() );
+ gp = l.extract_with( other_item( i ), other_less());
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->nKey, i );
gp = l.extract( i );
EXPECT_TRUE( !gp );
- gp = l.extract_with( other_item( i ), other_less() );
+ gp = l.extract_with( other_item( i ), other_less());
EXPECT_TRUE( !gp );
}
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
List::gc::force_dispose();
for ( auto const& i : arr ) {
EXPECT_EQ( i.s.nDisposeCount, 1 );
- EXPECT_FALSE( l.contains( i ) );
+ EXPECT_FALSE( l.contains( i ));
}
}
};
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
- size_t const nSetSize = std::max( s.head_size() * 2, static_cast<size_t>(100) );
+ size_t const nSetSize = std::max( s.head_size() * 2, static_cast<size_t>(100));
typedef typename Set::value_type value_type;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
EXPECT_EQ( i.nInsertCount, 0u );
ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nInsertCount;} ));
EXPECT_EQ( i.nInsertCount, 1u );
- ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nInsertCount;} ) );
+ ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nInsertCount;} ));
EXPECT_EQ( i.nInsertCount, 1u );
i.nInsertCount = 0;
break;
break;
}
- ASSERT_TRUE( s.contains( i.nKey ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
}
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[ idx ];
- ASSERT_TRUE( s.contains( i.nKey ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
EXPECT_EQ( i.nFindCount, 0u );
- ASSERT_TRUE( s.find( i.nKey, []( value_type& v ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type& v ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
value_type v( i );
case 0:
ASSERT_FALSE( s.unlink( v ));
ASSERT_TRUE( s.unlink( i ));
- ASSERT_FALSE( s.unlink( i ) );
+ ASSERT_FALSE( s.unlink( i ));
break;
case 1:
ASSERT_TRUE( s.erase( i.key()));
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 2:
EXPECT_EQ( i.nEraseCount, 0u );
ASSERT_FALSE( s.contains( i.nKey ));
ASSERT_FALSE( s.find( i.nKey, []( value_type const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
i.clear_stat();
ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// Forward iterator test
ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
// Force retiring cycle
Set::gc::force_dispose();
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( nSetSize );
indices.reserve( nSetSize );
for ( size_t key = 0; key < nSetSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Set::guarded_ptr gp;
for ( auto idx : indices ) {
auto& i = data[idx];
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_TRUE( !gp );
gp = s.extract( i.key());
// fill set
for ( auto& i : data ) {
i.nDisposeCount = 0;
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
// get/extract
auto& i = data[idx];
EXPECT_EQ( i.nFindCount, 0u );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
++gp->nEraseCount;
EXPECT_EQ( i.nEraseCount, 1u );
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_TRUE( !gp );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_TRUE( !gp );
}
gp.release();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
// erase_at( iterator )
for ( auto& i : data ) {
i.clear_stat();
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
for ( auto it = s.begin(); it != s.end(); ++it ) {
- ASSERT_TRUE( s.erase_at( it ) );
- ASSERT_FALSE( s.erase_at( it ) );
+ ASSERT_TRUE( s.erase_at( it ));
+ ASSERT_FALSE( s.erase_at( it ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
// erase_at( reverse_iterator )
for ( auto& i : data ) {
i.clear_stat();
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
for ( auto it = s.rbegin(); it != s.rend(); ++it ) {
- ASSERT_TRUE( s.erase_at( it ) );
- ASSERT_FALSE( s.erase_at( it ) );
+ ASSERT_TRUE( s.erase_at( it ));
+ ASSERT_FALSE( s.erase_at( it ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
- size_t const nSetSize = std::max( s.head_size() * 2, static_cast<size_t>(100) );
+ size_t const nSetSize = std::max( s.head_size() * 2, static_cast<size_t>(100));
std::vector< value_type > data;
std::vector< size_t> indices;
data.reserve( nSetSize );
indices.reserve( nSetSize );
for ( size_t key = 0; key < nSetSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Set::exempt_ptr xp;
value_type * rp;
{
rcu_lock l;
- rp = s.get( i.key() );
+ rp = s.get( i.key());
ASSERT_TRUE( !rp );
}
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
}
// fill set
for ( auto& i : data ) {
i.nDisposeCount = 0;
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
// get/extract
{
rcu_lock l;
EXPECT_EQ( i.nFindCount, 0u );
- rp = s.get( i.key() );
+ rp = s.get( i.key());
ASSERT_FALSE( !rp );
++rp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
++xp->nEraseCount;
EXPECT_EQ( i.nEraseCount, 1u );
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
struct cmp {
int operator ()(const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()(const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
ASSERT_TRUE( s.find( i.nKey ) == s.end());
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less()) == s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
std::pair<bool, bool> updResult;
updResult = s.update( i, []( value_type& val, value_type* arg)
{
ASSERT_TRUE( arg != nullptr );
- EXPECT_EQ( val.key(), arg->key() );
+ EXPECT_EQ( val.key(), arg->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
EXPECT_EQ( i.nUpdateNewCount, 0u );
ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
- ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ) );
+ ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
i.nUpdateNewCount = 0;
break;
break;
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()));
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
- ASSERT_TRUE( s.find( i.nKey ) != s.end() );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less() ) != s.end() );
- EXPECT_EQ( s.find( i.nKey )->nKey, i.key() );
- EXPECT_EQ( s.find_with( other_item( i.key() ), other_less())->nKey, i.key() );
+ ASSERT_TRUE( s.find( i.nKey ) != s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) != s.end());
+ EXPECT_EQ( s.find( i.nKey )->nKey, i.key());
+ EXPECT_EQ( s.find_with( other_item( i.key()), other_less())->nKey, i.key());
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[ idx ];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
EXPECT_EQ( i.nFindCount, 0u );
- ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
- ASSERT_TRUE( s.find( i.nKey ) != s.end() );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less()) != s.end() );
- EXPECT_EQ( s.find( i.nKey )->nKey, i.key() );
- EXPECT_EQ( s.find_with( other_item( i.key() ), other_less())->nKey, i.key() );
+ ASSERT_TRUE( s.find( i.nKey ) != s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) != s.end());
+ EXPECT_EQ( s.find( i.nKey )->nKey, i.key());
+ EXPECT_EQ( s.find_with( other_item( i.key()), other_less())->nKey, i.key());
value_type v( i );
case 0:
ASSERT_FALSE( s.unlink( v ));
ASSERT_TRUE( s.unlink( i ));
- ASSERT_FALSE( s.unlink( i ) );
+ ASSERT_FALSE( s.unlink( i ));
break;
case 1:
ASSERT_TRUE( s.erase( i.key()));
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 2:
ASSERT_TRUE( s.erase( v ));
- ASSERT_FALSE( s.erase( v ) );
+ ASSERT_FALSE( s.erase( v ));
break;
case 3:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 4:
EXPECT_EQ( i.nEraseCount, 0u );
break;
case 5:
EXPECT_EQ( i.nEraseCount, 0u );
- ASSERT_TRUE( s.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
break;
}
ASSERT_FALSE( s.contains( other_item( i.key()), other_less()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
- ASSERT_TRUE( s.find( i.nKey ) == s.end() );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less() ) == s.end() );
+ ASSERT_TRUE( s.find( i.nKey ) == s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// Force retiring cycle
i.clear_stat();
ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// Iterator test
ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
// Force retiring cycle
Set::gc::force_dispose();
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Set::guarded_ptr gp;
gp = s.get( i );
ASSERT_TRUE( !gp );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_TRUE( !gp );
gp = s.get_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
// fill set
for ( auto& i : data ) {
i.nDisposeCount = 0;
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
// get/extract
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 2u );
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !gp );
gp = s.extract( i );
ASSERT_TRUE( !gp );
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_TRUE( !gp );
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
}
gp.release();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Item>
size_t operator()( const Item& i ) const
{
- return (*this)( i.key() );
+ return (*this)( i.key());
}
};
struct cmp {
int operator ()(const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()(const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
EXPECT_EQ( i.nUpdateNewCount, 0u );
ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
- ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ) );
+ ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
i.nUpdateNewCount = 0;
break;
break;
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()));
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[ idx ];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
EXPECT_EQ( i.nFindCount, 0u );
- ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
value_type v( i );
case 0:
ASSERT_FALSE( s.unlink( v ));
ASSERT_TRUE( s.unlink( i ));
- ASSERT_FALSE( s.unlink( i ) );
+ ASSERT_FALSE( s.unlink( i ));
break;
case 1:
ASSERT_TRUE( s.erase( i.key()));
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 2:
ASSERT_TRUE( s.erase( v ));
- ASSERT_FALSE( s.erase( v ) );
+ ASSERT_FALSE( s.erase( v ));
break;
case 3:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 4:
EXPECT_EQ( i.nEraseCount, 0u );
break;
case 5:
EXPECT_EQ( i.nEraseCount, 0u );
- ASSERT_TRUE( s.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
break;
}
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// Force retiring cycle
i.clear_stat();
ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// Iterator test
ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
// Force retiring cycle
Set::gc::force_dispose();
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Set::guarded_ptr gp;
gp = s.get( i );
ASSERT_TRUE( !gp );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_TRUE( !gp );
gp = s.get_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
// fill set
for ( auto& i : data ) {
i.nDisposeCount = 0;
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
// get/extract
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 2u );
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !gp );
gp = s.extract( i );
ASSERT_TRUE( !gp );
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_TRUE( !gp );
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
}
gp.release();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// Force retiring cycle
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Item>
size_t operator()( const Item& i ) const
{
- return (*this)( i.key() );
+ return (*this)( i.key());
}
};
struct cmp {
int operator ()(const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()(const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
ASSERT_TRUE( s.contains( i.nKey ) == &i );
ASSERT_TRUE( s.contains( i ) == &i );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less()) == &i );
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) == &i );
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
}
};
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Set::exempt_ptr xp;
typename Set::raw_ptr rp;
rcu_lock l;
rp = s.get( i );
ASSERT_TRUE( !rp );
- rp = s.get( i.key() );
+ rp = s.get( i.key());
ASSERT_TRUE( !rp );
rp = s.get_with( other_item( i.key()), other_less());
ASSERT_TRUE( !rp );
xp = s.extract( i );
ASSERT_TRUE( !xp );
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !xp );
}
else {
xp = s.extract( i );
ASSERT_TRUE( !xp );
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !xp );
}
}
// fill set
for ( auto& i : data ) {
i.nDisposeCount = 0;
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
// get/extract
++rp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
- rp = s.get( i.key() );
+ rp = s.get( i.key());
ASSERT_FALSE( !rp );
++rp->nFindCount;
EXPECT_EQ( i.nFindCount, 2u );
xp = s.extract( i );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !xp );
xp = s.extract( i );
ASSERT_TRUE( !xp );
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !xp );
}
}
xp = s.extract( i );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !xp );
xp = s.extract( i );
ASSERT_TRUE( !xp );
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !xp );
}
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
struct cmp {
int operator ()(const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()(const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
ASSERT_TRUE( s.find( i.nKey ) == s.end());
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less()) == s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
std::pair<bool, bool> updResult;
updResult = s.update( i, []( value_type& val, value_type* arg)
{
ASSERT_TRUE( arg != nullptr );
- EXPECT_EQ( val.key(), arg->key() );
+ EXPECT_EQ( val.key(), arg->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
EXPECT_EQ( i.nUpdateNewCount, 0u );
ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
- ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ) );
+ ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
i.nUpdateNewCount = 0;
break;
break;
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()));
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
- ASSERT_TRUE( s.find( i.nKey ) != s.end() );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less() ) != s.end() );
- EXPECT_EQ( s.find( i.nKey )->nKey, i.key() );
- EXPECT_EQ( s.find_with( other_item( i.key() ), other_less())->nKey, i.key() );
+ ASSERT_TRUE( s.find( i.nKey ) != s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) != s.end());
+ EXPECT_EQ( s.find( i.nKey )->nKey, i.key());
+ EXPECT_EQ( s.find_with( other_item( i.key()), other_less())->nKey, i.key());
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[ idx ];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
EXPECT_EQ( i.nFindCount, 0u );
- ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
- ASSERT_TRUE( s.find( i.nKey ) != s.end() );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less()) != s.end() );
- EXPECT_EQ( s.find( i.nKey )->nKey, i.key() );
- EXPECT_EQ( s.find_with( other_item( i.key() ), other_less())->nKey, i.key() );
+ ASSERT_TRUE( s.find( i.nKey ) != s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) != s.end());
+ EXPECT_EQ( s.find( i.nKey )->nKey, i.key());
+ EXPECT_EQ( s.find_with( other_item( i.key()), other_less())->nKey, i.key());
value_type v( i );
case 0:
ASSERT_FALSE( s.unlink( v ));
ASSERT_TRUE( s.unlink( i ));
- ASSERT_FALSE( s.unlink( i ) );
+ ASSERT_FALSE( s.unlink( i ));
break;
case 1:
ASSERT_TRUE( s.erase( i.key()));
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 2:
ASSERT_TRUE( s.erase( v ));
- ASSERT_FALSE( s.erase( v ) );
+ ASSERT_FALSE( s.erase( v ));
break;
case 3:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 4:
EXPECT_EQ( i.nEraseCount, 0u );
break;
case 5:
EXPECT_EQ( i.nEraseCount, 0u );
- ASSERT_TRUE( s.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
break;
}
ASSERT_FALSE( s.contains( other_item( i.key()), other_less()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
- ASSERT_TRUE( s.find( i.nKey ) == s.end() );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less() ) == s.end() );
+ ASSERT_TRUE( s.find( i.nKey ) == s.end());
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// Force retiring cycle
i.clear_stat();
ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// Iterator test
ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
// Force retiring cycle
Set::gc::force_dispose();
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Set::guarded_ptr gp;
gp = s.get( i );
ASSERT_TRUE( !gp );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_TRUE( !gp );
gp = s.get_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
// fill set
for ( auto& i : data ) {
i.nDisposeCount = 0;
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
// get/extract
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 2u );
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !gp );
gp = s.extract( i );
ASSERT_TRUE( !gp );
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_TRUE( !gp );
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
}
gp.release();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// Force retiring cycle
struct cmp {
int operator ()( const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()( const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert/find
EXPECT_EQ( key.nKey, n.nKey );
EXPECT_EQ( n.nKey * 5, n.nVal );
} ));
- ASSERT_FALSE( l.find( i ) == l.end() );
+ ASSERT_FALSE( l.find( i ) == l.end());
EXPECT_EQ( l.find( i.nKey )->nKey, i.nKey );
- ASSERT_FALSE( l.find_with( other_item( i.nKey ), other_less() ) == l.end() );
- EXPECT_EQ( l.find_with( other_item( i.nKey ), other_less() )->nKey, i.nKey );
+ ASSERT_FALSE( l.find_with( other_item( i.nKey ), other_less()) == l.end());
+ EXPECT_EQ( l.find_with( other_item( i.nKey ), other_less())->nKey, i.nKey );
auto pair = l.upsert( i.nKey, false );
EXPECT_TRUE( pair.first );
EXPECT_TRUE( pair.first );
EXPECT_FALSE( pair.second );
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
// erase
for ( auto const&i : arr ) {
- ASSERT_FALSE( l.find( i.nKey ) == l.end() );
+ ASSERT_FALSE( l.find( i.nKey ) == l.end());
EXPECT_EQ( l.find( i.nKey )->nKey, i.nKey );
- ASSERT_FALSE( l.find_with( other_item( i.nKey ), other_less() ) == l.end() );
- EXPECT_EQ( l.find_with( other_item( i.nKey ), other_less() )->nKey, i.nKey );
+ ASSERT_FALSE( l.find_with( other_item( i.nKey ), other_less()) == l.end());
+ EXPECT_EQ( l.find_with( other_item( i.nKey ), other_less())->nKey, i.nKey );
switch ( i.nKey % 4 ) {
case 0:
EXPECT_FALSE( l.find( i, []( value_type&, value_type const&) {} ));
EXPECT_FALSE( l.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( l.find_with( other_item( i.nKey ), other_less(), []( value_type&, other_item const& ) {} ));
- EXPECT_TRUE( l.find( i ) == l.end() );
- EXPECT_TRUE( l.find( i.nKey ) == l.end() );
- EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less() ) == l.end() );
+ EXPECT_TRUE( l.find( i ) == l.end());
+ EXPECT_TRUE( l.find( i.nKey ) == l.end());
+ EXPECT_TRUE( l.find_with( other_item( i.nKey ), other_less()) == l.end());
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// clear test
for ( auto& i : arr )
EXPECT_TRUE( l.insert( i ));
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// empty list iterator test
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
EXPECT_EQ( static_cast<size_t>(key), nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
guarded_ptr gp;
gp->nVal = gp->nKey * 10;
++nCount;
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// extract() test
for ( auto const& i : arr ) {
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
--nCount;
EXPECT_FALSE( gp );
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert/find
EXPECT_FALSE( l.find( i.key, []( list_value_type& ) {} ));
EXPECT_FALSE( l.find( key_type( i.key ), []( list_value_type& ) {} ));
EXPECT_FALSE( l.find_with( other_key( i.key ), other_less(), []( list_value_type& ) {} ));
- EXPECT_TRUE( l.find( i.key ) == l.end() );
+ EXPECT_TRUE( l.find( i.key ) == l.end());
EXPECT_TRUE( l.find_with( other_key( i.key ), other_less()) == l.end());
switch ( i.key % 6 ) {
ret = l.upsert( i.key, i.val );
EXPECT_TRUE( ret.first );
EXPECT_TRUE( ret.second );
- EXPECT_TRUE( l.contains( i.key ) );
+ EXPECT_TRUE( l.contains( i.key ));
ret = l.upsert( i.key, i.key * 12 );
EXPECT_TRUE( ret.first );
EXPECT_TRUE( pair.first );
EXPECT_FALSE( pair.second );
- EXPECT_FALSE( l.find( i.key ) == l.end() );
+ EXPECT_FALSE( l.find( i.key ) == l.end());
EXPECT_EQ( l.find( i.key )->first.nKey, i.key );
EXPECT_EQ( l.find( i.key )->second.val, i.key * 3 );
- EXPECT_FALSE( l.find_with( other_key( i.key ), other_less() ) == l.end() );
+ EXPECT_FALSE( l.find_with( other_key( i.key ), other_less()) == l.end());
EXPECT_EQ( l.find_with( other_key( i.key ), other_less())->first.nKey, i.key );
EXPECT_EQ( l.find_with( other_key( i.key ), other_less())->second.val, i.key * 3 );
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
// erase
EXPECT_FALSE( l.find_with( other_key( i.key ), other_less(), []( list_value_type& ) {} ));
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// clear test
for ( auto& i : arr )
EXPECT_TRUE( l.insert( i.key, i.val ));
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// empty list iterator test
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
int key = 0;
for ( auto& it : l ) {
- EXPECT_EQ( key, it.first.key() );
- EXPECT_EQ( it.second.val, it.first.key() );
+ EXPECT_EQ( key, it.first.key());
+ EXPECT_EQ( it.second.val, it.first.key());
it.second.val = it.first.key() * 10;
++key;
}
key = 0;
for ( auto it = l.cbegin(); it != l.cend(); ++it ) {
- EXPECT_EQ( key, it->first.key() );
+ EXPECT_EQ( key, it->first.key());
EXPECT_EQ( it->first.key() * 10, it->second.val );
++key;
}
key = 0;
for ( auto it = l.begin(); it != l.end(); ++it ) {
- EXPECT_EQ( key, it->first.key() );
+ EXPECT_EQ( key, it->first.key());
EXPECT_EQ( it->first.key() * 10, it->second.val );
it->second.val = it->first.key() * 2;
++key;
EXPECT_EQ( static_cast<size_t>(key), nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
guarded_ptr gp;
gp->second.val = gp->first.nKey * 10;
++nCount;
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// extract() test
for ( auto const& i : arr ) {
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
--nCount;
EXPECT_FALSE( gp );
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert/find
EXPECT_TRUE( pair.first );
EXPECT_FALSE( pair.second );
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
// erase
EXPECT_FALSE( l.find_with( other_key( i.key ), other_less(), []( list_value_type& ) {} ));
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// clear test
for ( auto& i : arr )
EXPECT_TRUE( l.insert( i.key, i.val ));
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// empty list iterator test
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
int key = 0;
for ( auto& it : l ) {
- EXPECT_EQ( key, it.first.key() );
- EXPECT_EQ( it.second.val, it.first.key() );
+ EXPECT_EQ( key, it.first.key());
+ EXPECT_EQ( it.second.val, it.first.key());
it.second.val = it.first.key() * 10;
++key;
}
key = 0;
for ( auto it = l.cbegin(); it != l.cend(); ++it ) {
- EXPECT_EQ( key, it->first.key() );
+ EXPECT_EQ( key, it->first.key());
EXPECT_EQ( it->first.key() * 10, it->second.val );
++key;
}
key = 0;
for ( auto it = l.begin(); it != l.end(); ++it ) {
- EXPECT_EQ( key, it->first.key() );
+ EXPECT_EQ( key, it->first.key());
EXPECT_EQ( it->first.key() * 10, it->second.val );
it->second.val = it->first.key() * 2;
++key;
EXPECT_EQ( static_cast<size_t>(key), nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
guarded_ptr gp;
gp->second.val = gp->first.nKey * 10;
++nCount;
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// extract() test
for ( auto const& i : arr ) {
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
--nCount;
EXPECT_FALSE( gp );
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert/find
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, 0 );
it = l.contains( i.key );
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, 0 );
it = l.insert( i.key );
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
case 1:
{
auto it = l.insert( i.key, i.val );
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.val );
it = l.contains( key_type( i.key ));
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.val );
it = l.insert( key_type( i.key ), i.val );
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
case 2:
{
auto it = l.emplace( i.key, i.key * 100 );
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.key * 100 );
it = l.contains( other_key( i.key ), other_less());
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.key * 100 );
it = l.emplace( i.key, i.key * 50 );
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
case 3:
EXPECT_FALSE( pair.second );
pair = l.update( i.key );
- ASSERT_FALSE( pair.first == l.end() );
+ ASSERT_FALSE( pair.first == l.end());
EXPECT_TRUE( pair.second );
pair.first->second.val = i.key * 3;
- auto it = l.contains( other_key( i.key ), other_less() );
- ASSERT_FALSE( it == l.end() );
+ auto it = l.contains( other_key( i.key ), other_less());
+ ASSERT_FALSE( it == l.end());
EXPECT_TRUE( it == pair.first );
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.key * 3 );
pair = l.update( i.key, false );
- ASSERT_FALSE( pair.first == l.end() );
+ ASSERT_FALSE( pair.first == l.end());
EXPECT_TRUE( pair.first == it );
EXPECT_FALSE( pair.second );
EXPECT_EQ( pair.first->first.key, i.key );
pair.first->second.val = i.key * 5;
- it = l.contains( other_key( i.key ), other_less() );
- ASSERT_FALSE( it == l.end() );
+ it = l.contains( other_key( i.key ), other_less());
+ ASSERT_FALSE( it == l.end());
EXPECT_TRUE( it == pair.first );
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.key * 5 );
EXPECT_EQ( i.key, n.first.key );
n.second.val = n.first.key * 7;
});
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.key * 7 );
it = l.contains( i.key );
- ASSERT_FALSE( it == l.end() );
+ ASSERT_FALSE( it == l.end());
EXPECT_EQ( it->first.key, i.key );
EXPECT_EQ( it->second.val, i.key * 7 );
it = l.insert_with( i.key, []( list_value_type& ) {
EXPECT_TRUE( false );
});
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
}
EXPECT_TRUE( l.contains( key_type( i.key )) != l.end());
EXPECT_TRUE( l.contains( other_key( i.key ), other_less()) != l.end());
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// empty list iterator test
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
EXPECT_EQ( static_cast<size_t>(key), nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
typedef typename List::exempt_ptr exempt_ptr;
rcu_lock lock;
raw_ptr rp = l.get( i.key );
EXPECT_TRUE( !rp );
- rp = l.get_with( other_key( i.key ), other_less() );
+ rp = l.get_with( other_key( i.key ), other_less());
EXPECT_TRUE( !rp );
}
}
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// extract()
}
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
}
};
struct cmp {
int operator ()( const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()( const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert/find
EXPECT_TRUE( pair.first );
EXPECT_FALSE( pair.second );
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
// erase
EXPECT_FALSE( l.find_with( other_item( i.nKey ), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// clear test
for ( auto& i : arr )
EXPECT_TRUE( l.insert( i ));
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// empty list iterator test
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
EXPECT_EQ( static_cast<size_t>(key), nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
guarded_ptr gp;
gp->nVal = gp->nKey * 10;
++nCount;
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// extract() test
for ( auto const& i : arr ) {
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nCount );
--nCount;
EXPECT_FALSE( gp );
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
}
};
struct cmp {
int operator ()( const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()( const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
// insert/find
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, it->nKey * 2 );
it = l.contains( i.nKey );
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, it->nKey * 2 );
it = l.insert( i.nKey );
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
case 1:
{
auto it = l.insert( i );
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nVal );
it = l.contains( i );
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nVal );
it = l.insert( i );
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
case 2:
{
auto it = l.emplace( i.nKey, i.nKey * 100 );
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nKey * 100 );
it = l.contains( other_item( i.nKey ), other_less());
- EXPECT_FALSE( it == l.end() );
+ EXPECT_FALSE( it == l.end());
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nKey * 100 );
it = l.emplace( i.nKey, i.nKey * 50 );
- EXPECT_TRUE( it == l.end() );
+ EXPECT_TRUE( it == l.end());
break;
}
case 3:
EXPECT_FALSE( pair.second );
pair = l.update( i.nKey );
- EXPECT_FALSE( pair.first == l.end() );
+ EXPECT_FALSE( pair.first == l.end());
EXPECT_TRUE( pair.second );
pair.first->nVal = i.nKey * 3;
EXPECT_EQ( pair.first->nKey, i.nKey );
- auto it = l.contains( other_item( i.nKey ), other_less() );
- EXPECT_FALSE( it == l.end() );
+ auto it = l.contains( other_item( i.nKey ), other_less());
+ EXPECT_FALSE( it == l.end());
EXPECT_TRUE( it == pair.first );
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nKey * 3 );
pair = l.update( i.nKey, false );
- EXPECT_FALSE( pair.first == l.end() );
+ EXPECT_FALSE( pair.first == l.end());
EXPECT_TRUE( pair.first == it );
EXPECT_FALSE( pair.second );
EXPECT_EQ( pair.first->nKey, i.nKey );
pair.first->nVal = i.nKey * 5;
- it = l.contains( other_item( i.nKey ), other_less() );
- EXPECT_FALSE( it == l.end() );
+ it = l.contains( other_item( i.nKey ), other_less());
+ EXPECT_FALSE( it == l.end());
EXPECT_TRUE( it == pair.first );
EXPECT_EQ( it->nKey, i.nKey );
EXPECT_EQ( it->nVal, i.nKey * 5 );
EXPECT_TRUE( l.contains( i.nKey ) != l.end());
EXPECT_TRUE( l.contains( other_item( i.nKey ), other_less()) != l.end());
- EXPECT_FALSE( l.empty() );
+ EXPECT_FALSE( l.empty());
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
EXPECT_CONTAINER_SIZE( l, nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
// empty list iterator test
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
for ( auto& i : arr )
EXPECT_EQ( static_cast<size_t>(key), nSize );
l.clear();
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
EXPECT_CONTAINER_SIZE( l, 0 );
}
};
}
shuffle( arr, arr + nSize );
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
typedef typename List::exempt_ptr exempt_ptr;
rcu_lock lock;
raw_ptr rp = l.get( i.nKey );
EXPECT_TRUE( !rp );
- rp = l.get_with( other_item( i.nKey ), other_less() );
+ rp = l.get_with( other_item( i.nKey ), other_less());
EXPECT_TRUE( !rp );
}
- EXPECT_TRUE( l.insert( i ) );
+ EXPECT_TRUE( l.insert( i ));
{
rcu_lock lock;
}
}
- ASSERT_FALSE( l.empty() );
+ ASSERT_FALSE( l.empty());
ASSERT_CONTAINER_SIZE( l, nSize );
// extract()
}
}
- ASSERT_TRUE( l.empty() );
+ ASSERT_TRUE( l.empty());
ASSERT_CONTAINER_SIZE( l, 0 );
}
};
base_class::test( m );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
typedef typename Map::value_type map_pair;
}
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// get_max
// Precondition: map is empty
// Postcondition: map is empty
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
typedef typename Map::value_type map_pair;
std::vector<key_type> arrKeys;
for ( int i = 0; i < static_cast<int>(kkSize); ++i )
- arrKeys.push_back( key_type( i ) );
- shuffle( arrKeys.begin(), arrKeys.end() );
+ arrKeys.push_back( key_type( i ));
+ shuffle( arrKeys.begin(), arrKeys.end());
std::vector< value_type > arrVals;
for ( size_t i = 0; i < kkSize; ++i ) {
// insert/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
- ASSERT_FALSE( m.contains( i.nKey ) );
- ASSERT_FALSE( m.contains( i ) );
+ ASSERT_FALSE( m.contains( i.nKey ));
+ ASSERT_FALSE( m.contains( i ));
ASSERT_FALSE( m.find( i, []( map_pair const& ) {
ASSERT_TRUE( false );
- } ) );
+ } ));
ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
std::pair< bool, bool > updResult;
switch ( i.nKey % 16 ) {
case 0:
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.insert( i ) );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.insert( i ));
ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
break;
case 1:
- ASSERT_TRUE( m.insert( i.nKey ) );
- ASSERT_FALSE( m.insert( i.nKey ) );
+ ASSERT_TRUE( m.insert( i.nKey ));
+ ASSERT_FALSE( m.insert( i.nKey ));
ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
break;
case 2:
- ASSERT_TRUE( m.insert( std::to_string( i.nKey ) ) );
- ASSERT_FALSE( m.insert( std::to_string( i.nKey ) ) );
+ ASSERT_TRUE( m.insert( std::to_string( i.nKey )) );
+ ASSERT_FALSE( m.insert( std::to_string( i.nKey )) );
ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
break;
case 3:
- ASSERT_TRUE( m.insert( i, val ) );
- ASSERT_FALSE( m.insert( i, val ) );
+ ASSERT_TRUE( m.insert( i, val ));
+ ASSERT_FALSE( m.insert( i, val ));
break;
case 4:
- ASSERT_TRUE( m.insert( i.nKey, val.strVal ) );
- ASSERT_FALSE( m.insert( i.nKey, val.strVal ) );
+ ASSERT_TRUE( m.insert( i.nKey, val.strVal ));
+ ASSERT_FALSE( m.insert( i.nKey, val.strVal ));
break;
case 5:
- ASSERT_TRUE( m.insert( val.strVal, i.nKey ) );
- ASSERT_FALSE( m.insert( val.strVal, i.nKey ) );
+ ASSERT_TRUE( m.insert( val.strVal, i.nKey ));
+ ASSERT_FALSE( m.insert( val.strVal, i.nKey ));
break;
case 6:
ASSERT_TRUE( m.insert_with( i, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
ASSERT_FALSE( m.insert_with( i, []( map_pair& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
break;
case 7:
ASSERT_TRUE( m.insert_with( i.nKey, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
ASSERT_FALSE( m.insert_with( i.nKey, []( map_pair& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
break;
case 8:
ASSERT_TRUE( m.insert_with( val.strVal, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
ASSERT_FALSE( m.insert_with( val.strVal, []( map_pair& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
break;
case 9:
updResult = m.update( i.nKey, []( map_pair&, map_pair* ) {
ASSERT_FALSE( updResult.second );
break;
case 12:
- ASSERT_TRUE( m.emplace( i.nKey ) );
- ASSERT_FALSE( m.emplace( i.nKey ) );
+ ASSERT_TRUE( m.emplace( i.nKey ));
+ ASSERT_FALSE( m.emplace( i.nKey ));
ASSERT_TRUE( m.find( i.nKey, []( map_pair& v ) {
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
- } ) );
+ } ));
break;
case 13:
- ASSERT_TRUE( m.emplace( i, i.nKey ) );
- ASSERT_FALSE( m.emplace( i, i.nKey ) );
+ ASSERT_TRUE( m.emplace( i, i.nKey ));
+ ASSERT_FALSE( m.emplace( i, i.nKey ));
break;
case 14:
{
std::string str = val.strVal;
- ASSERT_TRUE( m.emplace( i, std::move( str ) ) );
- ASSERT_TRUE( str.empty() );
+ ASSERT_TRUE( m.emplace( i, std::move( str )) );
+ ASSERT_TRUE( str.empty());
str = val.strVal;
- ASSERT_FALSE( m.emplace( i, std::move( str ) ) );
- ASSERT_TRUE( str.empty() );
+ ASSERT_FALSE( m.emplace( i, std::move( str )) );
+ ASSERT_TRUE( str.empty());
}
break;
case 15:
{
std::string str = val.strVal;
- ASSERT_TRUE( m.emplace( i, i.nKey, std::move( str ) ) );
- ASSERT_TRUE( str.empty() );
+ ASSERT_TRUE( m.emplace( i, i.nKey, std::move( str )) );
+ ASSERT_TRUE( str.empty());
str = val.strVal;
- ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str ) ) );
- ASSERT_TRUE( str.empty() );
+ ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str )) );
+ ASSERT_TRUE( str.empty());
}
break;
}
- ASSERT_TRUE( m.contains( i.nKey ) );
- ASSERT_TRUE( m.contains( i ) );
+ ASSERT_TRUE( m.contains( i.nKey ));
+ ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
- ASSERT_FALSE( m.begin() == m.end() );
- ASSERT_FALSE( m.cbegin() == m.cend() );
+ ASSERT_FALSE( m.begin() == m.end());
+ ASSERT_FALSE( m.cbegin() == m.cend());
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
{
std::vector< typename Map::level_statistics > vect;
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
- ASSERT_TRUE( m.contains( i.nKey ) );
- ASSERT_TRUE( m.contains( val.strVal ) );
- ASSERT_TRUE( m.contains( i ) );
+ ASSERT_TRUE( m.contains( i.nKey ));
+ ASSERT_TRUE( m.contains( val.strVal ));
+ ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
ASSERT_TRUE( m.find( i.nKey, []( map_pair const& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
switch ( i.nKey % 6 ) {
case 0:
- ASSERT_TRUE( m.erase( i ) );
- ASSERT_FALSE( m.erase( i ) );
+ ASSERT_TRUE( m.erase( i ));
+ ASSERT_FALSE( m.erase( i ));
break;
case 1:
- ASSERT_TRUE( m.erase( i.nKey ) );
- ASSERT_FALSE( m.erase( i.nKey ) );
+ ASSERT_TRUE( m.erase( i.nKey ));
+ ASSERT_FALSE( m.erase( i.nKey ));
break;
case 2:
- ASSERT_TRUE( m.erase( val.strVal ) );
- ASSERT_FALSE( m.erase( val.strVal ) );
+ ASSERT_TRUE( m.erase( val.strVal ));
+ ASSERT_FALSE( m.erase( val.strVal ));
break;
case 3:
ASSERT_TRUE( m.erase( i, []( map_pair& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
ASSERT_FALSE( m.erase( i, []( map_pair& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
break;
case 4:
ASSERT_TRUE( m.erase( i.nKey, []( map_pair& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
ASSERT_FALSE( m.erase( i.nKey, []( map_pair& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
break;
case 5:
ASSERT_TRUE( m.erase( val.strVal, []( map_pair& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
- } ) );
+ } ));
ASSERT_FALSE( m.erase( val.strVal, []( map_pair& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
break;
}
- ASSERT_FALSE( m.contains( i.nKey ) );
- ASSERT_FALSE( m.contains( i ) );
- ASSERT_FALSE( m.contains( val.strVal ) );
+ ASSERT_FALSE( m.contains( i.nKey ));
+ ASSERT_FALSE( m.contains( i ));
+ ASSERT_FALSE( m.contains( val.strVal ));
ASSERT_FALSE( m.find( i, []( map_pair const& ) {
ASSERT_TRUE( false );
- } ) );
+ } ));
ASSERT_FALSE( m.find( i.nKey, []( map_pair const& ) {
EXPECT_TRUE( false );
- } ) );
+ } ));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
- ASSERT_TRUE( m.begin() == m.end() );
- ASSERT_TRUE( m.cbegin() == m.cend() );
+ ASSERT_TRUE( m.begin() == m.end());
+ ASSERT_TRUE( m.cbegin() == m.cend());
// clear
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
+ ASSERT_TRUE( m.insert( i ));
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
}
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
// iterators
gp = m.get( i );
ASSERT_TRUE( !gp );
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// erase_at( iterator )
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
nCount = 0;
++nCount;
}
EXPECT_EQ( nCount, kkSize );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// erase_at( reverse_iterator )
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
nCount = 0;
for ( auto it = m.rbegin(); it != m.rend(); ++it ) {
EXPECT_EQ( it->second.nVal, 0 );
- ASSERT_TRUE( m.erase_at( it ) );
+ ASSERT_TRUE( m.erase_at( it ));
++nCount;
}
EXPECT_EQ( nCount, kkSize );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// erase_at( const_reverse_iterator )
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
nCount = 0;
for ( auto it = m.crbegin(); it != m.crend(); ++it ) {
EXPECT_EQ( it->second.nVal, 0 );
- ASSERT_TRUE( m.erase_at( it ) );
+ ASSERT_TRUE( m.erase_at( it ));
++nCount;
}
EXPECT_EQ( nCount, kkSize );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// erase_at( const_iterator )
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
nCount = 0;
for ( auto it = m.cbegin(); it != m.cend(); ++it ) {
EXPECT_EQ( it->second.nVal, 0 );
- ASSERT_TRUE( m.erase_at( it ) );
+ ASSERT_TRUE( m.erase_at( it ));
++nCount;
}
EXPECT_EQ( nCount, kkSize );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
}
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
// iterators
EXPECT_TRUE( p == nullptr );
}
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
} ));
}
- EXPECT_FALSE( m.empty() );
+ EXPECT_FALSE( m.empty());
EXPECT_CONTAINER_SIZE( m, kkSize );
- EXPECT_FALSE( m.begin() == m.end() );
- EXPECT_FALSE( m.cbegin() == m.cend() );
+ EXPECT_FALSE( m.begin() == m.end());
+ EXPECT_FALSE( m.cbegin() == m.cend());
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
EXPECT_TRUE( m.contains( i.nKey ));
- EXPECT_TRUE( m.contains( val.strVal ) );
+ EXPECT_TRUE( m.contains( val.strVal ));
EXPECT_TRUE( m.contains( i ));
EXPECT_TRUE( m.contains( other_item( i.nKey ), other_less()));
EXPECT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_TRUE( false );
} ));
}
- EXPECT_TRUE( m.empty() );
+ EXPECT_TRUE( m.empty());
EXPECT_CONTAINER_SIZE( m, 0 );
EXPECT_TRUE( m.begin() == m.end());
for ( auto const& i : arrKeys )
EXPECT_TRUE( m.insert( i ));
- EXPECT_FALSE( m.empty() );
+ EXPECT_FALSE( m.empty());
EXPECT_CONTAINER_SIZE( m, kkSize );
m.clear();
- EXPECT_TRUE( m.empty() );
+ EXPECT_TRUE( m.empty());
EXPECT_CONTAINER_SIZE( m, 0 );
}
};
}
for ( auto const& i : arrKeys )
- EXPECT_TRUE( m.insert( i ) );
- EXPECT_FALSE( m.empty() );
+ EXPECT_TRUE( m.insert( i ));
+ EXPECT_FALSE( m.empty());
EXPECT_CONTAINER_SIZE( m, kkSize );
// iterators
ASSERT_TRUE( !gp );
gp = m.get( i );
ASSERT_TRUE( !gp );
- gp = m.get_with( other_item( i.nKey ), other_less() );
+ gp = m.get_with( other_item( i.nKey ), other_less());
ASSERT_TRUE( !gp );
}
- EXPECT_TRUE( m.empty() );
+ EXPECT_TRUE( m.empty());
EXPECT_CONTAINER_SIZE( m, 0 );
}
};
break;
case 1:
it = m.insert( i.nKey );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert( i.nKey ) == m.end());
it->second.nVal = it->first.nKey;
it->second.strVal = std::to_string( it->first.nKey );
break;
case 2:
it = m.insert( std::to_string( i.nKey ));
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert( std::to_string( i.nKey )) == m.end());
it->second.nVal = it->first.nKey;
it->second.strVal = std::to_string( it->first.nKey );
break;
case 3:
it = m.insert( i, val );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert( i, val ) == m.end());
break;
case 4:
it = m.insert( i.nKey, val.strVal );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert( i.nKey, val.strVal ) == m.end());
break;
case 5:
it = m.insert( val.strVal, i.nKey );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert( val.strVal, i.nKey ) == m.end());
break;
case 6:
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
} );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert_with( i, []( map_pair& ) {
EXPECT_TRUE( false );
} ) == m.end());
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
} );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert_with( i.nKey, []( map_pair& ) {
EXPECT_TRUE( false );
} ) == m.end());
v.second.nVal = v.first.nKey;
v.second.strVal = std::to_string( v.first.nKey );
} );
- ASSERT_FALSE( it == m.end() );
+ ASSERT_FALSE( it == m.end());
ASSERT_TRUE( m.insert_with( val.strVal, []( map_pair& ) {
EXPECT_TRUE( false );
} ) == m.end());
break;
case 9:
updResult = m.update( i.nKey, false );
- ASSERT_TRUE( updResult.first == m.end() );
+ ASSERT_TRUE( updResult.first == m.end());
ASSERT_FALSE( updResult.second );
updResult = m.update( i.nKey );
updResult.first->second.nVal = updResult.first->first.nKey;
updResult = m.update( i.nKey, false );
- ASSERT_TRUE( updResult.first != m.end() );
+ ASSERT_TRUE( updResult.first != m.end());
ASSERT_FALSE( updResult.second );
EXPECT_EQ( updResult.first->first.nKey, updResult.first->second.nVal );
updResult.first->second.strVal = std::to_string( updResult.first->second.nVal );
break;
case 10:
updResult = m.update( i, false );
- ASSERT_TRUE( updResult.first == m.end() );
+ ASSERT_TRUE( updResult.first == m.end());
ASSERT_FALSE( updResult.second );
updResult = m.update( i );
break;
case 13:
it = m.emplace( i, i.nKey );
- ASSERT_TRUE( it != m.end() );
+ ASSERT_TRUE( it != m.end());
ASSERT_FALSE( m.emplace( i, i.nKey ) != m.end());
break;
case 14:
{
std::string str = val.strVal;
it = m.emplace( i, std::move( str ));
- ASSERT_TRUE( it != m.end() );
+ ASSERT_TRUE( it != m.end());
ASSERT_TRUE( str.empty());
str = val.strVal;
ASSERT_FALSE( m.emplace( i, std::move( str )) != m.end());
{
std::string str = val.strVal;
it = m.emplace( i, i.nKey, std::move( str ));
- ASSERT_TRUE( it != m.end() );
+ ASSERT_TRUE( it != m.end());
ASSERT_TRUE( str.empty());
str = val.strVal;
ASSERT_FALSE( m.emplace( i, i.nKey, std::move( str )) != m.end());
EXPECT_EQ( it->first.nKey, it->second.nVal );
EXPECT_EQ( std::to_string( it->first.nKey ), it->second.strVal );
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
- ASSERT_FALSE( m.begin() == m.end() );
- ASSERT_FALSE( m.cbegin() == m.cend() );
+ ASSERT_FALSE( m.begin() == m.end());
+ ASSERT_FALSE( m.cbegin() == m.cend());
// clear
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
- ASSERT_TRUE( m.begin() == m.end() );
- ASSERT_TRUE( m.cbegin() == m.cend() );
+ ASSERT_TRUE( m.begin() == m.end());
+ ASSERT_TRUE( m.cbegin() == m.cend());
}
};
}
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
// iterators
typedef typename Map::rcu_lock rcu_lock;
// get/extract
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
for ( auto const& i : arrKeys ) {
value_type const& val = arrVals.at( i.nKey );
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
ASSERT_FALSE( !xp );
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
EXPECT_TRUE( !xp );
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
EXPECT_TRUE( !xp );
ASSERT_TRUE( !rp );
rp = m.get( i );
ASSERT_TRUE( !rp );
- rp = m.get_with( other_item( i.nKey ), other_less() );
+ rp = m.get_with( other_item( i.nKey ), other_less());
ASSERT_TRUE( !rp );
}
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
EXPECT_TRUE( false );
} ));
- EXPECT_TRUE( m.find( i ) == m.end() );
- EXPECT_TRUE( m.find( i.nKey ) == m.end() );
- EXPECT_TRUE( m.find_with( other_item( i.nKey ), other_less() ) == m.end() );
+ EXPECT_TRUE( m.find( i ) == m.end());
+ EXPECT_TRUE( m.find( i.nKey ) == m.end());
+ EXPECT_TRUE( m.find_with( other_item( i.nKey ), other_less()) == m.end());
std::pair< bool, bool > updResult;
res = m.upsert( i, std::move( str ));
EXPECT_TRUE( res.first );
EXPECT_FALSE( res.second );
- EXPECT_TRUE( str.empty() );
+ EXPECT_TRUE( str.empty());
}
break;
}
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
} ));
- ASSERT_TRUE( m.find( i ) != m.end() );
- ASSERT_TRUE( m.find( i.nKey ) != m.end() );
- ASSERT_TRUE( m.find_with( other_item( i.nKey ), other_less() ) != m.end() );
+ ASSERT_TRUE( m.find( i ) != m.end());
+ ASSERT_TRUE( m.find( i.nKey ) != m.end());
+ ASSERT_TRUE( m.find_with( other_item( i.nKey ), other_less()) != m.end());
EXPECT_EQ( m.find( i )->first.nKey, i.nKey );
EXPECT_EQ( m.find( i.nKey )->first.nKey, i.nKey );
- EXPECT_EQ( m.find_with( other_item( i.nKey ), other_less() )->first.nKey, i.nKey );
+ EXPECT_EQ( m.find_with( other_item( i.nKey ), other_less())->first.nKey, i.nKey );
}
- EXPECT_FALSE( m.empty() );
+ EXPECT_FALSE( m.empty());
EXPECT_CONTAINER_SIZE( m, kkSize );
- EXPECT_FALSE( m.begin() == m.end() );
- EXPECT_FALSE( m.cbegin() == m.cend() );
+ EXPECT_FALSE( m.begin() == m.end());
+ EXPECT_FALSE( m.cbegin() == m.cend());
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
EXPECT_TRUE( m.contains( i.nKey ));
- EXPECT_TRUE( m.contains( val.strVal ) );
+ EXPECT_TRUE( m.contains( val.strVal ));
EXPECT_TRUE( m.contains( i ));
EXPECT_TRUE( m.contains( other_item( i.nKey ), other_less()));
EXPECT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_TRUE( false );
} ));
}
- EXPECT_TRUE( m.empty() );
+ EXPECT_TRUE( m.empty());
EXPECT_CONTAINER_SIZE( m, 0 );
EXPECT_TRUE( m.begin() == m.end());
for ( auto const& i : arrKeys )
EXPECT_TRUE( m.insert( i ));
- EXPECT_FALSE( m.empty() );
+ EXPECT_FALSE( m.empty());
EXPECT_CONTAINER_SIZE( m, kkSize );
m.clear();
- EXPECT_TRUE( m.empty() );
+ EXPECT_TRUE( m.empty());
EXPECT_CONTAINER_SIZE( m, 0 );
}
};
}
for ( auto const& i : arrKeys )
- EXPECT_TRUE( m.insert( i ) );
- EXPECT_FALSE( m.empty() );
+ EXPECT_TRUE( m.insert( i ));
+ EXPECT_FALSE( m.empty());
EXPECT_CONTAINER_SIZE( m, kkSize );
// iterators
ASSERT_TRUE( !gp );
gp = m.get( i );
ASSERT_TRUE( !gp );
- gp = m.get_with( other_item( i.nKey ), other_less() );
+ gp = m.get_with( other_item( i.nKey ), other_less());
ASSERT_TRUE( !gp );
}
- EXPECT_TRUE( m.empty() );
+ EXPECT_TRUE( m.empty());
EXPECT_CONTAINER_SIZE( m, 0u );
}
};
shuffle( arrKeys.begin(), arrKeys.end());
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
// extract_min
int nKey = -1;
size_t nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
gp = m.extract_min();
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->first.nKey, nKey + 1 );
nKey = gp->first.nKey;
++nCount;
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
EXPECT_EQ( nCount, kkSize );
// extract_max
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
nKey = kkSize;
nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
gp = m.extract_max();
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->first.nKey, nKey - 1 );
nKey = gp->first.nKey;
++nCount;
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
EXPECT_EQ( nCount, kkSize );
}
base_class::test( m );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
typedef typename Map::exempt_ptr exempt_ptr;
size_t nCount = 0;
int nKey = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
xp = m.extract_min();
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->first.nKey, nKey + 1 );
xp = m.extract_max();
ASSERT_TRUE( !xp );
EXPECT_EQ( kkSize, nCount );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// get_max
nKey = kkSize;
nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
xp = m.extract_max();
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->first.nKey, nKey - 1 );
xp = m.extract_max();
ASSERT_TRUE( !xp );
EXPECT_EQ( kkSize, nCount );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
atomics::memory_order mo_clear = convert_to_store_order(order);
for ( int i = 0; i < 5; ++i ) {
EXPECT_TRUE( !f.test_and_set( order ));
- EXPECT_TRUE( f.test_and_set( order ) );
+ EXPECT_TRUE( f.test_and_set( order ));
f.clear( mo_clear );
}
}
for ( int i = 0; i < 5; ++i ) {
EXPECT_TRUE( !f.test_and_set());
- EXPECT_TRUE( f.test_and_set() );
+ EXPECT_TRUE( f.test_and_set());
f.clear();
}
{
typedef Integral integral_type;
- EXPECT_TRUE( a.is_lock_free() );
+ EXPECT_TRUE( a.is_lock_free());
a.store( (integral_type) 0 );
EXPECT_EQ( a, static_cast<integral_type>( 0 ));
EXPECT_EQ( a.load(), static_cast<integral_type>( 0 ));
const atomics::memory_order oLoad = convert_to_load_order( order );
const atomics::memory_order oStore = convert_to_store_order( order );
- EXPECT_TRUE( a.is_lock_free() );
+ EXPECT_TRUE( a.is_lock_free());
a.store((integral_type) 0, oStore );
EXPECT_EQ( a, integral_type( 0 ));
EXPECT_EQ( a.load( oLoad ), integral_type( 0 ));
template <class AtomicBool>
void do_test_atomic_bool( AtomicBool& a )
{
- EXPECT_TRUE( a.is_lock_free() );
+ EXPECT_TRUE( a.is_lock_free());
a.store( false );
EXPECT_FALSE( a );
EXPECT_FALSE( a.load());
EXPECT_FALSE( expected );
EXPECT_FALSE( a.compare_exchange_weak( expected, false));
EXPECT_TRUE( expected );
- EXPECT_TRUE( a.load() );
+ EXPECT_TRUE( a.load());
a.store( false );
const atomics::memory_order oStore = convert_to_store_order( order );
const atomics::memory_order oExchange = convert_to_exchange_order( order );
- EXPECT_TRUE( a.is_lock_free() );
+ EXPECT_TRUE( a.is_lock_free());
a.store( false, oStore );
EXPECT_FALSE( a );
EXPECT_FALSE( a.load( oLoad ));
EXPECT_EQ( *reinterpret_cast<char *>(a.load()), 1 );
p = arr;
- EXPECT_TRUE( a.compare_exchange_weak( p, (void *)(arr + 5) ));
+ EXPECT_TRUE( a.compare_exchange_weak( p, (void *)(arr + 5)));
EXPECT_EQ( p, arr + 0 );
- EXPECT_FALSE( a.compare_exchange_weak( p, (void *)(arr + 3) ));
+ EXPECT_FALSE( a.compare_exchange_weak( p, (void *)(arr + 3)));
EXPECT_EQ( p, arr + 5 );
- EXPECT_TRUE( a.compare_exchange_strong( p, (void *)(arr + 3) ));
+ EXPECT_TRUE( a.compare_exchange_strong( p, (void *)(arr + 3)));
EXPECT_EQ( p, arr + 5 );
- EXPECT_FALSE( a.compare_exchange_strong( p, (void *)(arr + 5) ));
+ EXPECT_FALSE( a.compare_exchange_strong( p, (void *)(arr + 5)));
EXPECT_EQ( p, arr + 3 );
EXPECT_EQ( reinterpret_cast<char *>( a.exchange( (void *) arr )), arr + 3 );
{
atomics::memory_order mo_clear = convert_to_store_order(order);
- f.clear( convert_to_store_order(order) );
+ f.clear( convert_to_store_order(order));
for ( int i = 0; i < 5; ++i ) {
EXPECT_FALSE( atomics::atomic_flag_test_and_set_explicit( &f, order ));
- EXPECT_TRUE( atomics::atomic_flag_test_and_set_explicit( &f, order ) );
+ EXPECT_TRUE( atomics::atomic_flag_test_and_set_explicit( &f, order ));
atomics::atomic_flag_clear_explicit( &f, mo_clear );
atomics::atomic_flag_clear_explicit( &f, mo_clear );
}
for ( int i = 0; i < 5; ++i ) {
EXPECT_FALSE( atomics::atomic_flag_test_and_set( &f ));
- EXPECT_TRUE( atomics::atomic_flag_test_and_set( &f ) );
+ EXPECT_TRUE( atomics::atomic_flag_test_and_set( &f ));
atomics::atomic_flag_clear(&f);
atomics::atomic_flag_clear(&f);
}
{
typedef Integral integral_type;
- EXPECT_TRUE( atomics::atomic_is_lock_free( &a ) );
+ EXPECT_TRUE( atomics::atomic_is_lock_free( &a ));
atomics::atomic_store( &a, (integral_type) 0 );
EXPECT_EQ( a, integral_type( 0 ));
EXPECT_EQ( atomics::atomic_load( &a ), integral_type( 0 ));
EXPECT_TRUE( atomics::atomic_compare_exchange_weak( &a, &expected, n));
EXPECT_EQ( expected, prev );
EXPECT_NE( expected, n );
- EXPECT_FALSE( atomics::atomic_compare_exchange_weak( &a, &expected, n) );
+ EXPECT_FALSE( atomics::atomic_compare_exchange_weak( &a, &expected, n));
EXPECT_EQ( expected, n );
prev = n;
const atomics::memory_order oLoad = convert_to_load_order( order );
const atomics::memory_order oStore = convert_to_store_order( order );
- EXPECT_TRUE( atomics::atomic_is_lock_free( &a ) );
+ EXPECT_TRUE( atomics::atomic_is_lock_free( &a ));
atomics::atomic_store_explicit( &a, (integral_type) 0, oStore );
EXPECT_EQ( a, integral_type( 0 ));
EXPECT_EQ( atomics::atomic_load_explicit( &a, oLoad ), (integral_type) 0 );
template <class AtomicBool>
void do_test_atomic_bool(AtomicBool& a)
{
- EXPECT_TRUE( atomics::atomic_is_lock_free( &a ) );
+ EXPECT_TRUE( atomics::atomic_is_lock_free( &a ));
atomics::atomic_store( &a, false );
EXPECT_FALSE( a );
EXPECT_FALSE( atomics::atomic_load( &a ));
const atomics::memory_order oStore = convert_to_store_order( order );
const atomics::memory_order oExchange = convert_to_exchange_order( order );
- EXPECT_TRUE( atomics::atomic_is_lock_free( &a ) );
+ EXPECT_TRUE( atomics::atomic_is_lock_free( &a ));
atomics::atomic_store_explicit( &a, false, oStore );
EXPECT_FALSE( a == false );
EXPECT_FALSE( atomics::atomic_load_explicit( &a, oLoad ));
EXPECT_EQ( *reinterpret_cast<char *>(atomics::atomic_load( &a )), 1 );
p = arr;
- EXPECT_TRUE( atomics::atomic_compare_exchange_weak( &a, (void **) &p, (void *)(arr + 5) ));
+ EXPECT_TRUE( atomics::atomic_compare_exchange_weak( &a, (void **) &p, (void *)(arr + 5)));
EXPECT_EQ( p, arr + 0 );
- EXPECT_FALSE( atomics::atomic_compare_exchange_weak( &a, (void **) &p, (void *)(arr + 3) ));
+ EXPECT_FALSE( atomics::atomic_compare_exchange_weak( &a, (void **) &p, (void *)(arr + 3)));
EXPECT_EQ( p, arr + 5 );
- EXPECT_TRUE( atomics::atomic_compare_exchange_strong( &a, (void **) &p, (void *)(arr + 3) ));
+ EXPECT_TRUE( atomics::atomic_compare_exchange_strong( &a, (void **) &p, (void *)(arr + 3)));
EXPECT_EQ( p, arr + 5 );
- EXPECT_FALSE( atomics::atomic_compare_exchange_strong( &a, (void **) &p, (void *)(arr + 5) ));
+ EXPECT_FALSE( atomics::atomic_compare_exchange_strong( &a, (void **) &p, (void *)(arr + 5)));
EXPECT_EQ( p, arr + 3 );
EXPECT_EQ( reinterpret_cast<char *>( atomics::atomic_exchange( &a, (void *) arr )), arr + 3 );
do {
typename Gen::integer_type i = gen;
++arr[ i ];
- } while ( gen.next() );
+ } while ( gen.next());
for ( size_t i = 0; i < nLen; ++i )
EXPECT_EQ( arr[i], 1u ) << "i=" << i;
size_t res;
// Trivial case
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = splitter.cut(sizeof(src) * 8);
EXPECT_EQ( res, src );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ(splitter.safe_cut(sizeof(src) * 8), 0u );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
splitter.reset();
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = splitter.cut(sizeof(src) * 8);
EXPECT_EQ( res, src );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( splitter.safe_cut(sizeof(src) * 8), 0u );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
// Cut each hex digit
splitter.reset();
for ( size_t i = 0; i < sizeof(size_t) * 2; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
ASSERT_EQ( splitter.cut( 4 ), i );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_FALSE( splitter );
// by one bit
splitter.reset();
res = 0;
for ( size_t i = 0; i < sizeof(size_t) * 8; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = res + (splitter.cut( 1 ) << i);
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
res = 0;
size_t shift = 0;
while ( splitter ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
int bits = std::rand() % 16;
res = res + ( splitter.safe_cut( bits ) << shift );
shift += bits;
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
size_t res;
// Trivial case
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = splitter.cut(sizeof(src) * 8);
ASSERT_EQ( res, src );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ(splitter.safe_cut(sizeof(src) * 8), 0u );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
splitter.reset();
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = splitter.cut(sizeof(src) * 8);
EXPECT_EQ( res, src );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ(splitter.safe_cut(sizeof(src) * 8), 0u );
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
// Cut each hex digit
splitter.reset();
for ( size_t i = 0; i < sizeof(size_t) * 2; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
EXPECT_EQ( splitter.cut( 4 ), 0x0F - i );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
// by one bit
splitter.reset();
res = 0;
for ( size_t i = 0; i < sizeof(size_t) * 8; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = (res << 1) + splitter.cut( 1 );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
splitter.reset();
res = 0;
while ( splitter ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
int bits = std::rand() % 16;
res = (res << bits) + splitter.safe_cut( bits );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
// Cut each hex digit
splitter.reset();
for ( size_t i = 0; i < sizeof(size_t) * 2; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
EXPECT_EQ( static_cast<size_t>(splitter.cut( 4 )), i );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
// by one bit
splitter.reset();
res = 0;
for ( size_t i = 0; i < sizeof(size_t) * 8; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = res + ( static_cast<uint64_t>(splitter.cut( 1 )) << i);
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
res = 0;
size_t shift = 0;
while ( splitter ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
int bits = std::rand() % 16;
res = res + ( static_cast<uint64_t>(splitter.safe_cut( bits )) << shift );
shift += bits;
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
// Cut each hex digit
splitter.reset();
for ( size_t i = 0; i < sizeof(size_t) * 2; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
EXPECT_EQ( splitter.cut( 4 ), 0x0F - i );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
// by one bit
splitter.reset();
res = 0;
for ( size_t i = 0; i < sizeof(size_t) * 8; ++i ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
res = (res << 1) + splitter.cut( 1 );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
splitter.reset();
res = 0;
while ( splitter ) {
- ASSERT_FALSE( splitter.eos() );
+ ASSERT_FALSE( splitter.eos());
ASSERT_FALSE( !splitter );
int bits = std::rand() % 16;
res = (res << bits) + splitter.safe_cut( bits );
}
- ASSERT_TRUE( splitter.eos() );
+ ASSERT_TRUE( splitter.eos());
ASSERT_TRUE( !splitter );
EXPECT_EQ( res, src );
}
TEST_F( Split_bitstrig, cut_uint )
{
- if ( is_big_endian() )
+ if ( is_big_endian())
cut_uint_be();
else
cut_uint_le();
TEST_F( Split_bitstrig, cut_uint16 )
{
- if ( is_big_endian() )
+ if ( is_big_endian())
cut_small_be<uint16_t>();
else
cut_small_le<uint16_t>();
template <class PQueue>
void test( PQueue& pq )
{
- data_array<value_type> arr( pq.capacity() );
+ data_array<value_type> arr( pq.capacity());
value_type * pFirst = arr.begin();
value_type * pLast = arr.end();
- ASSERT_TRUE( pq.empty() );
- ASSERT_FALSE( pq.full() );
+ ASSERT_TRUE( pq.empty());
+ ASSERT_FALSE( pq.full());
ASSERT_EQ( pq.size(), 0u );
ASSERT_EQ( pq.capacity(), static_cast<size_t>( base_class::c_nCapacity - 1 ));
// Push test
for ( value_type * p = pFirst; p < pLast; ++p ) {
- ASSERT_TRUE( pq.push( *p ) );
- ASSERT_FALSE( pq.empty() );
+ ASSERT_TRUE( pq.push( *p ));
+ ASSERT_FALSE( pq.empty());
ASSERT_EQ( pq.size(), ++nSize );
}
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
// The queue is full
{
value_type k( base_class::c_nMinValue + key_type( base_class::c_nCapacity ));
- ASSERT_FALSE( pq.push( k ) );
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_FALSE( pq.push( k ));
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
}
// Pop test
- key_type nPrev = base_class::c_nMinValue + key_type( pq.capacity() ) - 1;
+ key_type nPrev = base_class::c_nMinValue + key_type( pq.capacity()) - 1;
value_type * p = pq.pop();
ASSERT_TRUE( p != nullptr );
EXPECT_EQ( p->k, nPrev );
ASSERT_EQ( pq.size(), pq.capacity() - 1 );
- ASSERT_FALSE( pq.full() );
- ASSERT_FALSE( pq.empty() );
+ ASSERT_FALSE( pq.full());
+ ASSERT_FALSE( pq.empty());
nSize = pq.size();
while ( pq.size() > 1u ) {
ASSERT_EQ( pq.size(), nSize );
}
- ASSERT_FALSE( pq.full() );
- ASSERT_FALSE( pq.empty() );
+ ASSERT_FALSE( pq.full());
+ ASSERT_FALSE( pq.empty());
ASSERT_EQ( pq.size(), 1u );
p = pq.pop();
ASSERT_TRUE( p != nullptr );
EXPECT_EQ( p->k, base_class::c_nMinValue );
- ASSERT_FALSE( pq.full() );
- ASSERT_TRUE( pq.empty() );
+ ASSERT_FALSE( pq.full());
+ ASSERT_TRUE( pq.empty());
ASSERT_EQ( pq.size(), 0u );
// Clear test
for ( value_type * p = pFirst; p < pLast; ++p ) {
- ASSERT_TRUE( pq.push( *p ) );
+ ASSERT_TRUE( pq.push( *p ));
}
- EXPECT_FALSE( pq.empty() );
- EXPECT_TRUE( pq.full() );
- EXPECT_EQ( pq.size(), pq.capacity() );
+ EXPECT_FALSE( pq.empty());
+ EXPECT_TRUE( pq.full());
+ EXPECT_EQ( pq.size(), pq.capacity());
pq.clear();
- EXPECT_TRUE( pq.empty() );
- EXPECT_FALSE( pq.full() );
+ EXPECT_TRUE( pq.empty());
+ EXPECT_FALSE( pq.full());
EXPECT_EQ( pq.size(), 0u );
// clear_with test
for ( value_type * p = pFirst; p < pLast; ++p ) {
- ASSERT_TRUE( pq.push( *p ) );
+ ASSERT_TRUE( pq.push( *p ));
}
- ASSERT_FALSE( pq.empty() );
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_FALSE( pq.empty());
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
{
disposer disp;
- pq.clear_with( std::ref( disp ) );
- ASSERT_TRUE( pq.empty() );
- ASSERT_FALSE( pq.full() );
+ pq.clear_with( std::ref( disp ));
+ ASSERT_TRUE( pq.empty());
+ ASSERT_FALSE( pq.full());
ASSERT_EQ( pq.size(), 0u );
- ASSERT_EQ( disp.m_nCallCount, pq.capacity() );
+ ASSERT_EQ( disp.m_nCallCount, pq.capacity());
}
}
};
>::type
> pqueue;
- std::unique_ptr<pqueue> pq( new pqueue( 0 ) );
+ std::unique_ptr<pqueue> pq( new pqueue( 0 ));
test( *pq );
}
>::type
> pqueue;
- std::unique_ptr<pqueue> pq( new pqueue( 0 ) );
+ std::unique_ptr<pqueue> pq( new pqueue( 0 ));
test( *pq );
}
};
typedef cds::intrusive::MSPriorityQueue< value_type, traits > pqueue;
- std::unique_ptr<pqueue> pq( new pqueue( 0 ) );
+ std::unique_ptr<pqueue> pq( new pqueue( 0 ));
test( *pq );
}
template <class PQueue>
void test( PQueue& pq )
{
- data_array<value_type> arr( pq.capacity() );
+ data_array<value_type> arr( pq.capacity());
value_type * pFirst = arr.begin();
value_type * pLast = pFirst + pq.capacity();
- ASSERT_TRUE( pq.empty() );
+ ASSERT_TRUE( pq.empty());
ASSERT_EQ( pq.size(), 0u );
ASSERT_EQ( pq.capacity(), size_t( base_class::c_nCapacity - 1 ));
for ( value_type * p = pFirst; p < pLast; ++p ) {
switch ( pq.size() & 3 ) {
case 0:
- ASSERT_TRUE( pq.push_with( [p]( value_type& dest ) { dest = *p; } ) );
+ ASSERT_TRUE( pq.push_with( [p]( value_type& dest ) { dest = *p; } ));
break;
case 1:
- ASSERT_TRUE( pq.emplace( p->k, p->v ) );
+ ASSERT_TRUE( pq.emplace( p->k, p->v ));
break;
case 2:
- ASSERT_TRUE( pq.emplace( std::make_pair( p->k, p->v ) ) );
+ ASSERT_TRUE( pq.emplace( std::make_pair( p->k, p->v )) );
break;
default:
- ASSERT_TRUE( pq.push( *p ) );
+ ASSERT_TRUE( pq.push( *p ));
}
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( !pq.empty());
ASSERT_TRUE( pq.size() == ++nSize );
}
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
// The queue is full
key_type k = base_class::c_nMinValue + key_type( base_class::c_nCapacity );
- ASSERT_TRUE( !pq.push( k ) );
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_TRUE( !pq.push( k ));
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
// Pop test
- key_type nPrev = base_class::c_nMinValue + key_type( pq.capacity() ) - 1;
+ key_type nPrev = base_class::c_nMinValue + key_type( pq.capacity()) - 1;
value_type kv( 0 );
key_type key;
- ASSERT_TRUE( pq.pop( kv ) );
+ ASSERT_TRUE( pq.pop( kv ));
EXPECT_EQ( kv.k, nPrev );
ASSERT_EQ( pq.size(), pq.capacity() - 1 );
- ASSERT_TRUE( !pq.full() );
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( !pq.full());
+ ASSERT_TRUE( !pq.empty());
nSize = pq.size();
while ( pq.size() > 1 ) {
if ( pq.size() & 1 ) {
- ASSERT_TRUE( pq.pop( kv ) );
+ ASSERT_TRUE( pq.pop( kv ));
EXPECT_EQ( kv.k, nPrev - 1 );
nPrev = kv.k;
}
else {
- ASSERT_TRUE( pq.pop_with( [&key]( value_type& src ) { key = src.k; } ) );
+ ASSERT_TRUE( pq.pop_with( [&key]( value_type& src ) { key = src.k; } ));
EXPECT_EQ( key, nPrev - 1 );
nPrev = key;
}
ASSERT_EQ( pq.size(), nSize );
}
- ASSERT_TRUE( !pq.full() );
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( !pq.full());
+ ASSERT_TRUE( !pq.empty());
ASSERT_EQ( pq.size(), 1u );
- ASSERT_TRUE( pq.pop( kv ) );
+ ASSERT_TRUE( pq.pop( kv ));
EXPECT_EQ( kv.k, base_class::c_nMinValue );
- ASSERT_TRUE( !pq.full() );
- ASSERT_TRUE( pq.empty() );
+ ASSERT_TRUE( !pq.full());
+ ASSERT_TRUE( pq.empty());
ASSERT_EQ( pq.size(), 0u );
// Clear test
for ( value_type * p = pFirst; p < pLast; ++p ) {
- ASSERT_TRUE( pq.push( *p ) );
+ ASSERT_TRUE( pq.push( *p ));
}
- ASSERT_TRUE( !pq.empty() );
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_TRUE( !pq.empty());
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
pq.clear();
- ASSERT_TRUE( pq.empty() );
- ASSERT_TRUE( !pq.full() );
+ ASSERT_TRUE( pq.empty());
+ ASSERT_TRUE( !pq.full());
ASSERT_EQ( pq.size(), 0u );
// clear_with test
for ( value_type * p = pFirst; p < pLast; ++p ) {
- ASSERT_TRUE( pq.push( *p ) );
+ ASSERT_TRUE( pq.push( *p ));
}
- ASSERT_TRUE( !pq.empty() );
- ASSERT_TRUE( pq.full() );
- ASSERT_EQ( pq.size(), pq.capacity() );
+ ASSERT_TRUE( !pq.empty());
+ ASSERT_TRUE( pq.full());
+ ASSERT_EQ( pq.size(), pq.capacity());
{
disposer disp;
- pq.clear_with( std::ref( disp ) );
- ASSERT_TRUE( pq.empty() );
- ASSERT_TRUE( !pq.full() );
+ pq.clear_with( std::ref( disp ));
+ ASSERT_TRUE( pq.empty());
+ ASSERT_TRUE( !pq.full());
ASSERT_EQ( pq.size(), 0u );
- ASSERT_EQ( disp.m_nCallCount, pq.capacity() );
+ ASSERT_EQ( disp.m_nCallCount, pq.capacity());
}
}
};
value_type * pFirst = arr.begin();
value_type * pLast = arr.end();
- ASSERT_TRUE( pq.empty() );
+ ASSERT_TRUE( pq.empty());
ASSERT_TRUE( pq.size() == 0 );
size_t nSize = 0;
// Push test
for ( value_type * p = pFirst; p < pLast; ++p ) {
- ASSERT_TRUE( pq.push( *p ) );
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( pq.push( *p ));
+ ASSERT_TRUE( !pq.empty());
ASSERT_EQ( pq.size(), ++nSize );
}
key_type nPrev = PQueueTest::c_nMinValue + key_type( PQueueTest::c_nCapacity ) - 1;
value_type kv( 0 );
- ASSERT_TRUE( pq.pop( kv ) );
+ ASSERT_TRUE( pq.pop( kv ));
EXPECT_EQ( kv.k, nPrev );
ASSERT_EQ( pq.size(), static_cast<size_t>( PQueueTest::c_nCapacity - 1 ));
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( !pq.empty());
nSize = pq.size();
while ( pq.size() > 1 ) {
- ASSERT_TRUE( pq.pop( kv ) );
+ ASSERT_TRUE( pq.pop( kv ));
EXPECT_EQ( kv.k, nPrev - 1 );
nPrev = kv.k;
ASSERT_EQ( pq.size(), nSize );
}
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( !pq.empty());
ASSERT_EQ( pq.size(), 1u );
- ASSERT_TRUE( pq.pop( kv ) );
+ ASSERT_TRUE( pq.pop( kv ));
EXPECT_EQ( kv.k, PQueueTest::c_nMinValue );
- ASSERT_TRUE( pq.empty() );
+ ASSERT_TRUE( pq.empty());
ASSERT_EQ( pq.size(), 0u );
// pop from empty pqueue
// Clear test
for ( value_type * p = pFirst; p < pLast; ++p )
- ASSERT_TRUE( pq.push( *p ) );
+ ASSERT_TRUE( pq.push( *p ));
- ASSERT_TRUE( !pq.empty() );
+ ASSERT_TRUE( !pq.empty());
ASSERT_EQ( pq.size(), static_cast<size_t>( PQueueTest::c_nCapacity ));
pq.clear();
- ASSERT_TRUE( pq.empty() );
+ ASSERT_TRUE( pq.empty());
ASSERT_EQ( pq.size(), 0u );
}
};
const size_t nSize = 100;
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// enqueue/dequeue
ASSERT_TRUE( q.enqueue( static_cast<value_type>(i)));
ASSERT_EQ( q.size(), i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), nSize );
for ( size_t i = 0; i < nSize; ++i ) {
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_EQ( q.size(), nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// push/pop
ASSERT_TRUE( q.push( static_cast<value_type>(i)));
ASSERT_EQ( q.size(), i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), nSize );
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.pop( it ) );
+ ASSERT_TRUE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_EQ( q.size(), nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// clear
for ( size_t i = 0; i < nSize; ++i ) {
ASSERT_TRUE( q.push( static_cast<value_type>( i )));
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), nSize );
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// pop from empty queue
it = nSize * 2;
ASSERT_FALSE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
- ASSERT_FALSE( q.dequeue( it ) );
+ ASSERT_FALSE( q.dequeue( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
}
ASSERT_FALSE( s.empty());
ASSERT_EQ( q.size(), i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), nSize );
for ( size_t i = 0; i < nSize; ++i ) {
ASSERT_EQ( q.size(), nSize - i - 1 );
ASSERT_EQ( s, str[i] );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
}
};
for ( size_t i = 0; i < nSize; ++i )
arr[i].nVal = static_cast<int>(i);
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// pop from empty queue
pv = q.pop();
ASSERT_TRUE( pv == nullptr );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
pv = q.dequeue();
ASSERT_TRUE( pv == nullptr );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// push/pop test
q.push( arr[i] );
else
q.enqueue( arr[i] );
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), i + 1 );
}
for ( size_t i = 0; i < nSize; ++i ) {
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), nSize - i );
if ( i & 1 )
pv = q.pop();
else
pv = q.dequeue();
ASSERT_FALSE( pv == nullptr );
- ASSERT_EQ( pv->nVal, static_cast<int>(i) );
+ ASSERT_EQ( pv->nVal, static_cast<int>(i));
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
// pop() doesn't call disposer
for ( size_t i = 0; i < nSize; ++i )
q.push( arr[i] );
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_EQ( q.size(), nSize );
q.clear( true );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
for ( size_t i = 0; i < nSize; ++i ) {
q.push( arr[i] );
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_EQ( q.size(), 0u );
for ( size_t i = 0; i < nSize; ++i ) {
typedef cds::container::SegmentedQueue< gc_type, int, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test( q );
}
typedef cds::container::SegmentedQueue< gc_type, int, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test( q );
}
typedef cds::container::SegmentedQueue< gc_type, int, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test( q );
}
typedef cds::container::SegmentedQueue< gc_type, std::string > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test_string( q );
}
typedef cds::container::SegmentedQueue< gc_type, std::string, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test_string( q );
}
typedef cds::container::SegmentedQueue< cds::gc::HP, int, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test( q );
}
typedef cds::container::SegmentedQueue< cds::gc::HP, int, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test( q );
}
typedef cds::container::SegmentedQueue< cds::gc::HP, int, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test( q );
}
typedef cds::container::SegmentedQueue< gc_type, std::string > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test_string( q );
}
typedef cds::container::SegmentedQueue< gc_type, std::string, traits > test_queue;
test_queue q( c_QuasiFactor );
- ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ) );
+ ASSERT_EQ( q.quasi_factor(), cds::beans::ceil2( c_QuasiFactor ));
test_string( q );
}
const size_t nSize = q.capacity();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// enqueue/dequeue
ASSERT_TRUE( q.enqueue( it ));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.dequeue( it ) );
+ ASSERT_TRUE( q.dequeue( it ));
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop
ASSERT_TRUE( q.push( it ));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.pop( it ) );
+ ASSERT_TRUE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop with lambda
ASSERT_EQ( it, -1 );
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0u );
for ( size_t i = 0; i < nSize; ++i ) {
- ASSERT_TRUE( q.push( static_cast<value_type>(i) ) );
+ ASSERT_TRUE( q.push( static_cast<value_type>(i)) );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
// push in full queue
ASSERT_FALSE( q.push( static_cast<int>(nSize * 2 )));
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
it = static_cast<int>( nSize * 2 );
ASSERT_FALSE( q.enqueue( it ));
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
// clear
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0u );
// pop from empty queue
it = static_cast<int>(nSize * 2);
- ASSERT_FALSE( q.pop( it ) );
+ ASSERT_FALSE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0u );
- ASSERT_FALSE( q.dequeue( it ) );
+ ASSERT_FALSE( q.dequeue( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0u );
}
ASSERT_TRUE( q.emplace( str[i].c_str()));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
{
std::string s;
auto f = [&s]( std::string& src ) {
- ASSERT_FALSE( src.empty() );
+ ASSERT_FALSE( src.empty());
s = std::move( src );
ASSERT_NE( s, src );
};
ASSERT_EQ( s, str[i] );
}
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
ASSERT_TRUE( q.enqueue( std::move( s )));
else
ASSERT_TRUE( q.push( std::move( s )));
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
std::string s;
- ASSERT_TRUE( q.pop( s ) );
+ ASSERT_TRUE( q.pop( s ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
ASSERT_EQ( s, str[i] );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
}
const size_t nSize = 100;
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// enqueue/dequeue
ASSERT_TRUE( q.enqueue( it ));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.dequeue( it ) );
+ ASSERT_TRUE( q.dequeue( it ));
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop
ASSERT_TRUE( q.push( it ));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.pop( it ) );
+ ASSERT_TRUE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop with lambda
ASSERT_EQ( it, -1 );
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
ASSERT_EQ( it, static_cast<value_type>( i ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// clear
for ( size_t i = 0; i < nSize; ++i ) {
- ASSERT_TRUE( q.push( static_cast<value_type>(i) ) );
+ ASSERT_TRUE( q.push( static_cast<value_type>(i)) );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// pop from empty queue
it = nSize * 2;
- ASSERT_FALSE( q.pop( it ) );
+ ASSERT_FALSE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
- ASSERT_FALSE( q.dequeue( it ) );
+ ASSERT_FALSE( q.dequeue( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
}
ASSERT_TRUE( q.emplace( str[i].c_str()));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
{
std::string s;
auto f = [&s]( std::string& src ) {
- ASSERT_FALSE( src.empty() );
+ ASSERT_FALSE( src.empty());
s = std::move( src );
ASSERT_NE( s, src );
};
ASSERT_EQ( s, str[i] );
}
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// move push
for ( size_t i = 0; i < nSize; ++i ) {
std::string s = str[i];
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
if ( i & 1 )
ASSERT_TRUE( q.enqueue( std::move( s )));
else
ASSERT_TRUE( q.push( std::move( s )));
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
std::string s;
- ASSERT_TRUE( q.pop( s ) );
+ ASSERT_TRUE( q.pop( s ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
ASSERT_EQ( s, str[i] );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
}
const size_t nSize = q.capacity();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
std::vector< value_type > arr;
ASSERT_TRUE( q.enqueue( i ));
}
ASSERT_CONTAINER_SIZE( q, i.nVal + 1 );
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
}
- ASSERT_CONTAINER_SIZE( q, q.capacity() );
+ ASSERT_CONTAINER_SIZE( q, q.capacity());
// pop
int val = 0;
- while ( !q.empty() ) {
+ while ( !q.empty()) {
value_type * v;
if ( val & 1 )
v = q.pop();
}
ASSERT_EQ( val, static_cast<int>( nSize ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// pop from empty queue
{
value_type * v = q.pop();
ASSERT_TRUE( v == nullptr );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
}
// clear
for ( auto& i : arr ) {
- ASSERT_TRUE( q.push( i ) );
+ ASSERT_TRUE( q.push( i ));
}
- ASSERT_FALSE( q.empty() );
- ASSERT_CONTAINER_SIZE( q, q.capacity() );
+ ASSERT_FALSE( q.empty());
+ ASSERT_CONTAINER_SIZE( q, q.capacity());
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
if ( std::is_same<typename Queue::disposer, cds::intrusive::opt::v::empty_disposer>::value ) {
// clear with disposer
for ( auto& i : arr ) {
- ASSERT_TRUE( q.push( i ) );
+ ASSERT_TRUE( q.push( i ));
i.nDisposeCount = 0;
}
- ASSERT_FALSE( q.empty() );
- ASSERT_CONTAINER_SIZE( q, q.capacity() );
+ ASSERT_FALSE( q.empty());
+ ASSERT_CONTAINER_SIZE( q, q.capacity());
q.clear( []( value_type * p ) { p->nDisposeCount = p->nVal + 1; } );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// check the disposer has not been called
for ( auto& i : arr ) {
for ( size_t i = 0; i < nSize; ++i )
arr[i].nVal = static_cast<int>(i);
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// pop from empty queue
pv = q.pop();
ASSERT_TRUE( pv == nullptr );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
pv =q.dequeue();
ASSERT_TRUE( pv == nullptr );
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop test
}
for ( size_t i = 0; i < nSize; ++i ) {
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize - i );
if ( i & 1 )
pv = q.pop();
ASSERT_FALSE( pv == nullptr );
ASSERT_EQ( pv->nVal, static_cast<int>(i));
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
Queue::gc::scan();
for ( size_t i = 0; i < nSize; ++i )
q.push( arr[i] );
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
Queue::gc::scan();
// push/enqueue
for ( size_t i = 0; i < val.size(); ++i ) {
if ( i & 1 ) {
- ASSERT_TRUE( q.push( val[i] ) );
+ ASSERT_TRUE( q.push( val[i] ));
}
else {
- ASSERT_TRUE( q.enqueue( val[i] ) );
+ ASSERT_TRUE( q.enqueue( val[i] ));
}
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- EXPECT_TRUE( !q.empty() );
+ EXPECT_TRUE( !q.empty());
// pop/dequeue
size_t nCount = 0;
- while ( !q.empty() ) {
+ while ( !q.empty()) {
value_type * pVal;
if ( nCount & 1 )
pVal = q.pop();
ASSERT_TRUE( pVal != nullptr );
- int nSegment = int( nCount / q.quasi_factor() );
- int nMin = nSegment * int( q.quasi_factor() );
- int nMax = nMin + int( q.quasi_factor() ) - 1;
+ int nSegment = int( nCount / q.quasi_factor());
+ int nMin = nSegment * int( q.quasi_factor());
+ int nMax = nMin + int( q.quasi_factor()) - 1;
EXPECT_TRUE( nMin <= pVal->nValue && pVal->nValue <= nMax ) << nMin << " <= " << pVal->nValue << " <= " << nMax;
++nCount;
EXPECT_CONTAINER_SIZE( q, val.size() - nCount );
}
EXPECT_EQ( nCount, val.size());
- EXPECT_TRUE( q.empty() );
+ EXPECT_TRUE( q.empty());
EXPECT_CONTAINER_SIZE( q, 0u );
// pop from empty queue
ASSERT_TRUE( q.pop() == nullptr );
- EXPECT_TRUE( q.empty() );
+ EXPECT_TRUE( q.empty());
EXPECT_CONTAINER_SIZE( q, 0u );
// check that Disposer has not been called
// clear
for ( size_t i = 0; i < val.size(); ++i )
- EXPECT_TRUE( q.push( val[i] ) );
+ EXPECT_TRUE( q.push( val[i] ));
EXPECT_CONTAINER_SIZE( q, val.size());
- EXPECT_TRUE( !q.empty() );
+ EXPECT_TRUE( !q.empty());
q.clear();
EXPECT_CONTAINER_SIZE( q, 0u );
- EXPECT_TRUE( q.empty() );
+ EXPECT_TRUE( q.empty());
// check if Disposer has been called
Queue::gc::force_dispose();
// clear_with
for ( size_t i = 0; i < val.size(); ++i )
- EXPECT_TRUE( q.push( val[i] ) );
- EXPECT_CONTAINER_SIZE( q, val.size() );
- EXPECT_TRUE( !q.empty() );
+ EXPECT_TRUE( q.push( val[i] ));
+ EXPECT_CONTAINER_SIZE( q, val.size());
+ EXPECT_TRUE( !q.empty());
- q.clear_with( Disposer2() );
+ q.clear_with( Disposer2());
EXPECT_CONTAINER_SIZE( q, 0u );
- EXPECT_TRUE( q.empty() );
+ EXPECT_TRUE( q.empty());
// check if Disposer has been called
Queue::gc::force_dispose();
const size_t nSize = 100;
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// enqueue/dequeue
ASSERT_TRUE( q.enqueue( it ));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.dequeue( it ) );
+ ASSERT_TRUE( q.dequeue( it ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
- int nSegment = int( i / q.quasi_factor() );
- int nMin = nSegment * int( q.quasi_factor() );
- int nMax = nMin + int( q.quasi_factor() ) - 1;
+ int nSegment = int( i / q.quasi_factor());
+ int nMin = nSegment * int( q.quasi_factor());
+ int nMax = nMin + int( q.quasi_factor()) - 1;
EXPECT_LE( nMin, it );
EXPECT_LE( it, nMax );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop
ASSERT_TRUE( q.push( it ));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
size_t nPushed = nSize;
size_t nOffset = nPushed % q.quasi_factor();
for ( size_t i = 0; i < nSize; ++i ) {
it = -1;
- ASSERT_TRUE( q.pop( it ) );
+ ASSERT_TRUE( q.pop( it ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
int nSegment = static_cast<int>((i + nPushed) / q.quasi_factor() - nStartSegment );
EXPECT_LE( nMin, it );
EXPECT_LE( it, nMax );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// push/pop with lambda
ASSERT_EQ( it, -1 );
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
nPushed += nSize;
EXPECT_LE( nMin, it );
EXPECT_LE( it, nMax );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// clear
for ( size_t i = 0; i < nSize; ++i ) {
- ASSERT_TRUE( q.push( static_cast<value_type>(i) ) );
+ ASSERT_TRUE( q.push( static_cast<value_type>(i)) );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
q.clear();
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// pop from empty queue
it = nSize * 2;
- ASSERT_FALSE( q.pop( it ) );
+ ASSERT_FALSE( q.pop( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
- ASSERT_FALSE( q.dequeue( it ) );
+ ASSERT_FALSE( q.dequeue( it ));
ASSERT_EQ( it, static_cast<value_type>( nSize * 2 ));
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
}
ASSERT_TRUE( q.emplace( str[i].c_str()));
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
{
std::string s;
auto f = [&s]( std::string& src ) {
- ASSERT_FALSE( src.empty() );
+ ASSERT_FALSE( src.empty());
s = std::move( src );
ASSERT_NE( s, src );
};
ASSERT_TRUE( s == str[0] || s == str[1] || s == str[2] );
}
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
// move push
for ( size_t i = 0; i < nSize; ++i ) {
std::string s = str[i];
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
if ( i & 1 )
ASSERT_TRUE( q.enqueue( std::move( s )));
else
ASSERT_TRUE( q.push( std::move( s )));
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( q, i + 1 );
}
- ASSERT_FALSE( q.empty() );
+ ASSERT_FALSE( q.empty());
ASSERT_CONTAINER_SIZE( q, nSize );
for ( size_t i = 0; i < nSize; ++i ) {
std::string s;
- ASSERT_TRUE( q.pop( s ) );
+ ASSERT_TRUE( q.pop( s ));
ASSERT_CONTAINER_SIZE( q, nSize - i - 1 );
ASSERT_TRUE( s == str[0] || s == str[1] || s == str[2] );
}
- ASSERT_TRUE( q.empty() );
+ ASSERT_TRUE( q.empty());
ASSERT_CONTAINER_SIZE( q, 0 );
}
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Q>
explicit int_item( Q const& src )
- : nKey( src.key() )
+ : nKey( src.key())
, nVal( 0 )
{}
int_item( int_item&& src )
: nKey( src.nKey )
, nVal( src.nVal )
- , strVal( std::move( src.strVal ) )
+ , strVal( std::move( src.strVal ))
{}
int_item( int k, std::string&& s )
: nKey( k )
, nVal( k * 2 )
- , strVal( std::move( s ) )
+ , strVal( std::move( s ))
{}
explicit int_item( other_item const& s )
- : nKey( s.key() )
+ : nKey( s.key())
, nVal( s.key() * 2 )
{}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_FALSE( s.contains( i.nKey ) );
+ ASSERT_FALSE( s.contains( i.nKey ));
ASSERT_FALSE( s.find( i.nKey, []( value_type& ) {} ));
std::pair<bool, bool> updResult;
updResult = s.update( i, []( value_type& val, value_type * prev )
{
ASSERT_TRUE( prev != nullptr );
- EXPECT_EQ( val.key(), prev->key() );
+ EXPECT_EQ( val.key(), prev->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- ASSERT_TRUE( s.insert( i.key() ));
- ASSERT_FALSE( s.insert( i.key() ));
+ ASSERT_TRUE( s.insert( i.key()));
+ ASSERT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( value_type& val, value_type * prev )
{
ASSERT_TRUE( prev != nullptr );
- EXPECT_EQ( val.key(), prev->key() );
+ EXPECT_EQ( val.key(), prev->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
{
ASSERT_TRUE( prev != nullptr );
EXPECT_EQ( prev->nUpdateNewCount, 1u );
- EXPECT_EQ( v.key(), prev->key() );
+ EXPECT_EQ( v.key(), prev->key());
++v.nUpdateCount;
}, false );
EXPECT_TRUE( updResult.first );
updResult = s.update( i.key(), []( value_type& v, value_type * prev )
{
ASSERT_TRUE( prev != nullptr );
- EXPECT_EQ( v.key(), prev->key() );
+ EXPECT_EQ( v.key(), prev->key());
EXPECT_EQ( prev->nUpdateNewCount, 1u );
EXPECT_EQ( v.nUpdateNewCount, 0u );
++v.nUpdateNewCount;
ASSERT_TRUE( s.find( i.key(), []( value_type const& v )
{
EXPECT_EQ( v.nUpdateNewCount, 1u );
- } ) );
+ } ));
break;
case 6:
- ASSERT_TRUE( s.emplace( i.key() ) );
- ASSERT_TRUE( s.contains( i.key() ) );
+ ASSERT_TRUE( s.emplace( i.key()) );
+ ASSERT_TRUE( s.contains( i.key()) );
break;
case 7:
str = "Hello!";
- ASSERT_TRUE( s.emplace( i.key(), std::move( str ) ) );
- EXPECT_TRUE( str.empty() );
+ ASSERT_TRUE( s.emplace( i.key(), std::move( str )) );
+ EXPECT_TRUE( str.empty());
ASSERT_TRUE( s.find( i.key(), []( value_type const& v )
{
- EXPECT_EQ( v.strVal, std::string( "Hello!" ) );
- } ) );
+ EXPECT_EQ( v.strVal, std::string( "Hello!" ));
+ } ));
break;
default:
// forgot anything?..
ASSERT_TRUE( false );
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.find( i.nKey, []( value_type& ) {} ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.find( i.nKey, []( value_type& ) {} ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_TRUE( s.contains( i.nKey ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
ASSERT_TRUE( s.find( i.nKey, []( value_type& v )
{
v.nFindCount = 1;
- } ) );
+ } ));
int nKey = i.key() - 1;
switch ( idx % 2 ) {
case 0:
- ASSERT_TRUE( s.erase( i.key() ) );
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_TRUE( s.erase( i.key()) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 1:
ASSERT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
{
EXPECT_EQ( v.nFindCount, 1u );
nKey = v.key();
- } ) );
+ } ));
EXPECT_EQ( i.key(), nKey );
nKey = i.key() - 1;
ASSERT_FALSE( s.erase( i.key(), [&nKey]( value_type const& v )
{
nKey = v.key();
- } ) );
+ } ));
EXPECT_EQ( i.key(), nKey + 1 );
break;
}
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.find( i.nKey, []( value_type const& ) {} ) );
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.find( i.nKey, []( value_type const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
{
std::vector< typename Set::level_statistics > lstat;
s.get_level_statistics( lstat );
- EXPECT_EQ( lstat[0].node_capacity, s.head_size() );
+ EXPECT_EQ( lstat[0].node_capacity, s.head_size());
for ( size_t i = 1; i < lstat.size(); ++i ) {
EXPECT_EQ( lstat[i].node_capacity, s.array_node_size());
}
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
- ASSERT_TRUE( s.rbegin() == s.rend() );
- ASSERT_TRUE( s.crbegin() == s.crend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
+ ASSERT_TRUE( s.rbegin() == s.rend());
+ ASSERT_TRUE( s.crbegin() == s.crend());
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// iterator test
gp = s.get( i.key());
ASSERT_FALSE( !gp );
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 2 ));
gp->nFindCount *= 2;
auto& i = data[idx];
ASSERT_TRUE( !gp );
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_FALSE( !gp );
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 4 ));
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_TRUE( !gp );
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// erase_at()
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
for ( auto it = s.begin(); it != s.end(); ++it ) {
int key = it->key();
ASSERT_TRUE( s.erase_at( it ));
EXPECT_EQ( it->key(), key );
- ASSERT_FALSE( s.erase_at( it ) );
+ ASSERT_FALSE( s.erase_at( it ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
typedef typename Set::rcu_lock rcu_lock;
rcu_lock l;
value_type * p = s.get( i.key());
ASSERT_TRUE( p != nullptr );
- EXPECT_EQ( p->key(), i.key() );
+ EXPECT_EQ( p->key(), i.key());
EXPECT_EQ( p->nFindCount, static_cast<size_t>( i.key() * 2 ));
p->nFindCount *= 2;
}
auto& i = data[idx];
ASSERT_TRUE( !xp );
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_FALSE( !xp );
- EXPECT_EQ( xp->key(), i.key() );
+ EXPECT_EQ( xp->key(), i.key());
EXPECT_EQ( xp->nFindCount, static_cast<size_t>( i.key() * 4 ));
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_TRUE( !xp );
{
rcu_lock l;
- value_type * p = s.get( i.key() );
+ value_type * p = s.get( i.key());
EXPECT_TRUE( p == nullptr );
}
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
// Precondition: set is empty
// Postcondition: set is empty
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- EXPECT_FALSE( s.contains( i.nKey ) );
- EXPECT_FALSE( s.contains( i ) );
- EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ EXPECT_FALSE( s.contains( i.nKey ));
+ EXPECT_FALSE( s.contains( i ));
+ EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
EXPECT_TRUE( s.find( i ) == s.end());
- EXPECT_TRUE( s.find( i.nKey ) == s.end() );
- EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end() );
+ EXPECT_TRUE( s.find( i.nKey ) == s.end());
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
std::pair<bool, bool> updResult;
updResult = s.update( i, []( value_type& val, value_type* old)
{
ASSERT_FALSE( old == nullptr );
- EXPECT_EQ( val.key(), old->key() );
+ EXPECT_EQ( val.key(), old->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- EXPECT_TRUE( s.insert( i.key() ));
- EXPECT_FALSE( s.insert( i.key() ));
+ EXPECT_TRUE( s.insert( i.key()));
+ EXPECT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( value_type& val, value_type* old)
{
ASSERT_FALSE( old == nullptr );
- EXPECT_EQ( val.key(), old->key() );
+ EXPECT_EQ( val.key(), old->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
updResult = s.update( i, [&i]( value_type& v, value_type* old )
{
EXPECT_TRUE( old == nullptr );
- EXPECT_EQ( v.key(), i.key() );
+ EXPECT_EQ( v.key(), i.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i, []( value_type& v, value_type* old )
{
ASSERT_FALSE( old == nullptr );
- EXPECT_EQ( v.key(), old->key() );
+ EXPECT_EQ( v.key(), old->key());
EXPECT_EQ( old->nUpdateNewCount, 1u );
v.nUpdateNewCount = old->nUpdateNewCount;
++v.nUpdateCount;
updResult = s.update( i.key(), [&i]( value_type& v, value_type* old )
{
EXPECT_TRUE( old == nullptr );
- EXPECT_EQ( v.key(), i.key() );
+ EXPECT_EQ( v.key(), i.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i.key(), []( value_type& v, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( v.key(), old->key() );
+ EXPECT_EQ( v.key(), old->key());
EXPECT_EQ( old->nUpdateNewCount, 1u );
v.nUpdateNewCount = old->nUpdateNewCount;
++v.nUpdateCount;
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 1u );
EXPECT_EQ( v.nUpdateCount, 1u );
}));
EXPECT_TRUE( s.emplace( i.key()));
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
}));
break;
EXPECT_TRUE( str.empty());
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
EXPECT_EQ( v.strVal, std::string( "Hello!" ));
} ));
break;
case 8:
str = "Hello!";
- EXPECT_TRUE( s.insert( value_type( i.key(), std::move( str ))) );
- EXPECT_TRUE( str.empty() );
+ EXPECT_TRUE( s.insert( value_type( i.key(), std::move( str ))));
+ EXPECT_TRUE( str.empty());
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
- EXPECT_EQ( v.strVal, std::string( "Hello!" ) );
- } ) );
+ EXPECT_EQ( v.strVal, std::string( "Hello!" ));
+ } ));
break;
case 9:
updResult = s.upsert( i.key(), false );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
- } ) );
+ EXPECT_EQ( v.key(), arg.key());
+ } ));
break;
case 10:
updResult = s.upsert( i, false );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
- } ) );
+ EXPECT_EQ( v.key(), arg.key());
+ } ));
break;
default:
// forgot anything?..
EXPECT_TRUE( false );
}
- EXPECT_TRUE( s.contains( i.nKey ) );
- EXPECT_TRUE( s.contains( i ) );
- EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
- EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type&, other_item const& ) {} ) );
+ EXPECT_TRUE( s.contains( i.nKey ));
+ EXPECT_TRUE( s.contains( i ));
+ EXPECT_TRUE( s.contains( other_item( i.key()), other_less()) );
+ EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
EXPECT_FALSE( s.find( i.nKey ) == s.end());
- EXPECT_FALSE( s.find( i ) == s.end() );
- EXPECT_FALSE( s.find_with( other_item( i.key() ), other_less()) == s.end() );
+ EXPECT_FALSE( s.find( i ) == s.end());
+ EXPECT_FALSE( s.find_with( other_item( i.key()), other_less()) == s.end());
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- EXPECT_TRUE( s.contains( i.nKey ) );
- EXPECT_TRUE( s.contains( i ) );
- EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ EXPECT_TRUE( s.contains( i.nKey ));
+ EXPECT_TRUE( s.contains( i ));
+ EXPECT_TRUE( s.contains( other_item( i.key()), other_less()) );
EXPECT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
v.nFindCount = 1;
{
EXPECT_EQ( ++v.nFindCount, 2u );
}));
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& )
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& )
{
EXPECT_EQ( ++v.nFindCount, 3u );
}));
break;
case 2:
EXPECT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- EXPECT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ EXPECT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 3:
EXPECT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
break;
}
- EXPECT_FALSE( s.contains( i.nKey ) );
- EXPECT_FALSE( s.contains( i ) );
- EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ EXPECT_FALSE( s.contains( i.nKey ));
+ EXPECT_FALSE( s.contains( i ));
+ EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- EXPECT_TRUE( s.insert( i ) );
+ EXPECT_TRUE( s.insert( i ));
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0u );
- EXPECT_TRUE( s.begin() == s.end() );
- EXPECT_TRUE( s.cbegin() == s.cend() );
+ EXPECT_TRUE( s.begin() == s.end());
+ EXPECT_TRUE( s.cbegin() == s.cend());
}
};
// Precondition: set is empty
// Postcondition: set is empty
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto& i : data ) {
- EXPECT_TRUE( s.insert( i ) );
+ EXPECT_TRUE( s.insert( i ));
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
// iterator test
EXPECT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.get_with( other_item( i.key() ), other_less() );
+ gp = s.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 3 ));
gp->nFindCount *= 2;
EXPECT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
break;
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 6 ));
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
break;
case 1:
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
EXPECT_TRUE( !gp );
}
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0 );
}
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto i : indices ) {
ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
typedef typename Set::guarded_ptr guarded_ptr;
// extract_min
size_t nCount = 0;
int nKey = -1;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
gp = s.extract_min();
ASSERT_FALSE( !gp );
EXPECT_EQ( nKey + 1, gp->key());
gp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// extract_max
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
nCount = 0;
nKey = nSetSize;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
gp = s.extract_max();
ASSERT_FALSE( !gp );
EXPECT_EQ( nKey - 1, gp->key());
gp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_less()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
updResult = s.update( i, []( bool bNew, value_type& val, value_type const& arg)
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( val.key(), arg.key() );
+ EXPECT_EQ( val.key(), arg.key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- ASSERT_TRUE( s.insert( i.key() ));
- ASSERT_FALSE( s.insert( i.key() ));
+ ASSERT_TRUE( s.insert( i.key()));
+ ASSERT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( bool bNew, value_type& val, int arg)
{
EXPECT_FALSE( bNew );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_TRUE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
}, false );
EXPECT_TRUE( updResult.first );
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 2u );
}));
break;
ASSERT_TRUE( s.emplace( i.key()));
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
}));
break;
EXPECT_TRUE( str.empty());
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
EXPECT_EQ( v.strVal, std::string( "Hello!" ));
- } ) );
+ } ));
break;
default:
// forgot anything?..
ASSERT_TRUE( false );
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
- ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type&, other_item const& ) {} ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
v.nFindCount = 1;
{
EXPECT_EQ( ++v.nFindCount, 2u );
}));
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& )
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& )
{
EXPECT_EQ( ++v.nFindCount, 3u );
}));
break;
case 2:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 3:
ASSERT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
break;
}
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_less()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
}
};
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Q>
explicit int_item( Q const& src )
- : nKey( src.key() )
+ : nKey( src.key())
, nVal( 0 )
{}
int_item( int_item&& src )
: nKey( src.nKey )
, nVal( src.nVal )
- , strVal( std::move( src.strVal ) )
+ , strVal( std::move( src.strVal ))
{}
int_item( int k, std::string&& s )
: nKey( k )
, nVal( k * 2 )
- , strVal( std::move( s ) )
+ , strVal( std::move( s ))
{}
explicit int_item( other_item const& s )
- : nKey( s.key() )
+ : nKey( s.key())
, nVal( s.key() * 2 )
{}
struct cmp {
int operator ()( int_item const& v1, int_item const& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename T>
int operator ()( int v1, T const& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// iterator test
ASSERT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.get_with( other_item( i.key() ), other_less() );
+ gp = s.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 3 ));
gp->nFindCount *= 2;
ASSERT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
break;
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 6 ));
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
break;
case 1:
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_TRUE( !gp );
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Q>
explicit int_item( Q const& src )
- : nKey( src.key() )
+ : nKey( src.key())
, nVal( 0 )
{}
int_item( int_item&& src )
: nKey( src.nKey )
, nVal( src.nVal )
- , strVal( std::move( src.strVal ) )
+ , strVal( std::move( src.strVal ))
{}
int_item( int k, std::string&& s )
: nKey( k )
, nVal( k * 2 )
- , strVal( std::move( s ) )
+ , strVal( std::move( s ))
{}
explicit int_item( other_item const& s )
- : nKey( s.key() )
+ : nKey( s.key())
, nVal( s.key() * 2 )
{}
struct cmp {
int operator ()( int_item const& v1, int_item const& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename T>
int operator ()( int v1, T const& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_FALSE( s.contains( i.nKey ) != s.end() );
- ASSERT_FALSE( s.contains( i ) != s.end() );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_less()) != s.end());
+ ASSERT_FALSE( s.contains( i.nKey ) != s.end());
+ ASSERT_FALSE( s.contains( i ) != s.end());
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_less()) != s.end());
std::pair<typename Set::iterator, bool> updResult;
switch ( idx % 6 ) {
case 0:
it = s.insert( i );
- ASSERT_TRUE( it != s.end() );
+ ASSERT_TRUE( it != s.end());
it->nFindCount = it->nKey;
ASSERT_TRUE( s.insert( i ) == s.end());
updResult = s.update( i, false );
EXPECT_FALSE( updResult.second );
break;
case 1:
- it = s.insert( i.key() );
+ it = s.insert( i.key());
ASSERT_TRUE( it != s.end());
- ASSERT_TRUE( s.insert( i.key() ) == s.end());
+ ASSERT_TRUE( s.insert( i.key()) == s.end());
it->nFindCount = it->nKey;
updResult = s.update( i.key(), false );
EXPECT_TRUE( updResult.first == it );
break;
case 3:
updResult = s.update( i.key());
- EXPECT_TRUE( updResult.first != s.end() );
+ EXPECT_TRUE( updResult.first != s.end());
EXPECT_TRUE( updResult.second );
updResult.first->nFindCount = updResult.first->nKey;
break;
it = s.emplace( i.key());
ASSERT_TRUE( it != s.end());
it->nFindCount = it->nKey;
- ASSERT_FALSE( s.emplace( i.key() ) != s.end());
+ ASSERT_FALSE( s.emplace( i.key()) != s.end());
break;
case 5:
str = "Hello!";
it = s.emplace( i.key(), std::move( str ));
- ASSERT_TRUE( it != s.end() );
+ ASSERT_TRUE( it != s.end());
EXPECT_TRUE( str.empty());
it->nFindCount = it->nKey;
str = "Hello!";
ASSERT_TRUE( s.emplace( i.key(), std::move( str )) == s.end());
- EXPECT_TRUE( str.empty() ); // yes, that's is :(
+ EXPECT_TRUE( str.empty()); // yes, that's is :(
break;
default:
// forgot anything?..
}
it = s.contains( i.nKey );
- ASSERT_TRUE( it != s.end() );
+ ASSERT_TRUE( it != s.end());
EXPECT_EQ( it->nFindCount, static_cast<unsigned>( it->nKey ));
- ASSERT_TRUE( s.contains( i ) != s.end() );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) != s.end());
+ ASSERT_TRUE( s.contains( i ) != s.end());
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) != s.end());
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// iterators
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
- ASSERT_TRUE( s.begin() == s.end() );
- ASSERT_TRUE( s.cbegin() == s.cend() );
+ ASSERT_TRUE( s.begin() == s.end());
+ ASSERT_TRUE( s.cbegin() == s.cend());
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// iterator test
ASSERT_TRUE( !rp );
switch ( idx % 3 ) {
case 0:
- rp = s.get( i.key() );
+ rp = s.get( i.key());
ASSERT_FALSE( !rp );
break;
case 1:
ASSERT_FALSE( !rp );
break;
case 2:
- rp = s.get_with( other_item( i.key() ), other_less() );
+ rp = s.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !rp );
}
- EXPECT_EQ( rp->key(), i.key() );
+ EXPECT_EQ( rp->key(), i.key());
EXPECT_EQ( rp->nFindCount, static_cast<unsigned>( i.key() * 3 ));
rp->nFindCount *= 2;
}
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_FALSE( !xp );
break;
case 1:
ASSERT_FALSE( !xp );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !xp );
break;
}
- EXPECT_EQ( xp->key(), i.key() );
+ EXPECT_EQ( xp->key(), i.key());
EXPECT_EQ( xp->nFindCount, static_cast<unsigned>( i.key() * 6 ));
}
xp.release();
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
break;
case 1:
xp = s.extract( i );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_TRUE( !xp );
else {
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_FALSE( !xp );
break;
case 1:
ASSERT_FALSE( !xp );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !xp );
break;
}
- EXPECT_EQ( xp->key(), i.key() );
+ EXPECT_EQ( xp->key(), i.key());
EXPECT_EQ( xp->nFindCount, static_cast<unsigned>( i.key() * 6 ));
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
break;
case 1:
xp = s.extract( i );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_TRUE( !xp );
}
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
base_class::test( s );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.reserve( nSetSize );
indices.reserve( nSetSize );
for ( size_t key = 0; key < nSetSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
typedef typename Set::exempt_ptr exempt_ptr;
// extract_min
size_t nCount = 0;
int nKey = -1;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
xp = s.extract_min();
ASSERT_FALSE( !xp );
- EXPECT_EQ( nKey + 1, xp->key() );
+ EXPECT_EQ( nKey + 1, xp->key());
++nCount;
nKey = xp->key();
}
xp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// extract_max
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
nCount = 0;
nKey = nSetSize;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
xp = s.extract_max();
ASSERT_FALSE( !xp );
- EXPECT_EQ( nKey - 1, xp->key() );
+ EXPECT_EQ( nKey - 1, xp->key());
++nCount;
nKey = xp->key();
}
xp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- EXPECT_FALSE( s.contains( i.nKey ) );
- EXPECT_FALSE( s.contains( i ) );
- EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ EXPECT_FALSE( s.contains( i.nKey ));
+ EXPECT_FALSE( s.contains( i ));
+ EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
- EXPECT_TRUE( s.find( i.nKey ) == s.end() );
- EXPECT_TRUE( s.find( i ) == s.end() );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less() ) == s.end() );
+ EXPECT_TRUE( s.find( i.nKey ) == s.end());
+ EXPECT_TRUE( s.find( i ) == s.end());
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
std::pair<bool, bool> updResult;
updResult = s.update( i, []( value_type& cur, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( cur.key(), old->key() );
+ EXPECT_EQ( cur.key(), old->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- EXPECT_TRUE( s.insert( i.key() ));
- EXPECT_FALSE( s.insert( i.key() ));
+ EXPECT_TRUE( s.insert( i.key()));
+ EXPECT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( value_type& cur, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( cur.key(), old->key() );
+ EXPECT_EQ( cur.key(), old->key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
updResult = s.update( i, []( value_type& v, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( v.key(), old->key() );
+ EXPECT_EQ( v.key(), old->key());
v.nUpdateNewCount = old->nUpdateNewCount + 1;
}, false );
EXPECT_TRUE( updResult.first );
updResult = s.update( i.key(), [&i]( value_type& v, value_type* old )
{
EXPECT_TRUE( old == nullptr );
- EXPECT_EQ( i.key(), v.key() );
+ EXPECT_EQ( i.key(), v.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i.key(), []( value_type& v, value_type* old )
{
EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( v.key(), old->key() );
+ EXPECT_EQ( v.key(), old->key());
v.nUpdateNewCount = old->nUpdateNewCount + 1;
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 2u );
}));
break;
EXPECT_TRUE( s.emplace( i.key()));
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
}));
break;
EXPECT_TRUE( str.empty());
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
EXPECT_EQ( v.strVal, std::string( "Hello!" ));
- } ) );
+ } ));
break;
case 8:
{
updResult = s.upsert( i.key(), false );
EXPECT_FALSE( updResult.first );
EXPECT_FALSE( updResult.second );
- EXPECT_TRUE( s.find( i.key() ) == s.end() );
+ EXPECT_TRUE( s.find( i.key()) == s.end());
- updResult = s.upsert( i.key() );
+ updResult = s.upsert( i.key());
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( updResult.second );
- auto it = s.find( i.key() );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ auto it = s.find( i.key());
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
updResult = s.upsert( i.key(), false );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
} ));
}
break;
updResult = s.upsert( i, false );
EXPECT_FALSE( updResult.first );
EXPECT_FALSE( updResult.second );
- EXPECT_TRUE( s.find( i ) == s.end() );
+ EXPECT_TRUE( s.find( i ) == s.end());
updResult = s.upsert( i );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( updResult.second );
auto it = s.find( i );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
updResult = s.upsert( i, false );
EXPECT_TRUE( updResult.first );
EXPECT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
} ));
}
break;
ASSERT_TRUE( false );
}
- EXPECT_TRUE( s.contains( i.nKey ) );
- EXPECT_TRUE( s.contains( i ) );
- EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
- EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type&, other_item const& ) {} ) );
+ EXPECT_TRUE( s.contains( i.nKey ));
+ EXPECT_TRUE( s.contains( i ));
+ EXPECT_TRUE( s.contains( other_item( i.key()), other_less()) );
+ EXPECT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ EXPECT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
auto it = s.find( i );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
- it = s.find_with( other_item( i.key() ), other_less() );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ it = s.find_with( other_item( i.key()), other_less());
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- EXPECT_TRUE( s.contains( i.nKey ) );
- EXPECT_TRUE( s.contains( i ) );
- EXPECT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ EXPECT_TRUE( s.contains( i.nKey ));
+ EXPECT_TRUE( s.contains( i ));
+ EXPECT_TRUE( s.contains( other_item( i.key()), other_less()) );
EXPECT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
v.nFindCount = 1;
{
EXPECT_EQ( ++v.nFindCount, 2u );
}));
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& )
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& )
{
EXPECT_EQ( ++v.nFindCount, 3u );
}));
auto it = s.find( i );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
- it = s.find_with( other_item( i.key() ), other_less() );
- ASSERT_FALSE( it == s.end() );
- EXPECT_EQ( it->key(), i.key() );
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
+ it = s.find_with( other_item( i.key()), other_less());
+ ASSERT_FALSE( it == s.end());
+ EXPECT_EQ( it->key(), i.key());
int nKey = i.key() - 1;
break;
case 2:
EXPECT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- EXPECT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ EXPECT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 3:
EXPECT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
break;
}
- EXPECT_FALSE( s.contains( i.nKey ) );
- EXPECT_FALSE( s.contains( i ) );
- EXPECT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ EXPECT_FALSE( s.contains( i.nKey ));
+ EXPECT_FALSE( s.contains( i ));
+ EXPECT_FALSE( s.contains( other_item( i.key()), other_less()));
EXPECT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
EXPECT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
EXPECT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
- EXPECT_TRUE( s.find( i.nKey ) == s.end() );
- EXPECT_TRUE( s.find( i ) == s.end() );
- EXPECT_TRUE( s.find_with( other_item( i.key() ), other_less() ) == s.end() );
+ EXPECT_TRUE( s.find( i.nKey ) == s.end());
+ EXPECT_TRUE( s.find( i ) == s.end());
+ EXPECT_TRUE( s.find_with( other_item( i.key()), other_less()) == s.end());
}
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- EXPECT_TRUE( s.insert( i ) );
+ EXPECT_TRUE( s.insert( i ));
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0u );
- EXPECT_TRUE( s.begin() == s.end() );
- EXPECT_TRUE( s.cbegin() == s.cend() );
+ EXPECT_TRUE( s.begin() == s.end());
+ EXPECT_TRUE( s.cbegin() == s.cend());
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto& i : data ) {
- EXPECT_TRUE( s.insert( i ) );
+ EXPECT_TRUE( s.insert( i ));
}
- EXPECT_FALSE( s.empty() );
+ EXPECT_FALSE( s.empty());
EXPECT_CONTAINER_SIZE( s, nSetSize );
// iterator test
EXPECT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.get_with( other_item( i.key() ), other_less() );
+ gp = s.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 3 ));
gp->nFindCount *= 2;
EXPECT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
break;
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 6 ));
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
break;
case 1:
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
EXPECT_TRUE( !gp );
}
- EXPECT_TRUE( s.empty() );
+ EXPECT_TRUE( s.empty());
EXPECT_CONTAINER_SIZE( s, 0 );
}
Stack stack;
value_type v;
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
ASSERT_EQ( stack.size(), 0u );
- ASSERT_TRUE( stack.push( 1 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( 1 ));
+ ASSERT_TRUE( !stack.empty());
ASSERT_EQ( stack.size(), 1u );
- ASSERT_TRUE( stack.push( 2 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( 2 ));
+ ASSERT_TRUE( !stack.empty());
ASSERT_EQ( stack.size(), 2u );
- ASSERT_TRUE( stack.push( 3 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( 3 ));
+ ASSERT_TRUE( !stack.empty());
ASSERT_EQ( stack.size(), 3u );
- ASSERT_TRUE( stack.pop( v ) );
+ ASSERT_TRUE( stack.pop( v ));
EXPECT_EQ( v, value_type( 3 ));
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( !stack.empty());
ASSERT_EQ( stack.size(), 2u );
- ASSERT_TRUE( stack.pop( v ) );
+ ASSERT_TRUE( stack.pop( v ));
EXPECT_EQ( v, value_type( 2 ));
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( !stack.empty());
ASSERT_EQ( stack.size(), 1u );
- ASSERT_TRUE( stack.pop( v ) );
+ ASSERT_TRUE( stack.pop( v ));
EXPECT_EQ( v, value_type( 1 ));
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
ASSERT_EQ( stack.size(), 0u );
v = 1000;
- ASSERT_TRUE( !stack.pop( v ) );
+ ASSERT_TRUE( !stack.pop( v ));
EXPECT_EQ( v, value_type( 1000 ));
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
ASSERT_EQ( stack.size(), 0u );
- ASSERT_TRUE( stack.push( 10 ) );
- ASSERT_TRUE( stack.push( 20 ) );
- ASSERT_TRUE( stack.push( 30 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( 10 ));
+ ASSERT_TRUE( stack.push( 20 ));
+ ASSERT_TRUE( stack.push( 30 ));
+ ASSERT_TRUE( !stack.empty());
ASSERT_EQ( stack.size(), 3u );
- while ( stack.pop( v ) );
+ while ( stack.pop( v ));
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
ASSERT_EQ( stack.size(), 0u );
}
};
typedef typename Stack::value_type value_type;
Stack stack;
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
value_type v1, v2, v3;
v1.nVal = 1;
v2.nVal = 2;
v3.nVal = 3;
- ASSERT_TRUE( stack.push( v1 ) );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.push( v2 ) );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.push( v3 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( v1 ));
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.push( v2 ));
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.push( v3 ));
+ ASSERT_TRUE( !stack.empty());
value_type * pv;
pv = stack.pop();
ASSERT_TRUE( pv != nullptr );
ASSERT_EQ( pv->nVal, 3 );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( !stack.empty());
pv = stack.pop();
ASSERT_TRUE( pv != nullptr );
ASSERT_EQ( pv->nVal, 2 );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( !stack.empty());
pv = stack.pop();
ASSERT_TRUE( pv != nullptr );
ASSERT_EQ( pv->nVal, 1 );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
pv = stack.pop();
ASSERT_TRUE( pv == nullptr );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
if ( !std::is_same<typename Stack::disposer, cds::intrusive::opt::v::empty_disposer>::value ) {
int v1disp = v1.nDisposeCount;
ASSERT_TRUE( stack.push( v3 ));
stack.clear();
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
EXPECT_EQ( v1.nDisposeCount, v1disp);
EXPECT_EQ( v2.nDisposeCount, v2disp);
EXPECT_EQ( v3.nDisposeCount, v3disp);
- ASSERT_TRUE( stack.push( v1 ) );
- ASSERT_TRUE( stack.push( v2 ) );
- ASSERT_TRUE( stack.push( v3 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( v1 ));
+ ASSERT_TRUE( stack.push( v2 ));
+ ASSERT_TRUE( stack.push( v3 ));
+ ASSERT_TRUE( !stack.empty());
stack.clear( true );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
EXPECT_EQ( v1.nDisposeCount, v1disp + 1 );
EXPECT_EQ( v2.nDisposeCount, v2disp + 1 );
{
typedef typename Stack::value_type value_type;
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
value_type v1, v2, v3;
v1.nVal = 1;
v2.nVal = 2;
v3.nVal = 3;
- ASSERT_TRUE( stack.push( v1 ) );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.push( v2 ) );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.push( v3 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( v1 ));
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.push( v2 ));
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.push( v3 ));
+ ASSERT_TRUE( !stack.empty());
value_type * pv;
pv = stack.pop();
ASSERT_NE( pv, nullptr );
ASSERT_EQ( pv, &v3 );
ASSERT_EQ( pv->nVal, 3 );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( !stack.empty());
pv = stack.pop();
ASSERT_NE( pv, nullptr );
ASSERT_EQ( pv, &v2 );
ASSERT_EQ( pv->nVal, 2 );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( !stack.empty());
pv = stack.pop();
ASSERT_NE( pv, nullptr );
ASSERT_EQ( pv, &v1 );
ASSERT_EQ( pv->nVal, 1 );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
pv = stack.pop();
ASSERT_EQ( pv, nullptr );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
ASSERT_EQ( v1.nDisposeCount, 0 );
ASSERT_EQ( v2.nDisposeCount, 0 );
stack.push( v3 );
stack.clear();
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
Stack::gc::scan();
if ( !std::is_same<typename Stack::disposer, cds::intrusive::opt::v::empty_disposer>::value ) {
typedef typename Stack::value_type value_type;
value_type v;
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
- ASSERT_TRUE( stack.push( 1 ) );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.push( 2 ) );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.push( 3 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( 1 ));
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.push( 2 ));
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.push( 3 ));
+ ASSERT_TRUE( !stack.empty());
- ASSERT_TRUE( stack.pop( v ) );
+ ASSERT_TRUE( stack.pop( v ));
ASSERT_EQ( v, 3 );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.pop_with( [&v]( value_type& src ) { v = src; } ) );
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.pop_with( [&v]( value_type& src ) { v = src; } ));
ASSERT_EQ( v, 2 );
- ASSERT_TRUE( !stack.empty() );
- ASSERT_TRUE( stack.pop( v ) );
+ ASSERT_TRUE( !stack.empty());
+ ASSERT_TRUE( stack.pop( v ));
ASSERT_EQ( v, 1 );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
v = 1000;
- ASSERT_TRUE( !stack.pop( v ) );
+ ASSERT_TRUE( !stack.pop( v ));
ASSERT_EQ( v, 1000 );
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
- ASSERT_TRUE( stack.push( 10 ) );
- ASSERT_TRUE( stack.push( 20 ) );
- ASSERT_TRUE( stack.push( 30 ) );
- ASSERT_TRUE( !stack.empty() );
+ ASSERT_TRUE( stack.push( 10 ));
+ ASSERT_TRUE( stack.push( 20 ));
+ ASSERT_TRUE( stack.push( 30 ));
+ ASSERT_TRUE( !stack.empty());
- ASSERT_TRUE( stack.emplace( 100 ) );
- ASSERT_TRUE( stack.pop( v ) );
+ ASSERT_TRUE( stack.emplace( 100 ));
+ ASSERT_TRUE( stack.pop( v ));
ASSERT_EQ( v, 100 );
stack.clear();
- ASSERT_TRUE( stack.empty() );
+ ASSERT_TRUE( stack.empty());
Stack::gc::scan();
}
> map_type;
typename map_type::hash_tuple_type ht;
- map_type m( std::move( ht ) );
+ map_type m( std::move( ht ));
test( m );
}
> map_type;
typename map_type::hash_tuple_type ht;
- map_type m( 32, 6, 0, std::move( ht ) );
+ map_type m( 32, 6, 0, std::move( ht ));
test( m );
}
> map_type;
typename map_type::hash_tuple_type ht;
- map_type m( std::move( ht ) );
+ map_type m( std::move( ht ));
test( m );
}
> map_type;
typename map_type::hash_tuple_type ht;
- map_type m( std::move( ht ) );
+ map_type m( std::move( ht ));
test( m );
}
> map_type;
typename map_type::hash_tuple_type ht;
- map_type m( 32, 6, 0, std::move( ht ) );
+ map_type m( 32, 6, 0, std::move( ht ));
test( m );
}
> map_type;
typename map_type::hash_tuple_type ht;
- map_type m( std::move( ht ) );
+ map_type m( std::move( ht ));
test( m );
}
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
} ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
ASSERT_TRUE( m.contains( i.nKey ));
- ASSERT_TRUE( m.contains( val.strVal ) );
+ ASSERT_TRUE( m.contains( val.strVal ));
ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE( m.contains( other_item( i.nKey ), other_predicate()));
ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_TRUE( false );
} ));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// clear
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i ));
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
{
bool operator()( Map& m, int key ) const
{
- return m.contains( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less() );
+ return m.contains( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less());
}
};
{
bool operator()( Map& m, int key ) const
{
- return m.erase_with( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less() );
+ return m.erase_with( cds_test::striped_map_fixture::other_item( key ), cds_test::striped_map_fixture::other_less());
}
template <typename Func>
ASSERT_FALSE( m.contains( i.nKey ));
ASSERT_FALSE( m.contains( i ));
- ASSERT_FALSE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey ) ));
+ ASSERT_FALSE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey )));
ASSERT_FALSE( m.find( i, []( map_pair const& ) {
ASSERT_TRUE( false );
} ));
ASSERT_TRUE( m.contains( i.nKey ));
ASSERT_TRUE( m.contains( i ));
- ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey ) ));
+ ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey )));
ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_EQ( v.first.nKey, v.second.nVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
} )));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
ASSERT_TRUE( m.contains( i.nKey ));
- ASSERT_TRUE( m.contains( val.strVal ) );
+ ASSERT_TRUE( m.contains( val.strVal ));
ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE(( call_contains_with<c_hasFindWith, Map>()( m, i.nKey )));
ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_TRUE( false );
} )));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// clear
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i ));
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
> map_type;
- map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( m );
}
cds::opt::copy_policy< cc::striped_set::move_item >
> map_type;
- map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( m );
}
cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
> map_type;
- map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( m );
}
cds::opt::copy_policy< cc::striped_set::move_item >
> map_type;
- map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ map_type m( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( m );
}
> set_type;
typename set_type::hash_tuple_type ht;
- set_type s( std::move( ht ) );
+ set_type s( std::move( ht ));
test( s );
}
> set_type;
typename set_type::hash_tuple_type ht;
- set_type s( 32, 6, 0, std::move( ht ) );
+ set_type s( 32, 6, 0, std::move( ht ));
test( s );
}
> set_type;
typename set_type::hash_tuple_type ht;
- set_type s( std::move( ht ) );
+ set_type s( std::move( ht ));
test( s );
}
> set_type;
typename set_type::hash_tuple_type ht;
- set_type s( std::move( ht ) );
+ set_type s( std::move( ht ));
test( s );
}
> set_type;
typename set_type::hash_tuple_type ht;
- set_type s( 32, 6, 0, std::move( ht ) );
+ set_type s( 32, 6, 0, std::move( ht ));
test( s );
}
> set_type;
typename set_type::hash_tuple_type ht;
- set_type s( std::move( ht ) );
+ set_type s( std::move( ht ));
test( s );
}
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ));
this->test( s, data );
}
}
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ));
this->test( s, data );
}
}
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ));
this->test( s, data );
}
}
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 128 ));
this->test( s, data );
}
}
// clear
for ( auto& i : data ) {
i.clear_stat();
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
for ( auto& i : data ) {
EXPECT_EQ( i.nDisposeCount, 1u );
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Item>
size_t operator()( const Item& i ) const
{
- return (*this)( i.key() );
+ return (*this)( i.key());
}
};
typedef hash_int hash1;
struct cmp {
int operator ()(const T& v1, const T& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename Q>
int operator ()(const Q& v1, const T& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
typedef typename Set::value_type value_type;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
EXPECT_EQ( i.nUpdateNewCount, 0u );
ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
- ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ) );
+ ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
i.nUpdateNewCount = 0;
break;
break;
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_predicate()));
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_predicate()));
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_predicate(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_predicate(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[ idx ];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_predicate() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_predicate()) );
EXPECT_EQ( i.nFindCount, 0u );
- ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_predicate(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_predicate(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
value_type v( i );
case 0:
ASSERT_FALSE( s.unlink( v ));
ASSERT_TRUE( s.unlink( i ));
- ASSERT_FALSE( s.unlink( i ) );
+ ASSERT_FALSE( s.unlink( i ));
break;
case 1:
ASSERT_TRUE( s.erase( i.key()));
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 2:
ASSERT_TRUE( s.erase( v ));
- ASSERT_FALSE( s.erase( v ) );
+ ASSERT_FALSE( s.erase( v ));
break;
case 3:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_predicate()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_predicate() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_predicate()) );
break;
case 4:
EXPECT_EQ( i.nEraseCount, 0u );
break;
case 5:
EXPECT_EQ( i.nEraseCount, 0u );
- ASSERT_TRUE( s.erase_with( other_item( i.key() ), other_predicate(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_TRUE( s.erase_with( other_item( i.key()), other_predicate(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_predicate(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_predicate(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
break;
}
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_predicate(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// clear
i.clear_stat();
ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// clear_and_dispose
for ( auto& i : data ) {
i.clear_stat();
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
- s.clear_and_dispose( mock_disposer() );
+ s.clear_and_dispose( mock_disposer());
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
for ( auto& i : data ) {
EXPECT_EQ( i.nDisposeCount, 1u );
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 4 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 4 ));
this->test( s, data );
}
}
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 4 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 4 ));
this->test( s, data );
}
}
std::vector< typename set_type::value_type > data;
{
- set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 4 ) );
+ set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>( 4 ));
this->test( s, data );
}
}
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
void copy_stat( stat const& s )
template <typename Q>
explicit int_item( Q const& src )
- : nKey( src.key() )
+ : nKey( src.key())
, nVal( 0 )
{}
: stat( src )
, nKey( src.nKey )
, nVal( src.nVal )
- , strVal( std::move( src.strVal ) )
+ , strVal( std::move( src.strVal ))
{}
int_item( int k, std::string&& s )
: nKey( k )
, nVal( k * 2 )
- , strVal( std::move( s ) )
+ , strVal( std::move( s ))
{}
explicit int_item( other_item const& s )
- : nKey( s.key() )
+ : nKey( s.key())
, nVal( s.key() * 2 )
{}
struct cmp {
int operator ()( int_item const& v1, int_item const& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename T>
int operator ()( int v1, T const& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_predicate()));
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_predicate()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_predicate(), []( value_type&, other_item const& ) {} ));
updResult = s.update( i, []( bool bNew, value_type& val, value_type const& arg)
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( val.key(), arg.key() );
+ EXPECT_EQ( val.key(), arg.key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- ASSERT_TRUE( s.insert( i.key() ));
- ASSERT_FALSE( s.insert( i.key() ));
+ ASSERT_TRUE( s.insert( i.key()));
+ ASSERT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( bool bNew, value_type& val, int arg)
{
EXPECT_FALSE( bNew );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_TRUE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
}, false );
EXPECT_TRUE( updResult.first );
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 2u );
}));
break;
ASSERT_TRUE( s.emplace( i.key()));
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
}));
break;
EXPECT_TRUE( str.empty());
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
EXPECT_EQ( v.strVal, std::string( "Hello!" ));
- } ) );
+ } ));
break;
default:
// forgot anything?..
ASSERT_TRUE( false );
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_predicate() ) );
- ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_predicate(), []( value_type&, other_item const& ) {} ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_predicate()) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_predicate(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_predicate() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_predicate()) );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
v.nFindCount = 1;
{
EXPECT_EQ( ++v.nFindCount, 2u );
}));
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_predicate(), []( value_type& v, other_item const& )
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_predicate(), []( value_type& v, other_item const& )
{
EXPECT_EQ( ++v.nFindCount, 3u );
}));
break;
case 2:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_predicate()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_predicate() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_predicate()) );
break;
case 3:
ASSERT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
break;
}
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_predicate()));
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_predicate()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_predicate(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_FALSE( s.contains( i.nKey ) );
+ ASSERT_FALSE( s.contains( i.nKey ));
ASSERT_FALSE( s.contains( i ));
ASSERT_FALSE( (call_contains_with< c_hasFindWith, Set >()( s, i.key())));
- ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ) );
- ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ) );
+ ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
+ ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( (call_find_with< c_hasFindWith, Set >()(s, i.key(), []( value_type&, other_item const& ) {} )));
std::pair<bool, bool> updResult;
switch ( idx % 8 ) {
case 0:
- ASSERT_TRUE( s.insert( i ) );
- ASSERT_FALSE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
+ ASSERT_FALSE( s.insert( i ));
updResult = s.update( i, []( bool bNew, value_type& val, value_type const& arg )
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( val.key(), arg.key() );
+ EXPECT_EQ( val.key(), arg.key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- ASSERT_TRUE( s.insert( i.key() ) );
- ASSERT_FALSE( s.insert( i.key() ) );
+ ASSERT_TRUE( s.insert( i.key()) );
+ ASSERT_FALSE( s.insert( i.key()) );
updResult = s.update( i.key(), []( bool bNew, value_type& val, int arg )
{
EXPECT_FALSE( bNew );
EXPECT_FALSE( updResult.second );
break;
case 2:
- ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ) );
- ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ));
+ ASSERT_FALSE( s.insert( i, []( value_type& v ) { ++v.nFindCount; } ));
ASSERT_TRUE( s.find( i.nKey, []( value_type const& v, int key )
{
EXPECT_EQ( v.key(), key );
EXPECT_EQ( v.nFindCount, 1u );
- } ) );
+ } ));
break;
case 3:
- ASSERT_TRUE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ) );
- ASSERT_FALSE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ));
+ ASSERT_FALSE( s.insert( i.key(), []( value_type& v ) { ++v.nFindCount; } ));
ASSERT_TRUE( s.find( i.nKey, []( value_type const& v, int key )
{
EXPECT_EQ( v.key(), key );
EXPECT_EQ( v.nFindCount, 1u );
- } ) );
+ } ));
break;
case 4:
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_TRUE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
} );
EXPECT_TRUE( updResult.first );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
}, false );
EXPECT_TRUE( updResult.first );
{
EXPECT_EQ( v.key(), key );
EXPECT_EQ( v.nUpdateNewCount, 2u );
- } ) );
+ } ));
break;
case 5:
updResult = s.update( i.key(), []( bool bNew, value_type& v, int arg )
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 2u );
- } ) );
+ } ));
break;
case 6:
- ASSERT_TRUE( s.emplace( i.key() ) );
+ ASSERT_TRUE( s.emplace( i.key()) );
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
- } ) );
+ } ));
break;
case 7:
str = "Hello!";
- ASSERT_TRUE( s.emplace( i.key(), std::move( str ) ) );
- EXPECT_TRUE( str.empty() );
+ ASSERT_TRUE( s.emplace( i.key(), std::move( str )) );
+ EXPECT_TRUE( str.empty());
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
- EXPECT_EQ( v.strVal, std::string( "Hello!" ) );
- } ) );
+ EXPECT_EQ( v.strVal, std::string( "Hello!" ));
+ } ));
break;
default:
// forgot anything?..
ASSERT_TRUE( false );
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( (call_contains_with< c_hasFindWith, Set>()( s, i.key() )));
- ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( (call_contains_with< c_hasFindWith, Set>()( s, i.key())));
+ ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_TRUE( (call_find_with< c_hasFindWith, Set >()(s, i.key(), []( value_type&, other_item const& ) {})));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
ASSERT_TRUE( (call_contains_with<c_hasFindWith, Set>()(s, i.key())));
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
int nKey = i.key() - 1;
switch ( idx % 6 ) {
case 0:
- ASSERT_TRUE( s.erase( i.key() ) );
- ASSERT_FALSE( s.erase( i.key() ) );
+ ASSERT_TRUE( s.erase( i.key()) );
+ ASSERT_FALSE( s.erase( i.key()) );
break;
case 1:
- ASSERT_TRUE( s.erase( i ) );
- ASSERT_FALSE( s.erase( i ) );
+ ASSERT_TRUE( s.erase( i ));
+ ASSERT_FALSE( s.erase( i ));
break;
case 2:
ASSERT_TRUE( (call_erase_with<c_hasEraseWith, Set>()( s, i.key())));
ASSERT_FALSE( s.erase( i.key(), [&nKey]( value_type const& v )
{
nKey = v.key();
- } ) );
+ } ));
EXPECT_EQ( i.key(), nKey + 1 );
break;
case 4:
ASSERT_TRUE( s.erase( i, [&nKey]( value_type const& v )
{
nKey = v.key();
- } ) );
+ } ));
EXPECT_EQ( i.key(), nKey );
nKey = i.key() - 1;
ASSERT_FALSE( s.erase( i, [&nKey]( value_type const& v )
{
nKey = v.key();
- } ) );
+ } ));
EXPECT_EQ( i.key(), nKey + 1 );
break;
case 5:
break;
}
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
ASSERT_FALSE( (call_contains_with<c_hasFindWith, Set>()( s, i.key())));
- ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ) );
+ ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( (call_find_with<c_hasFindWith, Set>()( s, i.key(), []( value_type&, other_item const& ) {})));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
// clear
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0u );
}
cds::opt::copy_policy< cc::striped_set::move_item >
> set_type;
- set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( s );
}
cds::opt::resizing_policy< cc::striped_set::load_factor_resizing<0>>
> set_type;
- set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( s );
}
cds::opt::copy_policy< cc::striped_set::move_item >
> set_type;
- set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ) );
+ set_type s( 30, cc::striped_set::load_factor_resizing<0>( 8 ));
this->test( s );
}
EXPECT_EQ( std::to_string( key.nKey ), val.strVal );
} ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
ASSERT_TRUE( m.check_consistency());
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
ASSERT_TRUE( m.contains( i.nKey ));
- ASSERT_TRUE( m.contains( val.strVal ) );
+ ASSERT_TRUE( m.contains( val.strVal ));
ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
ASSERT_TRUE( m.find( i, []( key_type const& key, value_type& val ) {
EXPECT_TRUE( false );
} ));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// clear
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i ));
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i, arrVals[ i.nKey ] ));
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
typedef typename Map::exempt_ptr exempt_ptr;
// extract
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
exempt_ptr xp;
for ( auto const& i : arrKeys ) {
value_type const& val = arrVals.at( i.nKey );
- ASSERT_TRUE( m.contains( i.nKey ) );
+ ASSERT_TRUE( m.contains( i.nKey ));
switch ( i.nKey % 4 ) {
case 0:
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->nVal, i.nKey );
- ASSERT_FALSE( m.contains( i.nKey ) );
+ ASSERT_FALSE( m.contains( i.nKey ));
switch ( i.nKey % 4 ) {
case 0:
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
EXPECT_TRUE( !xp );
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// extract_min
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i, arrVals[ i.nKey ] ));
size_t nCount = 0;
int nKey = -1;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
switch ( nCount % 3 ) {
case 0:
xp = m.extract_min();
xp = m.extract_min();
ASSERT_TRUE( !xp );
EXPECT_EQ( kkSize, nCount );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// extract_max
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i, arrVals[ i.nKey ] ));
nKey = kkSize;
nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
switch ( nCount % 3 ) {
case 0:
xp = m.extract_max();
xp = m.extract_max();
ASSERT_TRUE( !xp );
EXPECT_EQ( kkSize, nCount );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
EXPECT_EQ( std::to_string( key.nKey ), val.strVal );
} ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
ASSERT_TRUE( m.check_consistency());
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
ASSERT_TRUE( m.contains( i.nKey ));
- ASSERT_TRUE( m.contains( val.strVal ) );
+ ASSERT_TRUE( m.contains( val.strVal ));
ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
ASSERT_TRUE( m.find( i, []( key_type const& key, mapped_type& val ) {
EXPECT_TRUE( false );
} ));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
Map::gc::force_dispose();
// clear
for ( auto const& i : arrKeys ) {
- value_type& val( arrVals.at( i.nKey ) );
+ value_type& val( arrVals.at( i.nKey ));
ASSERT_TRUE( m.insert( i, &val ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
Map::gc::force_dispose();
EXPECT_EQ( item.nDisposeCount, 2u );
}
- ASSERT_TRUE( m.check_consistency() );
+ ASSERT_TRUE( m.check_consistency());
// RCU-specific test related to exempt_ptr
// extract
for ( auto const& i : arrKeys ) {
- value_type& val( arrVals.at( i.nKey ) );
- ASSERT_TRUE( m.insert( i, &val ) );
+ value_type& val( arrVals.at( i.nKey ));
+ ASSERT_TRUE( m.insert( i, &val ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
for ( auto const& i : arrKeys ) {
value_type const& val = arrVals.at( i.nKey );
- EXPECT_TRUE( m.contains( i.nKey ) );
+ EXPECT_TRUE( m.contains( i.nKey ));
switch ( i.nKey % 4 ) {
case 0:
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->nVal, i.nKey );
- EXPECT_FALSE( m.contains( i.nKey ) );
+ EXPECT_FALSE( m.contains( i.nKey ));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
xp.release();
}
// extract_min
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
for ( auto const& i : arrKeys ) {
- value_type& val( arrVals.at( i.nKey ) );
- ASSERT_TRUE( m.insert( i, &val ) );
+ value_type& val( arrVals.at( i.nKey ));
+ ASSERT_TRUE( m.insert( i, &val ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
- ASSERT_TRUE( m.check_consistency() );
+ ASSERT_TRUE( m.check_consistency());
int nPrevKey = -1;
size_t nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
switch ( nCount % 3 ) {
case 0:
xp = m.extract_min();
nPrevKey = xp->nVal;
++nCount;
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
EXPECT_EQ( nCount, kkSize );
xp.release();
}
// extract_max
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
for ( auto const& i : arrKeys ) {
- value_type& val( arrVals.at( i.nKey ) );
- ASSERT_TRUE( m.insert( i, &val ) );
+ value_type& val( arrVals.at( i.nKey ));
+ ASSERT_TRUE( m.insert( i, &val ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
- ASSERT_TRUE( m.check_consistency() );
+ ASSERT_TRUE( m.check_consistency());
nPrevKey = static_cast<int>(kkSize);
nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
switch ( nCount % 3 ) {
case 0:
xp = m.extract_max();
nPrevKey = xp->nVal;
++nCount;
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
EXPECT_EQ( nCount, kkSize );
xp.release();
}
// checking empty map
- ASSERT_TRUE( m.check_consistency() );
+ ASSERT_TRUE( m.check_consistency());
}
};
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
{
int operator ()(T const& v1, T const& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
int operator()( int lhs, T const& rhs ) const
{
- if ( lhs < rhs.key() )
+ if ( lhs < rhs.key())
return -1;
return lhs > rhs.key() ? 1 : 0;
}
// Precondition: tree is empty
// Postcondition: tree is empty
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0 );
size_t const nTreeSize = kSize;
data.push_back( value_type( static_cast<int>( key )));
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
EXPECT_EQ( i.nUpdateNewCount, 0u );
ASSERT_TRUE( t.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
- ASSERT_FALSE( t.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ) );
+ ASSERT_FALSE( t.insert( i, []( value_type& v ) { ++v.nUpdateNewCount;} ));
EXPECT_EQ( i.nUpdateNewCount, 1u );
i.nUpdateNewCount = 0;
break;
break;
}
- ASSERT_TRUE( t.contains( i.nKey ) );
- ASSERT_TRUE( t.contains( i ) );
- ASSERT_TRUE( t.contains( other_item( i.key() ), other_less()));
+ ASSERT_TRUE( t.contains( i.nKey ));
+ ASSERT_TRUE( t.contains( i ));
+ ASSERT_TRUE( t.contains( other_item( i.key()), other_less()));
EXPECT_EQ( i.nFindCount, 0u );
ASSERT_TRUE( t.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( t.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
+ ASSERT_TRUE( t.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
- ASSERT_TRUE( t.find( i, []( value_type& v, value_type& ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( t.find( i, []( value_type& v, value_type& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 3u );
}
- ASSERT_FALSE( t.empty() );
+ ASSERT_FALSE( t.empty());
ASSERT_CONTAINER_SIZE( t, nTreeSize );
std::for_each( data.begin(), data.end(), []( value_type& v ) { v.clear_stat(); });
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[ idx ];
- ASSERT_TRUE( t.contains( i.nKey ) );
- ASSERT_TRUE( t.contains( i ) );
- ASSERT_TRUE( t.contains( other_item( i.key() ), other_less() ) );
+ ASSERT_TRUE( t.contains( i.nKey ));
+ ASSERT_TRUE( t.contains( i ));
+ ASSERT_TRUE( t.contains( other_item( i.key()), other_less()) );
EXPECT_EQ( i.nFindCount, 0u );
- ASSERT_TRUE( t.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( t.find( i.nKey, []( value_type& v, int ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 1u );
- ASSERT_TRUE( t.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ) );
+ ASSERT_TRUE( t.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& ) { ++v.nFindCount; } ));
EXPECT_EQ( i.nFindCount, 2u );
value_type v( i );
case 0:
ASSERT_FALSE( t.unlink( v ));
ASSERT_TRUE( t.unlink( i ));
- ASSERT_FALSE( t.unlink( i ) );
+ ASSERT_FALSE( t.unlink( i ));
break;
case 1:
ASSERT_TRUE( t.erase( i.key()));
- ASSERT_FALSE( t.erase( i.key() ) );
+ ASSERT_FALSE( t.erase( i.key()) );
break;
case 2:
ASSERT_TRUE( t.erase( v ));
- ASSERT_FALSE( t.erase( v ) );
+ ASSERT_FALSE( t.erase( v ));
break;
case 3:
ASSERT_TRUE( t.erase_with( other_item( i.key()), other_less()));
- ASSERT_FALSE( t.erase_with( other_item( i.key() ), other_less() ) );
+ ASSERT_FALSE( t.erase_with( other_item( i.key()), other_less()) );
break;
case 4:
EXPECT_EQ( i.nEraseCount, 0u );
break;
case 5:
EXPECT_EQ( i.nEraseCount, 0u );
- ASSERT_TRUE( t.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_TRUE( t.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
- ASSERT_FALSE( t.erase_with( other_item( i.key() ), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
+ ASSERT_FALSE( t.erase_with( other_item( i.key()), other_less(), []( value_type& val ) { ++val.nEraseCount; } ));
EXPECT_EQ( i.nEraseCount, 1u );
break;
}
ASSERT_FALSE( t.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( t.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0 );
// Force retiring cycle
i.clear_stat();
ASSERT_TRUE( t.insert( i ));
}
- ASSERT_FALSE( t.empty() );
+ ASSERT_FALSE( t.empty());
ASSERT_CONTAINER_SIZE( t, nTreeSize );
// clear test
base_class::test( t );
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0 );
typedef typename Tree::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Tree::guarded_ptr gp;
gp = t.get( i );
ASSERT_TRUE( !gp );
- gp = t.get( i.key() );
+ gp = t.get( i.key());
ASSERT_TRUE( !gp );
gp = t.get_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
for ( auto idx : indices ) {
auto& i = data[idx];
i.nDisposeCount = 0;
- ASSERT_TRUE( t.insert( i ) );
+ ASSERT_TRUE( t.insert( i ));
}
// get/extract
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
- gp = t.get( i.key() );
+ gp = t.get( i.key());
ASSERT_FALSE( !gp );
++gp->nFindCount;
EXPECT_EQ( i.nFindCount, 2u );
gp = t.extract( i );
break;
case 2:
- gp = t.extract_with( other_item( i.key() ), other_less() );
+ gp = t.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !gp );
gp = t.extract( i );
ASSERT_TRUE( !gp );
- gp = t.extract( i.key() );
+ gp = t.extract( i.key());
ASSERT_TRUE( !gp );
- gp = t.extract_with( other_item( i.key() ), other_less() );
+ gp = t.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !gp );
}
gp.release();
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0u );
// Force retiring cycle
for ( auto idx : indices ) {
auto& i = data[idx];
i.nDisposeCount = 0;
- ASSERT_TRUE( t.insert( i ) );
+ ASSERT_TRUE( t.insert( i ));
}
size_t nCount = 0;
int nKey = -1;
- while ( !t.empty() ) {
+ while ( !t.empty()) {
gp = t.extract_min();
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->key(), nKey + 1 );
nKey = gp->key();
}
gp.release();
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0u );
- EXPECT_EQ( nCount, data.size() );
+ EXPECT_EQ( nCount, data.size());
// Force retiring cycle
Tree::gc::force_dispose();
for ( auto idx : indices ) {
auto& i = data[idx];
i.nDisposeCount = 0;
- ASSERT_TRUE( t.insert( i ) );
+ ASSERT_TRUE( t.insert( i ));
}
nCount = 0;
nKey = static_cast<int>( data.size());
- while ( !t.empty() ) {
+ while ( !t.empty()) {
gp = t.extract_max();
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->key(), nKey - 1 );
nKey = gp->key();
}
gp.release();
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0u );
- EXPECT_EQ( nCount, data.size() );
+ EXPECT_EQ( nCount, data.size());
// Force retiring cycle
Tree::gc::force_dispose();
base_class::test( t );
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0 );
typedef typename Tree::value_type value_type;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
typename Tree::exempt_ptr xp;
rcu_lock l;
value_type * p = t.get( i );
ASSERT_TRUE( p == nullptr );
- p = t.get( i.key() );
+ p = t.get( i.key());
ASSERT_TRUE( !p );
- p = t.get_with( other_item( i.key() ), other_less() );
+ p = t.get_with( other_item( i.key()), other_less());
ASSERT_TRUE( p == nullptr );
}
for ( auto idx : indices ) {
auto& i = data[idx];
i.nDisposeCount = 0;
- ASSERT_TRUE( t.insert( i ) );
+ ASSERT_TRUE( t.insert( i ));
}
// get/extract
++p->nFindCount;
EXPECT_EQ( i.nFindCount, 1u );
- p = t.get( i.key() );
+ p = t.get( i.key());
ASSERT_FALSE( !p );
++p->nFindCount;
EXPECT_EQ( i.nFindCount, 2u );
- p = t.get_with( other_item( i.key() ), other_less() );
+ p = t.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !p );
++p->nFindCount;
EXPECT_EQ( i.nFindCount, 3u );
xp = t.extract( i );
break;
case 2:
- xp = t.extract_with( other_item( i.key() ), other_less() );
+ xp = t.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_FALSE( !xp );
xp = t.extract( i );
ASSERT_TRUE( !xp );
- xp = t.extract( i.key() );
+ xp = t.extract( i.key());
ASSERT_TRUE( !xp );
- xp = t.extract_with( other_item( i.key() ), other_less() );
+ xp = t.extract_with( other_item( i.key()), other_less());
ASSERT_TRUE( !xp );
}
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0u );
// Force retiring cycle
for ( auto idx : indices ) {
auto& i = data[idx];
i.nDisposeCount = 0;
- ASSERT_TRUE( t.insert( i ) );
+ ASSERT_TRUE( t.insert( i ));
}
size_t nCount = 0;
int nKey = -1;
- while ( !t.empty() ) {
+ while ( !t.empty()) {
xp = t.extract_min();
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->key(), nKey + 1 );
nKey = xp->key();
}
xp.release();
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0u );
- EXPECT_EQ( nCount, data.size() );
+ EXPECT_EQ( nCount, data.size());
// Force retiring cycle
Tree::gc::force_dispose();
for ( auto idx : indices ) {
auto& i = data[idx];
i.nDisposeCount = 0;
- ASSERT_TRUE( t.insert( i ) );
+ ASSERT_TRUE( t.insert( i ));
}
nCount = 0;
nKey = static_cast<int>( data.size());
- while ( !t.empty() ) {
+ while ( !t.empty()) {
xp = t.extract_max();
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->key(), nKey - 1 );
nKey = xp->key();
}
xp.release();
- ASSERT_TRUE( t.empty() );
+ ASSERT_TRUE( t.empty());
ASSERT_CONTAINER_SIZE( t, 0u );
- EXPECT_EQ( nCount, data.size() );
+ EXPECT_EQ( nCount, data.size());
// Force retiring cycle
Tree::gc::force_dispose();
EXPECT_EQ( std::to_string( v.first.nKey ), v.second.strVal );
} ));
}
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
ASSERT_TRUE( m.check_consistency());
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
// erase/find
for ( auto const& i : arrKeys ) {
- value_type const& val( arrVals.at( i.nKey ) );
+ value_type const& val( arrVals.at( i.nKey ));
ASSERT_TRUE( m.contains( i.nKey ));
- ASSERT_TRUE( m.contains( val.strVal ) );
+ ASSERT_TRUE( m.contains( val.strVal ));
ASSERT_TRUE( m.contains( i ));
ASSERT_TRUE( m.contains( other_item( i.nKey ), other_less()));
ASSERT_TRUE( m.find( i, []( map_pair const& v ) {
EXPECT_TRUE( false );
} ));
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// clear
for ( auto const& i : arrKeys )
ASSERT_TRUE( m.insert( i ));
- ASSERT_FALSE( m.empty() );
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
m.clear();
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
}
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
// get/extract
gp = m.get_with( other_item( i.nKey ), other_less());
ASSERT_TRUE( !gp );
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
gp = m.extract_min();
EXPECT_TRUE( !gp );
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
// extract_min
int nKey = -1;
size_t nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
gp = m.extract_min();
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->first.nKey, nKey + 1 );
nKey = gp->first.nKey;
++nCount;
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
EXPECT_EQ( nCount, kkSize );
// extract_max
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
nKey = kkSize;
nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
gp = m.extract_max();
ASSERT_FALSE( !gp );
EXPECT_EQ( gp->first.nKey, nKey - 1 );
nKey = gp->first.nKey;
++nCount;
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
EXPECT_EQ( nCount, kkSize );
}
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
- ASSERT_FALSE( m.empty() );
+ ASSERT_TRUE( m.insert( i ));
+ ASSERT_FALSE( m.empty());
ASSERT_CONTAINER_SIZE( m, kkSize );
typedef typename Map::exempt_ptr exempt_ptr;
typedef typename Map::rcu_lock rcu_lock;
// get/extract
- shuffle( arrKeys.begin(), arrKeys.end() );
+ shuffle( arrKeys.begin(), arrKeys.end());
exempt_ptr xp;
for ( auto const& i : arrKeys ) {
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
ASSERT_FALSE( !xp );
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
EXPECT_TRUE( !xp );
xp = m.extract( val.strVal );
break;
case 3:
- xp = m.extract_with( other_item( i.nKey ), other_less() );
+ xp = m.extract_with( other_item( i.nKey ), other_less());
break;
}
EXPECT_TRUE( !xp );
ASSERT_TRUE( !rp );
rp = m.get( i );
ASSERT_TRUE( !rp );
- rp = m.get_with( other_item( i.nKey ), other_less() );
+ rp = m.get_with( other_item( i.nKey ), other_less());
ASSERT_TRUE( !rp );
}
}
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// extract_min
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
+ ASSERT_TRUE( m.insert( i ));
size_t nCount = 0;
int nKey = -1;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
xp = m.extract_min();
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->first.nKey, nKey + 1 );
xp = m.extract_max();
ASSERT_TRUE( !xp );
EXPECT_EQ( kkSize, nCount );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
// extract_max
EXPECT_TRUE( !xp );
for ( auto const& i : arrKeys )
- ASSERT_TRUE( m.insert( i ) );
+ ASSERT_TRUE( m.insert( i ));
nKey = kkSize;
nCount = 0;
- while ( !m.empty() ) {
+ while ( !m.empty()) {
xp = m.extract_max();
ASSERT_FALSE( !xp );
EXPECT_EQ( xp->first.nKey, nKey - 1 );
xp = m.extract_max();
ASSERT_TRUE( !xp );
EXPECT_EQ( kkSize, nCount );
- ASSERT_TRUE( m.empty() );
+ ASSERT_TRUE( m.empty());
ASSERT_CONTAINER_SIZE( m, 0 );
}
};
void clear_stat()
{
- memset( this, 0, sizeof( *this ) );
+ memset( this, 0, sizeof( *this ));
}
};
template <typename Q>
explicit int_item( Q const& src )
- : nKey( src.key() )
+ : nKey( src.key())
, nVal( 0 )
{}
int_item( int_item&& src )
: nKey( src.nKey )
, nVal( src.nVal )
- , strVal( std::move( src.strVal ) )
+ , strVal( std::move( src.strVal ))
{}
int_item( int k, std::string&& s )
: nKey( k )
, nVal( k * 2 )
- , strVal( std::move( s ) )
+ , strVal( std::move( s ))
{}
explicit int_item( other_item const& s )
- : nKey( s.key() )
+ : nKey( s.key())
, nVal( s.key() * 2 )
{}
struct cmp {
int operator ()( int_item const& v1, int_item const& v2 ) const
{
- if ( v1.key() < v2.key() )
+ if ( v1.key() < v2.key())
return -1;
return v1.key() > v2.key() ? 1 : 0;
}
template <typename T>
int operator ()( int v1, T const& v2 ) const
{
- if ( v1 < v2.key() )
+ if ( v1 < v2.key())
return -1;
return v1 > v2.key() ? 1 : 0;
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
size_t const nSetSize = kSize;
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
// insert/find
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_less()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
updResult = s.update( i, []( bool bNew, value_type& val, value_type const& arg)
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( val.key(), arg.key() );
+ EXPECT_EQ( val.key(), arg.key());
}, false );
EXPECT_TRUE( updResult.first );
EXPECT_FALSE( updResult.second );
break;
case 1:
- ASSERT_TRUE( s.insert( i.key() ));
- ASSERT_FALSE( s.insert( i.key() ));
+ ASSERT_TRUE( s.insert( i.key()));
+ ASSERT_FALSE( s.insert( i.key()));
updResult = s.update( i.key(), []( bool bNew, value_type& val, int arg)
{
EXPECT_FALSE( bNew );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_TRUE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
});
EXPECT_TRUE( updResult.first );
updResult = s.update( i, []( bool bNew, value_type& v, value_type const& arg )
{
EXPECT_FALSE( bNew );
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
++v.nUpdateNewCount;
}, false );
EXPECT_TRUE( updResult.first );
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nUpdateNewCount, 2u );
}));
break;
ASSERT_TRUE( s.emplace( i.key()));
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
}));
break;
EXPECT_TRUE( str.empty());
ASSERT_TRUE( s.find( i, []( value_type const& v, value_type const& arg )
{
- EXPECT_EQ( v.key(), arg.key() );
+ EXPECT_EQ( v.key(), arg.key());
EXPECT_EQ( v.nVal, arg.nVal );
EXPECT_EQ( v.strVal, std::string( "Hello!" ));
- } ) );
+ } ));
break;
default:
// forgot anything?..
ASSERT_TRUE( false );
}
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
- ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ) );
- ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ) );
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type&, other_item const& ) {} ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
+ ASSERT_TRUE( s.find( i.nKey, []( value_type&, int ) {} ));
+ ASSERT_TRUE( s.find( i, []( value_type&, value_type const& ) {} ));
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
ASSERT_TRUE( s.check_consistency());
// erase
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto idx : indices ) {
auto& i = data[idx];
- ASSERT_TRUE( s.contains( i.nKey ) );
- ASSERT_TRUE( s.contains( i ) );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) );
+ ASSERT_TRUE( s.contains( i.nKey ));
+ ASSERT_TRUE( s.contains( i ));
+ ASSERT_TRUE( s.contains( other_item( i.key()), other_less()) );
ASSERT_TRUE( s.find( i.nKey, []( value_type& v, int )
{
v.nFindCount = 1;
{
EXPECT_EQ( ++v.nFindCount, 2u );
}));
- ASSERT_TRUE( s.find_with( other_item( i.key() ), other_less(), []( value_type& v, other_item const& )
+ ASSERT_TRUE( s.find_with( other_item( i.key()), other_less(), []( value_type& v, other_item const& )
{
EXPECT_EQ( ++v.nFindCount, 3u );
}));
break;
case 2:
ASSERT_TRUE( s.erase_with( other_item( i.key()), other_less()));
- ASSERT_FALSE( s.erase_with( other_item( i.key() ), other_less() ) );
+ ASSERT_FALSE( s.erase_with( other_item( i.key()), other_less()) );
break;
case 3:
ASSERT_TRUE( s.erase( i.key(), [&nKey]( value_type const& v )
break;
}
- ASSERT_FALSE( s.contains( i.nKey ) );
- ASSERT_FALSE( s.contains( i ) );
- ASSERT_FALSE( s.contains( other_item( i.key() ), other_less()));
+ ASSERT_FALSE( s.contains( i.nKey ));
+ ASSERT_FALSE( s.contains( i ));
+ ASSERT_FALSE( s.contains( other_item( i.key()), other_less()));
ASSERT_FALSE( s.find( i.nKey, []( value_type&, int ) {} ));
ASSERT_FALSE( s.find( i, []( value_type&, value_type const& ) {} ));
ASSERT_FALSE( s.find_with( other_item( i.key()), other_less(), []( value_type&, other_item const& ) {} ));
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// clear
for ( auto& i : data ) {
- ASSERT_TRUE( s.insert( i ) );
+ ASSERT_TRUE( s.insert( i ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
s.clear();
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
};
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
typedef typename Set::guarded_ptr guarded_ptr;
ASSERT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.get( i.key() );
+ gp = s.get( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.get_with( other_item( i.key() ), other_less() );
+ gp = s.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
gp->nFindCount = gp->key() * 3;
gp.release();
ASSERT_TRUE( !gp );
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
ASSERT_FALSE( !gp );
break;
case 1:
ASSERT_FALSE( !gp );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !gp );
break;
}
- EXPECT_EQ( gp->key(), i.key() );
+ EXPECT_EQ( gp->key(), i.key());
EXPECT_EQ( gp->nFindCount, static_cast<size_t>( i.key() * 3 ));
switch ( idx % 3 ) {
case 0:
- gp = s.extract( i.key() );
+ gp = s.extract( i.key());
break;
case 1:
gp = s.extract( i );
break;
case 2:
- gp = s.extract_with( other_item( i.key() ), other_less() );
+ gp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_TRUE( !gp );
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// extract_min
size_t nCount = 0;
int nKey = -1;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
gp = s.extract_min();
ASSERT_FALSE( !gp );
- EXPECT_EQ( nKey + 1, gp->key() );
+ EXPECT_EQ( nKey + 1, gp->key());
++nCount;
nKey = gp->key();
}
gp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// extract_max
for ( auto i : indices ) {
ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
nCount = 0;
nKey = nSetSize;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
gp = s.extract_max();
ASSERT_FALSE( !gp );
- EXPECT_EQ( nKey - 1, gp->key() );
+ EXPECT_EQ( nKey - 1, gp->key());
++nCount;
nKey = gp->key();
}
gp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
// Precondition: set is empty
// Postcondition: set is empty
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
base_class::test( s );
data.reserve( kSize );
indices.reserve( kSize );
for ( size_t key = 0; key < kSize; ++key ) {
- data.push_back( value_type( static_cast<int>(key) ) );
+ data.push_back( value_type( static_cast<int>(key)) );
indices.push_back( key );
}
- shuffle( indices.begin(), indices.end() );
+ shuffle( indices.begin(), indices.end());
for ( auto i : indices ) {
ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
typedef typename Set::exempt_ptr exempt_ptr;
ASSERT_TRUE( !rp );
switch ( idx % 3 ) {
case 0:
- rp = s.get( i.key() );
+ rp = s.get( i.key());
ASSERT_FALSE( !rp );
break;
case 1:
ASSERT_FALSE( !rp );
break;
case 2:
- rp = s.get_with( other_item( i.key() ), other_less() );
+ rp = s.get_with( other_item( i.key()), other_less());
ASSERT_FALSE( !rp );
}
- EXPECT_EQ( rp->key(), i.key() );
+ EXPECT_EQ( rp->key(), i.key());
rp->nFindCount = rp->key() * 3;
}
}
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_FALSE( !xp );
break;
case 1:
ASSERT_FALSE( !xp );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !xp );
break;
}
- EXPECT_EQ( xp->key(), i.key() );
+ EXPECT_EQ( xp->key(), i.key());
EXPECT_EQ( xp->nFindCount, static_cast<unsigned>( i.key() * 3 ));
}
xp.release();
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
break;
case 1:
xp = s.extract( i );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_TRUE( !xp );
else {
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
ASSERT_FALSE( !xp );
break;
case 1:
ASSERT_FALSE( !xp );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
ASSERT_FALSE( !xp );
break;
}
- EXPECT_EQ( xp->key(), i.key() );
+ EXPECT_EQ( xp->key(), i.key());
EXPECT_EQ( xp->nFindCount, static_cast<unsigned>( i.key() * 3 ));
switch ( idx % 3 ) {
case 0:
- xp = s.extract( i.key() );
+ xp = s.extract( i.key());
break;
case 1:
xp = s.extract( i );
break;
case 2:
- xp = s.extract_with( other_item( i.key() ), other_less() );
+ xp = s.extract_with( other_item( i.key()), other_less());
break;
}
ASSERT_TRUE( !xp );
}
}
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// extract_min
size_t nCount = 0;
int nKey = -1;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
xp = s.extract_min();
ASSERT_FALSE( !xp );
- EXPECT_EQ( nKey + 1, xp->key() );
+ EXPECT_EQ( nKey + 1, xp->key());
++nCount;
nKey = xp->key();
}
xp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
// extract_max
for ( auto i : indices ) {
- ASSERT_TRUE( s.insert( data[i] ) );
+ ASSERT_TRUE( s.insert( data[i] ));
}
- ASSERT_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
nCount = 0;
nKey = nSetSize;
- while ( !s.empty() ) {
+ while ( !s.empty()) {
xp = s.extract_max();
ASSERT_FALSE( !xp );
- EXPECT_EQ( nKey - 1, xp->key() );
+ EXPECT_EQ( nKey - 1, xp->key());
++nCount;
nKey = xp->key();
}
xp.release();
EXPECT_EQ( nCount, nSetSize );
- ASSERT_TRUE( s.empty() );
+ ASSERT_TRUE( s.empty());
ASSERT_CONTAINER_SIZE( s, 0 );
}
$nTabsFound += $_ =~ s/\t/ /g;\r
$_ =~ s/\s+$//;\r
$_ =~ s/\s+;$/;/;\r
+ $_ =~ s/\)\s+\)/\)\)/g;\r
$str .= $_ ;\r
$str .= "\n" ;\r
}\r