template<typename T>
class lunchbox::UnorderedIntervalSet< T >
A container to store intervals of elements efficently.
The type can be any class or typename which has the semantics of natural numbers for addition and comparison operations. The intervals are stored in an unordered fashion. Not thread-safe.
Example:
#include <test.h>
#include <lunchbox/unorderedIntervalSet.h>
int main( int, char** )
{
SetType set;
TEST( set.empty( ));
TEST( set.size() == 1 );
set.insert( 1, 5 );
TEST( set.exists( 3 ));
TEST( set.size() == 5 );
set.insert( 1, 5 );
TEST( set.size() == 5 );
set.insert( 2, 4 );
TEST( set.size() == 5 );
TEST( set.find( 0 ) == set.end( ));
TEST( *set.find( 3 ) == 3 );
TEST( set.find( 6 ) == set.end( ));
size_t i = 1;
for( SetType::const_iterator it = set.begin(); it != set.end(); ++it, ++i )
TEST( *it == i );
set.erase( 3, 4 );
TEST( set.size() == 3 );
set.erase( 2 );
TEST( set.size() == 2 );
TEST( set.exists( 1 ));
TEST( set.exists( 5 ));
set.clear();
TEST( set.empty( ));
set.insert( 0, 1 );
TEST( set.size() == 2 );
set.insert( 3, 5 );
TEST( set.size() == 5 );
SetType::const_iterator it = set.begin();
TEST( *it == 0 );
++it;
TEST( *it == 1 );
++it;
TEST( *it == 3 );
++it;
TEST( *it == 4 );
++it;
TEST( *it == 5 );
set.erase( 4, 7 );
TEST( set.size() == 3 );
set.erase( 40, 70 );
TEST( set.size() == 3 );
return EXIT_SUCCESS;
}
Definition at line 37 of file unorderedIntervalSet.h.