walberla::AllSet< T > Class Template Reference

Detailed Description

template<typename T>
class walberla::AllSet< T >

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:

AllSet<int> universe = AllSet<int>::all(); // "universe" contains all integers
bool contains = universe.contains( [any integer] ); // -> true
universe -= 42; // "universe" contains all integers except 42
contains = universe.contains( 42 ); // -> false
AllSet<int> set = AllSet<int>(5) + AllSet<int>(23); // a set that consists of two integers: 5 and 23
contains = universe.contains( set ); // -> true
set += 42;
contains = universe.contains( set ); // -> false
bool intersects = universe.intersects( set ); // -> true

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:

AllSet<int> aAll = AllSet<int>::all() - 42;
AllSet<int> bAll = AllSet<int>::all();
bool boolean = ( aAll == bAll ); // -> false
boolean = aAll.equalSize( bAll ); // -> false
boolean = ( aAll < bAll ); // -> true
bAll -= 23;
boolean = ( aAll == bAll ); // -> false
boolean = aAll.equalSize( bAll ); // -> true
boolean = ( aAll < bAll ); // -> false
aAll -= 23;
bAll -= 42;
boolean = ( aAll == bAll ); // -> true
boolean = aAll.equalSize( bAll ); // -> true

#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_
 

Member Typedef Documentation

◆ ConstIter

template<typename T >
using walberla::AllSet< T >::ConstIter = typename std::set<T>::const_iterator

Constructor & Destructor Documentation

◆ AllSet() [1/2]

template<typename T >
walberla::AllSet< T >::AllSet ( const bool  _all = false)
inlineexplicit

◆ AllSet() [2/2]

template<typename T >
walberla::AllSet< T >::AllSet ( const T &  element)
inline

Member Function Documentation

◆ all()

template<typename T >
static const AllSet<T>& walberla::AllSet< T >::all ( )
inlinestatic

◆ begin()

template<typename T >
ConstIter walberla::AllSet< T >::begin ( ) const
inline

◆ clear()

template<typename T >
void walberla::AllSet< T >::clear ( )
inline

◆ contains() [1/2]

template<typename T >
bool walberla::AllSet< T >::contains ( const AllSet< T > &  set) const

Returns true only if "set" is a strict subset of "this".

◆ contains() [2/2]

template<typename T >
bool walberla::AllSet< T >::contains ( const T &  element) const
inline

Returns true only if the element "element" is included in this set.

◆ emptySet()

template<typename T >
static const AllSet<T>& walberla::AllSet< T >::emptySet ( )
inlinestatic

◆ end()

template<typename T >
ConstIter walberla::AllSet< T >::end ( ) const
inline

◆ equalSize()

template<typename T >
bool walberla::AllSet< T >::equalSize ( const AllSet< T > &  set) const
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".

◆ getComplement()

template<typename T >
AllSet<T> walberla::AllSet< T >::getComplement ( ) const
inline

◆ insert()

template<typename T >
void walberla::AllSet< T >::insert ( const T &  element)
inline

◆ intersects()

template<typename T >
bool walberla::AllSet< T >::intersects ( const AllSet< T > &  set) const

Returns true only if there is an intersection between "this" and "set".

◆ invert()

template<typename T >
void walberla::AllSet< T >::invert ( )
inline

◆ isAll()

template<typename T >
bool walberla::AllSet< T >::isAll ( ) const
inline

◆ isCountable()

template<typename T >
bool walberla::AllSet< T >::isCountable ( ) const
inline

◆ isEmpty()

template<typename T >
bool walberla::AllSet< T >::isEmpty ( ) const
inline

◆ isEqual()

template<typename T >
bool walberla::AllSet< T >::isEqual ( const AllSet< T > &  set) const
inline

◆ isUniverse()

template<typename T >
bool walberla::AllSet< T >::isUniverse ( ) const
inline

◆ operator&=()

template<typename T >
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.

◆ operator+=()

template<typename T >
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.

◆ operator-=()

template<typename T >
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.

◆ operator<()

template<typename T >
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".

◆ operator>()

template<typename T >
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".

◆ toStream()

template<typename T >
void walberla::AllSet< T >::toStream ( std::ostream &  os) const

◆ toString()

template<typename T >
std::string walberla::AllSet< T >::toString
inline

Member Data Documentation

◆ all_

template<typename T >
bool walberla::AllSet< T >::all_
private

true if the set represents a set of all possible elements (= "the universe" / the complement of the empty set)

◆ set_

template<typename T >
std::set<T> walberla::AllSet< T >::set_
private

The documentation for this class was generated from the following file:
void set(FlagT &flags, const FlagT::value_type flag)
Definition: Flags.h:57
bool intersects(const AllSet< T > &set) const
Returns true only if there is an intersection between "this" and "set".
Definition: AllSet.h:328
bool contains(const AllSet< T > &set) const
Returns true only if "set" is a strict subset of "this".
Definition: AllSet.h:353
static const AllSet< T > & all()
Definition: AllSet.h:104