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

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 
00065     bool contains(const T& item) const { return find(item) != end(); }
00066 
00068     bool contains(const OpSet<T>& ts) const;
00069 
00079     int distance(const OpSet<T>& ts) const;
00080 
00085     OpSet<T> operator+(const T& tag) const;
00086 
00091     OpSet<T>& operator+=(const T& ts);
00092 
00097     OpSet<T> operator+(const OpSet<T>& ts) const;
00098 
00103     OpSet<T>& operator+=(const OpSet<T>& ts);
00104 
00109     OpSet<T> operator-(const T& tag) const;
00110 
00115     OpSet<T>& operator-=(const T& tag);
00116 
00121     OpSet<T> operator-(const OpSet<T>& ts) const;
00122 
00127     OpSet<T>& operator-=(const OpSet<T>& ts);
00128 
00133     OpSet<T> operator^(const OpSet<T>& ts) const;
00134 
00139     OpSet<T>& operator^=(const OpSet<T>& ts);
00140 };
00141 
00142 };
00143 
00144 // vim:set ts=4 sw=4:
00145 #endif

Generated on Fri Sep 9 22:18:59 2005 for libtagcoll by  doxygen 1.4.4