walberla::Set< T > Class Template Reference

Detailed Description

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

Wrapper class for managing sets that store elements of type T.

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:

Set<int> A = Set<int>(1) + Set<int>(2) + Set<int>(3);
Set<int> B = Set<int>(1) + Set<int>(2);
Set<int> C = Set<int>(1) + Set<int>(2) + Set<int>(4);
bool boolean = ( A == B ); // -> false
boolean = ( A != B ); // -> true
boolean = ( A > B ); // -> true
boolean = ( A >= B ); // -> true
boolean = ( A < B ); // -> false
boolean = A.equalSize(B); // -> false
boolean = ( A == C ); // -> false
boolean = A.equalSize(C); // -> true
B.insert(3);
boolean = ( A == B ); // -> true
boolean = A.equalSize(B); // -> true
boolean = ( A > B ); // -> false
boolean = ( A >= B ); // -> true
boolean = ( A <= B ); // -> true

#include <Set.h>

Public Types

typedef std::set< T >::value_type value_type
 
typedef std::set< T >::const_iterator const_iterator
 
typedef std::set< T >::iterator iterator
 

Public Member Functions

 Set ()
 
 Set (const T &element)
 
virtual ~Set ()
 
std::pair< iterator, bool > insert (const T &element)
 
iterator insert (iterator position, const T &element)
 
template<class InputIterator >
void insert (InputIterator first, InputIterator last)
 
void clear ()
 removes all elements from this set More...
 
const Set< T > & operator&= (const Set< T > &set)
 intersection More...
 
const Set< T > & operator+= (const Set< T > &set)
 union More...
 
const Set< T > & operator-= (const Set< T > &set)
 difference / relative complement More...
 
bool operator< (const Set< T > &set) const
 compares the size (not the content!) of two sets More...
 
bool operator> (const Set< T > &set) const
 compares the size (not the content!) of two sets More...
 
bool operator<= (const Set< T > &set) const
 compares the size (not the content!) of two sets More...
 
bool operator>= (const Set< T > &set) const
 compares the size (not the content!) of two sets More...
 
bool equalSize (const Set< T > &set) const
 compares the size (not the content!) of two sets More...
 
bool intersects (const Set< T > &set) const
 true if both sets intersect More...
 
bool contains (const Set< T > &set) const
 true if "set" is completely contained within this set More...
 
bool contains (const T &element) const
 true if "element" is contained within this set More...
 
bool isEqual (const Set< T > &set) const
 true if both sets contain the same elements More...
 
bool empty () const
 true if this set is empty More...
 
bool isEmpty () const
 true if this set is empty More...
 
size_t size () const
 
void swap (Set< T > &set)
 
void toStream (std::ostream &os) const
 
std::string toString () const
 
const_iterator begin () const
 
iterator begin ()
 
const_iterator end () const
 
iterator end ()
 
const std::set< T > & get () const
 
std::set< T > & get ()
 

Static Public Member Functions

static const Set< T > & emptySet ()
 

Private Attributes

std::set< T > set_
 

Friends

Set< T > operator& (const Set &a, const Set &b)
 intersection More...
 
Set< T > operator+ (const Set &a, const Set &b)
 union More...
 
Set< T > operator- (const Set &a, const Set &b)
 difference / relative complement More...
 
bool operator== (const Set &a, const Set &b)
 compares the content of two sets More...
 
bool operator!= (const Set &a, const Set &b)
 compares the content of two sets More...
 

Member Typedef Documentation

template<typename T>
typedef std::set<T>::const_iterator walberla::Set< T >::const_iterator
template<typename T>
typedef std::set<T>::iterator walberla::Set< T >::iterator
template<typename T>
typedef std::set<T>::value_type walberla::Set< T >::value_type

Constructor & Destructor Documentation

template<typename T>
walberla::Set< T >::Set ( )
inline
template<typename T>
walberla::Set< T >::Set ( const T &  element)
inline
template<typename T>
virtual walberla::Set< T >::~Set ( )
inlinevirtual

Member Function Documentation

template<typename T>
const_iterator walberla::Set< T >::begin ( ) const
inline
template<typename T>
iterator walberla::Set< T >::begin ( )
inline
template<typename T>
void walberla::Set< T >::clear ( )
inline

removes all elements from this set

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

true if "set" is completely contained within this set

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

true if "element" is contained within this set

template<typename T>
bool walberla::Set< T >::empty ( ) const
inline

true if this set is empty

template<typename T>
static const Set<T>& walberla::Set< T >::emptySet ( )
inlinestatic
template<typename T>
const_iterator walberla::Set< T >::end ( ) const
inline
template<typename T>
iterator walberla::Set< T >::end ( )
inline
template<typename T>
bool walberla::Set< T >::equalSize ( const Set< T > &  set) const
inline

compares the size (not the content!) of two sets

template<typename T>
const std::set<T>& walberla::Set< T >::get ( ) const
inline
template<typename T>
std::set<T>& walberla::Set< T >::get ( )
inline
template<typename T>
std::pair<iterator,bool> walberla::Set< T >::insert ( const T &  element)
inline
template<typename T>
iterator walberla::Set< T >::insert ( iterator  position,
const T &  element 
)
inline
template<typename T>
template<class InputIterator >
void walberla::Set< T >::insert ( InputIterator  first,
InputIterator  last 
)
inline
template<typename T>
bool walberla::Set< T >::intersects ( const Set< T > &  set) const
inline

true if both sets intersect

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

true if this set is empty

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

true if both sets contain the same elements

template<typename T>
const Set< T > & walberla::Set< T >::operator&= ( const Set< T > &  set)
inline

intersection

Calculates the intersection of "this" and "set", only the resulting set is kept.

template<typename T>
const Set< T > & walberla::Set< T >::operator+= ( const Set< T > &  set)
inline

union

Calculates the union of "this" and "set", only the resulting set is kept.

template<typename T>
const Set< T > & walberla::Set< T >::operator-= ( const Set< T > &  set)
inline

difference / relative complement

Calculates the difference of "this" and "set", only the resulting set (result = this - set) is kept.

template<typename T>
bool walberla::Set< T >::operator< ( const Set< T > &  set) const
inline

compares the size (not the content!) of two sets

template<typename T>
bool walberla::Set< T >::operator<= ( const Set< T > &  set) const
inline

compares the size (not the content!) of two sets

template<typename T>
bool walberla::Set< T >::operator> ( const Set< T > &  set) const
inline

compares the size (not the content!) of two sets

template<typename T>
bool walberla::Set< T >::operator>= ( const Set< T > &  set) const
inline

compares the size (not the content!) of two sets

template<typename T>
size_t walberla::Set< T >::size ( ) const
inline
template<typename T>
void walberla::Set< T >::swap ( Set< T > &  set)
inline
template<typename T >
void walberla::Set< T >::toStream ( std::ostream &  os) const
template<typename T >
std::string walberla::Set< T >::toString ( ) const
inline

Friends And Related Function Documentation

template<typename T>
bool operator!= ( const Set< T > &  a,
const Set< T > &  b 
)
friend

compares the content of two sets

template<typename T>
Set<T> operator& ( const Set< T > &  a,
const Set< T > &  b 
)
friend

intersection

template<typename T>
Set<T> operator+ ( const Set< T > &  a,
const Set< T > &  b 
)
friend

union

template<typename T>
Set<T> operator- ( const Set< T > &  a,
const Set< T > &  b 
)
friend

difference / relative complement

template<typename T>
bool operator== ( const Set< T > &  a,
const Set< T > &  b 
)
friend

compares the content of two sets

Member Data Documentation

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

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