Tagcoll::OpSet< T > Class Template Reference

OpSet is just the standard std::set extended with set operations. More...

#include <OpSet.h>

List of all members.

Public Member Functions

 OpSet ()
template<typename A, typename B>
 OpSet (A a, B b)
bool contains (const T &item) const
 Return true if the tag set contains tag, else false.
bool contains (const OpSet< T > &ts) const
 Return true if the tag set contains ts, else false.
int distance (const OpSet< T > &ts) const
OpSet< T > operator+ (const T &tag) const
 Singleton union.
OpSet< T > & operator+= (const T &ts)
 Singleton union.
OpSet< T > operator+ (const OpSet< T > &ts) const
 Set union.
OpSet< T > & operator+= (const OpSet< T > &ts)
 Singleton union.
OpSet< T > operator- (const T &tag) const
 Singleton difference.
OpSet< T > & operator-= (const T &tag)
 Singleton difference.
OpSet< T > operator- (const OpSet< T > &ts) const
 Set difference.
OpSet< T > & operator-= (const OpSet< T > &ts)
 Set difference.
OpSet< T > operator^ (const OpSet< T > &ts) const
 Set intersection.
OpSet< T > & operator^= (const OpSet< T > &ts)
 Set intersection.


Detailed Description

template<class T>
class Tagcoll::OpSet< T >

OpSet is just the standard std::set extended with set operations.

The reason for not using a plain std::set is that the libtagcoll code involves a lot of set operations, and overridden operators greatly help in having cleaner code.

Example:

  OpSet<string> myfavs;
  OpSet<string> yourfavs;
  myfavourite += "pear";
  myfavourite += "banana";
  yourfavourite += "apple";
  yourfavourite += "pear";
  OpSet<string> ourfavs = myfavs ^ yourfavs;
  OpSet<string> interesting = myfavs + yourfavs;
  OpSet<string> myonlyfavs = myfavs - yourfavs;
  for (OpSet<string>::const_iterator i = ourfavs.begin();
       i != ourfavs.end(); i++)
     cout << *i << endl;

Constructor & Destructor Documentation

template<class T>
Tagcoll::OpSet< T >::OpSet (  )  [inline]

template<class T>
template<typename A, typename B>
Tagcoll::OpSet< T >::OpSet ( a,
b 
) [inline]


Member Function Documentation

template<class T>
bool Tagcoll::OpSet< T >::contains ( const T &  item  )  const [inline]

Return true if the tag set contains tag, else false.

template<class T>
bool OpSet::contains ( const OpSet< T > &  ts  )  const [inline]

Return true if the tag set contains ts, else false.

template<class T>
int OpSet::distance ( const OpSet< T > &  ts  )  const [inline]

Calculates the distance between two tagsets.

The distance between A and B is defined by infinity if the intersection between A und B is empty, else it is $|(A \cup B) \setminus (A \cap B)|$

Returns:
the distance between the two tagsets or -1 if the distance is infinity

template<class T>
OpSet< T > OpSet::operator+ ( const T &  tag  )  const [inline]

Singleton union.

Returns:
the set union of this set and the singleton set {tag}

template<class T>
OpSet< T > & OpSet::operator+= ( const T &  ts  )  [inline]

Singleton union.

Returns:
the set union of this set and the singleton set {tag}

template<class T>
OpSet< T > OpSet::operator+ ( const OpSet< T > &  ts  )  const [inline]

Set union.

Returns:
the set union of this set and the set ts

template<class T>
OpSet< T > & OpSet::operator+= ( const OpSet< T > &  ts  )  [inline]

Singleton union.

Returns:
the set union of this set and the singleton set {tag}

template<class T>
OpSet< T > OpSet::operator- ( const T &  tag  )  const [inline]

Singleton difference.

Returns:
the set difference of this set and the singleton set {tag}

template<class T>
OpSet< T > & OpSet::operator-= ( const T &  tag  )  [inline]

Singleton difference.

Returns:
the set difference of this set and the singleton set {tag}

template<class T>
OpSet< T > OpSet::operator- ( const OpSet< T > &  ts  )  const [inline]

Set difference.

Returns:
the set difference of this set and the set ts

template<class T>
OpSet< T > & OpSet::operator-= ( const OpSet< T > &  ts  )  [inline]

Set difference.

Returns:
the set difference of this set and the set ts

template<class T>
OpSet< T > OpSet::operator^ ( const OpSet< T > &  ts  )  const [inline]

Set intersection.

Returns:
the set intersection of this set and the set ts

template<class T>
OpSet< T > & OpSet::operator^= ( const OpSet< T > &  ts  )  [inline]

Set intersection.

Returns:
the set intersection of this set and the set ts


The documentation for this class was generated from the following files:
Generated on Tue Aug 21 13:07:15 2007 for libtagcoll by  doxygen 1.5.3