LevelS C++ support library  3.50
Public Member Functions | List of all members
rangeset< T > Class Template Reference

#include <rangeset.h>

Public Member Functions

void clear ()
 
void reserve (tsize n)
 
tsize nranges () const
 
const rtype & data () const
 
const T & ivbegin (tdiff i) const
 
const T & ivend (tdiff i) const
 
ivlen (tdiff i) const
 
void append (const T &v1, const T &v2)
 
void append (const T &v)
 
void append (const rangeset &other)
 
void add (const T &v1, const T &v2)
 
void add (const T &v)
 
void remove (const T &v1, const T &v2)
 
void remove (const T &v)
 
void intersect (const T &a, const T &b)
 
nval () const
 
void toVector (std::vector< T > &res) const
 
std::vector< T > toVector () const
 
rangeset op_or (const rangeset &other) const
 
rangeset op_and (const rangeset &other) const
 
rangeset op_andnot (const rangeset &other) const
 
rangeset op_xor (const rangeset &other) const
 
tdiff findInterval (const T &v) const
 
bool operator== (const rangeset &other) const
 
bool contains (T a, T b) const
 
bool contains (T v) const
 
bool contains (const rangeset &other) const
 
bool overlaps (T a, T b) const
 
bool overlaps (const rangeset &other) const
 

Detailed Description

template<typename T>
class rangeset< T >

Class for storing sets of ranges of integer numbers

Definition at line 44 of file rangeset.h.

Member Function Documentation

◆ clear()

template<typename T>
void rangeset< T >::clear ( )
inline

Removes all rangeset entries.

Definition at line 223 of file rangeset.h.

◆ reserve()

template<typename T>
void rangeset< T >::reserve ( tsize  n)
inline

Reserves space for n ranges.

Definition at line 225 of file rangeset.h.

◆ nranges()

template<typename T>
tsize rangeset< T >::nranges ( ) const
inline

Returns the current number of ranges.

Definition at line 227 of file rangeset.h.

◆ data()

template<typename T>
const rtype& rangeset< T >::data ( ) const
inline

Returns the current vector of ranges.

Definition at line 231 of file rangeset.h.

◆ ivbegin()

template<typename T>
const T& rangeset< T >::ivbegin ( tdiff  i) const
inline

Returns the first value of range i.

Definition at line 245 of file rangeset.h.

◆ ivend()

template<typename T>
const T& rangeset< T >::ivend ( tdiff  i) const
inline

Returns the one-past-last value of range i.

Definition at line 247 of file rangeset.h.

◆ ivlen()

template<typename T>
T rangeset< T >::ivlen ( tdiff  i) const
inline

Returns the length of range i.

Definition at line 249 of file rangeset.h.

◆ append() [1/3]

template<typename T>
void rangeset< T >::append ( const T &  v1,
const T &  v2 
)
inline

