KrisLibrary  1.0.0
Public Types | Public Member Functions | List of all members
RangeSet Class Reference

A set of integers within a range. Operates in two modes, set or bit vector mode. In bit-vector mode, allows O(1) membership testing (but the range is fixed). Set mode is just like a regular set. More...

#include <RangeSet.h>

Public Types

typedef set< int >::iterator iterator
 
typedef set< int >::const_iterator const_iterator
 

Public Member Functions

void clear ()
 
bool empty ()
 
void setRange (int imin, int imax)
 
void expandRange (int item)
 
void insert (int item)
 
template<class It >
void insert (It first, It last)
 
void erase (iterator it)
 
void erase (int item)
 
template<class It >
void erase (It first, It last)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_t size () const
 
int count (int item)
 
iterator find (int item)
 
const_iterator find (int item) const
 
bool isRangeEmpty () const
 
int minimum () const
 
int maximum () const
 
bool inRange (int item) const
 
bool cacheGet (int item) const
 
void cacheSet (int item, bool value)
 
void BuildCache ()
 
void ClearCache ()
 
bool IsCacheBuilt () const
 

Detailed Description

A set of integers within a range. Operates in two modes, set or bit vector mode. In bit-vector mode, allows O(1) membership testing (but the range is fixed). Set mode is just like a regular set.

If you need to do n membership tests, the best mode to use can be given by choosing the minimum cost: c(set mode) = n*log(n)*c(set query constant) c(vector mode) = n*c(vector query time) + c(malloc time for max-min+1 bits)


The documentation for this class was generated from the following files: