A class for managing sets that supports the ability to define a set that represents all possible elements.
What is special about this set is the possibility to define a set that contains all possible elements:
If the equality of two sets must be tested, the operators "==" and "!=" and the member function "isEqual" can be used. If two sets must be compared in terms of size, the operators "<", ">", "<=", and ">=" and the member function "equalSize" can be used:
#include <AllSet.h>
Public Types | |
using | ConstIter = typename std::set< T >::const_iterator |
Public Member Functions | |
AllSet (const bool _all=false) | |
AllSet (const T &element) | |
void | invert () |
AllSet< T > | getComplement () const |
void | insert (const T &element) |
void | clear () |
const AllSet< T > & | operator&= (const AllSet< T > &set) |
intersection More... | |
const AllSet< T > & | operator+= (const AllSet< T > &set) |
union More... | |
const AllSet< T > & | operator-= (const AllSet< T > &set) |
difference / relative complement More... | |
bool | operator< (const AllSet< T > &set) const |
compares the size (not the content!) of two sets More... | |
bool | operator> (const AllSet< T > &set) const |
compares the size (not the content!) of two sets More... | |
bool | equalSize (const AllSet< T > &set) const |
compares the size (not the content!) of two sets More... | |
bool | intersects (const AllSet< T > &set) const |
Returns true only if there is an intersection between "this" and "set". More... | |
bool | contains (const AllSet< T > &set) const |
Returns true only if "set" is a strict subset of "this". More... | |
bool | contains (const T &element) const |
Returns true only if the element "element" is included in this set. More... | |
bool | isEqual (const AllSet< T > &set) const |
bool | isUniverse () const |
bool | isEmpty () const |
bool | isAll () const |
bool | isCountable () const |
void | toStream (std::ostream &os) const |
std::string | toString () const |
ConstIter | begin () const |
ConstIter | end () const |
Static Public Member Functions | |
static const AllSet< T > & | all () |
static const AllSet< T > & | emptySet () |
Private Attributes | |
bool | all_ |
true if the set represents a set of all possible elements (= "the universe" / the complement of the empty set) More... | |
std::set< T > | set_ |
using walberla::AllSet< T >::ConstIter = typename std::set<T>::const_iterator |
|
inlineexplicit |
|
inline |
|
inlinestatic |
|
inline |
|
inline |
bool walberla::AllSet< T >::contains | ( | const AllSet< T > & | set | ) | const |
Returns true only if "set" is a strict subset of "this".
|
inline |
Returns true only if the element "element" is included in this set.
|
inlinestatic |
|
inline |
|
inline |
compares the size (not the content!) of two sets
Returns true only if there are as many elements in "this" set as there are elements in the set "set".
|
inline |
|
inline |
bool walberla::AllSet< T >::intersects | ( | const AllSet< T > & | set | ) | const |
Returns true only if there is an intersection between "this" and "set".
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
const AllSet< T > & walberla::AllSet< T >::operator&= | ( | const AllSet< T > & | set | ) |
intersection
Calculates the intersection of "this" and "set", only the resulting set is kept.
const AllSet< T > & walberla::AllSet< T >::operator+= | ( | const AllSet< T > & | set | ) |
union
Calculates the union of "this" and "set", only the resulting set is kept.
const AllSet< T > & walberla::AllSet< T >::operator-= | ( | const AllSet< T > & | set | ) |
difference / relative complement
Calculates the difference of "this" and "set", only the resulting set (result = this - set) is kept.
bool walberla::AllSet< T >::operator< | ( | const AllSet< T > & | set | ) | const |
compares the size (not the content!) of two sets
Returns true only if there are less elements in "this" set than in the set "set".
bool walberla::AllSet< T >::operator> | ( | const AllSet< T > & | set | ) | const |
compares the size (not the content!) of two sets
Returns true only if there are more elements in "this" set than in the set "set".
void walberla::AllSet< T >::toStream | ( | std::ostream & | os | ) | const |
|
inline |
|
private |
true if the set represents a set of all possible elements (= "the universe" / the complement of the empty set)
|
private |