Appends [v1;v2[ to the rangeset. v1 must be larger than the minimum of the last range in the rangeset.

Definition at line 253 of file rangeset.h.

◆ append() [2/3]

template<typename T>
void rangeset< T >::append ( const T &  v)
inline

Appends [v;v+1[ to the rangeset. v must be larger than the minimum of the last range in the rangeset.

Definition at line 266 of file rangeset.h.

◆ append() [3/3]

template<typename T>
void rangeset< T >::append ( const rangeset< T > &  other)
inline

Appends other to the rangeset. All values in other must be larger than the minimum of the last range in the rangeset.

Definition at line 271 of file rangeset.h.

◆ add() [1/2]

template<typename T>
void rangeset< T >::add ( const T &  v1,
const T &  v2 
)
inline

After this operation, the rangeset contains the union of itself with [v1;v2[.

Definition at line 279 of file rangeset.h.

◆ add() [2/2]

template<typename T>
void rangeset< T >::add ( const T &  v)
inline

After this operation, the rangeset contains the union of itself with [v;v+1[.

Definition at line 287 of file rangeset.h.

◆ remove() [1/2]

template<typename T>
void rangeset< T >::remove ( const T &  v1,
const T &  v2 
)
inline

Removes all values within [v1;v2[ from the rangeset.

Definition at line 290 of file rangeset.h.

◆ remove() [2/2]

template<typename T>
void rangeset< T >::remove ( const T &  v)
inline

Removes the value v from the rangeset.

Definition at line 299 of file rangeset.h.

◆ intersect()

template<typename T>
void rangeset< T >::intersect ( const T &  a,
const T &  b 
)
inline

Removes all values not within [a;b[ from the rangeset.

Definition at line 302 of file rangeset.h.

◆ nval()

template<typename T>
T rangeset< T >::nval ( ) const
inline

Returns the total number of elements in the rangeset.

Definition at line 322 of file rangeset.h.

◆ toVector() [1/2]

template<typename T>
void rangeset< T >::toVector ( std::vector< T > &  res) const
inline

After this operation, res contains all elements of the rangeset in ascending order.

Definition at line 332 of file rangeset.h.

◆ toVector() [2/2]

template<typename T>
std::vector<T> rangeset< T >::toVector ( ) const
inline

Returns a vector containing all elements of the rangeset in ascending order.

Definition at line 343 of file rangeset.h.

◆ op_or()

template<typename T>
rangeset rangeset< T >::op_or ( const rangeset< T > &  other) const
inline

Returns the union of this rangeset and other.

Definition at line 351 of file rangeset.h.

◆ op_and()

template<typename T>
rangeset rangeset< T >::op_and ( const rangeset< T > &  other) const
inline

Returns the intersection of this rangeset and other.

Definition at line 358 of file rangeset.h.

◆ op_andnot()

template<typename T>
rangeset rangeset< T >::op_andnot ( const rangeset< T > &  other) const
inline

Returns the part of this rangeset which is not in other.

Definition at line 365 of file rangeset.h.

◆ op_xor()

template<typename T>
rangeset rangeset< T >::op_xor ( const rangeset< T > &  other) const
inline

Returns the parts of this rangeset and other, which are not in both rangesets.

Definition at line 373 of file rangeset.h.

◆ findInterval()

template<typename T>
tdiff rangeset< T >::findInterval ( const T &  v) const
inline

Returns the index of the interval containing v; if no such interval exists, -1 is returned.

Definition at line 382 of file rangeset.h.

◆ operator==()

template<typename T>
bool rangeset< T >::operator== ( const rangeset< T > &  other) const
inline

Returns true if the rangeset is identical to other, else false.

Definition at line 390 of file rangeset.h.

◆ contains() [1/3]

template<typename T>
bool rangeset< T >::contains ( a,
b 
) const
inline

Returns true if the rangeset contains all values in the range [a;b[, else false.

Definition at line 395 of file rangeset.h.

◆ contains() [2/3]

template<typename T>
bool rangeset< T >::contains ( v) const
inline

Returns true if the rangeset contains the value v, else false.

Definition at line 403 of file rangeset.h.

◆ contains() [3/3]

template<typename T>
bool rangeset< T >::contains ( const rangeset< T > &  other) const
inline

Returns true if the rangeset contains all values stored in other, else false.

Definition at line 407 of file rangeset.h.

◆ overlaps() [1/2]

template<typename T>
bool rangeset< T >::overlaps ( a,
b 
) const
inline

Returns true if any of the numbers [a;b[ are contained in the set, else false.

Definition at line 411 of file rangeset.h.

◆ overlaps() [2/2]

template<typename T>
bool rangeset< T >::overlaps ( const rangeset< T > &  other) const
inline

Returns true if there is overlap between the set and "other", else false.

Definition at line 420 of file rangeset.h.


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

Generated on Mon Dec 10 2018 10:24:20 for LevelS C++ support library