Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

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
 Calculates the distance between two tagsets.
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;


Member Function Documentation

template<class T>
bool OpSet::contains const OpSet< T > &  ts  )  const
 

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

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>
int OpSet::distance const OpSet< T > &  ts  )  const
 

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 OpSet< T > &  ts  )  const
 

Set union.

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

template<class T>
OpSet< T > OpSet::operator+ const T &  tag  )  const
 

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  ) 
 

Singleton union.

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

template<class T>
OpSet< T > & OpSet::operator+= const T &  ts  ) 
 

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
 

Set difference.

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

template<class T>
OpSet< T > OpSet::operator- const T &  tag  )  const
 

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  ) 
 

Set difference.

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

template<class T>
OpSet< T > & OpSet::operator-= const T &  tag  ) 
 

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
 

Set intersection.

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

template<class T>
OpSet< T > & OpSet::operator^= const OpSet< T > &  ts  ) 
 

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 Fri Sep 9 22:19:31 2005 for libtagcoll by  doxygen 1.4.4