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:
s.nKey = 0;
}
- int key() const
- {
- return nKey;
+ int key() const
+ {
+ return nKey;
}
};
}
};
- struct cmp
+ struct cmp
{
int operator()( key_type const& lhs, key_type const& rhs ) const
{
static const size_t nSize = 20;
typedef typename List::key_type list_key_type;
- typedef typename List::mapped_type list_mapped_type;
typedef typename List::value_type list_value_type;
struct key_val {
int key;
}
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 ) {
case 4:
{
- auto pair = l.update( i.key, []( list_value_type& n, list_value_type* old ) {
+ auto pair = l.update( i.key, []( list_value_type&, list_value_type* ) {
ASSERT_TRUE( false );
}, false );
EXPECT_FALSE( pair.first );
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.val * 12 );
+ ret = l.upsert( i.key, i.key * 12 );
EXPECT_TRUE( ret.first );
EXPECT_FALSE( ret.second );
EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
EXPECT_TRUE( l.contains( i.key ));
EXPECT_TRUE( l.contains( list_key_type(i.key)));
EXPECT_TRUE( l.contains( other_key( i.key ), other_less()));
- EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
+ EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
n.second.val = n.first.nKey;
} ));
EXPECT_TRUE( l.find( i.key, []( list_value_type& n ) {
} ));
auto pair = l.update( i.key, []( list_value_type& n, list_value_type* old ) {
- EXPECT_FALSE( old == nullptr );
- EXPECT_EQ( n.first.nKey * 5, n.second.val );
+ ASSERT_FALSE( old == nullptr );
+ EXPECT_EQ( n.first.nKey * 5, old->second.val );
n.second.val = n.first.nKey * 3;
}, false );
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 )
+ 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 );
}
};