Skip to content

Commit df82456

Browse files
committed
fix(Basic): add missing functions in SmallSet
1 parent 53e62ec commit df82456

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

include/geode/basic/small_set.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,26 @@ namespace geode
5555
return container_.end();
5656
}
5757

58+
auto contains( const Type& element ) const
59+
{
60+
return absl::c_contains( container_, element );
61+
}
62+
5863
auto insert( const Type& element )
5964
{
60-
if( absl::c_contains( container_, element ) )
65+
if( contains( element ) )
6166
{
6267
return false;
6368
}
6469
container_.push_back( element );
6570
return true;
6671
}
6772

73+
auto erase( const Type& element )
74+
{
75+
return container_.erase( absl::c_find( container_, element ) );
76+
}
77+
6878
auto at( index_t index ) const
6979
{
7080
return container_.at( index );

tests/basic/test-small-set.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ void test()
3737
OPENGEODE_EXCEPTION( !set.insert( 0 ), "[Test] Insert not allow" );
3838
OPENGEODE_EXCEPTION( !set.insert( 1 ), "[Test] Insert not allow" );
3939
OPENGEODE_EXCEPTION( set.size(), "[Test] Set size should be 2" );
40+
set.erase( 0 );
41+
OPENGEODE_EXCEPTION( set.size(), "[Test] Set size should be 1" );
42+
OPENGEODE_EXCEPTION( set.at( 0 ) == 1, "[Test] Wrong value in set" );
4043
}
4144

4245
OPENGEODE_TEST( "small-set" )

0 commit comments

Comments
 (0)