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_SET_TEST_SET_NOGC_H
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() );
- EXPECT_EQ( it->nFindCount, it->nKey );
- ASSERT_TRUE( s.contains( i ) != s.end() );
- ASSERT_TRUE( s.contains( other_item( i.key() ), other_less() ) != 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_FALSE( s.empty() );
+ ASSERT_FALSE( s.empty());
ASSERT_CONTAINER_SIZE( s, nSetSize );
// iterators
}
for ( auto it = s.cbegin(); it != s.cend(); ++it ) {
- EXPECT_EQ( it->nFindCount, it->key() * 3 );
+ EXPECT_EQ( it->nFindCount, static_cast<unsigned>( it->key() * 3 ));
}
// clear
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());
}
};