OKlibrary
0.2.1.6
|
00001 // Oliver Kullmann, 27.7.2003 (Swansea) 00002 /* Copyright 2003 - 2007 Oliver Kullmann 00003 This file is part of the OKlibrary. OKlibrary is free software; you can redistribute 00004 it and/or modify it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation and included in this library; either version 3 of the 00006 License, or any later version. */ 00007 00008 #ifndef LITSETWAECHTER 00009 #define LITSETWAECHTER 00010 00011 #include <set> 00012 #include <algorithm> 00013 #include <functional> 00014 00015 namespace LitSets { 00016 00017 template <class Literal, class Comp = std::less<Literal> > 00018 class Litset { 00019 00020 typedef std::set<Literal, Comp> setlit; 00021 setlit ls; 00022 00023 public : 00024 00025 typedef typename setlit::size_type size_type; 00026 typedef Literal Lit; 00027 typedef typename setlit::const_iterator const_iterator; 00028 00029 Litset(): ls() {} 00030 Litset(const Litset& l) : ls(l) {} 00031 Litset& operator =(const Litset& l) { 00032 ls = l.ls; 00033 } 00034 00035 size_type size() const { return ls.size(); } 00036 bool empty() const { return ls.empty(); } 00037 00038 Litset& add(Lit x) { 00039 ls.insert(x); 00040 return *this; 00041 } 00042 00043 Litset& erase(Lit x) { 00044 ls.erase(x); 00045 return *this; 00046 } 00047 00048 Litset& add(const Litset& L) { 00049 ls.insert(L.ls.begin(), L.ls.end()); 00050 return *this; 00051 } 00052 00053 Litset& erase(const Litset& L) { 00054 for (typename setlit::const_iterator i = L.ls.begin(); i != L.ls.end(); ++i) 00055 ls.erase(*i); 00056 return *this; 00057 } 00058 00059 const_iterator begin() const { return ls.begin(); } 00060 const_iterator end() const { return ls.end(); } 00061 00062 bool contains(Lit x) const { return ! (ls.find(x) == ls.end());} 00063 00064 bool operator == (const Litset& L) const { return ls == L.ls ;} 00065 bool operator < (const Litset& L) const { return ls < L.ls; } 00066 00067 }; 00068 00069 } 00070 00071 #include "Literals.hpp" 00072 00073 namespace LitSets { 00074 00075 typedef Litset<Literals::LitIntOccString> LitSet; 00076 } 00077 #endif