OpSet.h

Go to the documentation of this file.
00001 #ifndef TAGCOLL_OPSET_H
00002 #define TAGCOLL_OPSET_H
00003 
00008 /*
00009  * Copyright (C) 2003,2004,2005  Enrico Zini <enrico@debian.org>
00010  *
00011  * This library is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU Lesser General Public
00013  * License as published by the Free Software Foundation; either
00014  * version 2.1 of the License, or (at your option) any later version.
00015  *
00016  * This library is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this library; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00024  */
00025 
00026 /* TODO: replace + with | and ^ with &, since logical operators better
00027  * correspond to set operations */
00028 
00029 #include <set>
00030 
00031 namespace Tagcoll
00032 {
00033 
00057 template<class T>
00058 class OpSet : public std::set<T>
00059 {
00060 public:
00061     using std::set<T>::begin;
00062     using std::set<T>::end;
00063 
00064     OpSet() : std::set<T>() {}
00065 
00066     template<typename A, typename B>
00067     OpSet(A a, B b) : std::set<T>(a, b) {}
00068 
00070     bool contains(const T& item) const { return this->find(item) != this->end(); }
00071 
00073     bool contains(const OpSet<T>& ts) const;
00074 
00084     int distance(const OpSet<T>& ts) const;
00085 
00090     OpSet<T> operator+(const T& tag) const;
00091 
00096     OpSet<T>& operator+=(const T& ts);
00097 
00102     OpSet<T> operator+(const OpSet<T>& ts) const;
00103 
00108     OpSet<T>& operator+=(const OpSet<T>& ts);
00109 
00114     OpSet<T> operator-(const T& tag) const;
00115 
00120     OpSet<T>& operator-=(const T& tag);
00121 
00126     OpSet<T> operator-(const OpSet<T>& ts) const;
00127 
00132     OpSet<T>& operator-=(const OpSet<T>& ts);
00133 
00138     OpSet<T> operator^(const OpSet<T>& ts) const;
00139 
00144     OpSet<T>& operator^=(const OpSet<T>& ts);
00145 };
00146 
00147 };
00148 
00149 // vim:set ts=4 sw=4:
00150 #endif

Generated on Sat Jan 17 03:28:21 2009 for libtagcoll by  doxygen 1.5.1