00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 #ifndef HashSet_H
00046 #define HashSet_H
00047
00048 #include "HashTable.H"
00049 #include "nil.H"
00050
00051
00052
00053 namespace Foam
00054 {
00055
00056
00057
00058
00059
00060 template<class Key=word, class Hash=string::hash>
00061 class HashSet
00062 :
00063 public HashTable<nil, Key, Hash>
00064 {
00065
00066 public:
00067
00068 typedef typename HashTable<nil, Key, Hash>::iterator iterator;
00069 typedef typename HashTable<nil, Key, Hash>::const_iterator const_iterator;
00070
00071
00072
00073
00074
00075 HashSet(const label size = 128)
00076 :
00077 HashTable<nil, Key, Hash>(size)
00078 {}
00079
00080
00081 HashSet(Istream& is)
00082 :
00083 HashTable<nil, Key, Hash>(is)
00084 {}
00085
00086
00087 HashSet(const UList<Key>& lst)
00088 :
00089 HashTable<nil, Key, Hash>(2*lst.size())
00090 {
00091 forAll(lst, i)
00092 {
00093 insert(lst[i]);
00094 }
00095 }
00096
00097
00098 HashSet(const HashSet<Key, Hash>& hs)
00099 :
00100 HashTable<nil, Key, Hash>(hs)
00101 {}
00102
00103
00104 HashSet(const Xfer<HashSet<Key, Hash> >& hs)
00105 :
00106 HashTable<nil, Key, Hash>(hs)
00107 {}
00108
00109
00110 HashSet(const Xfer<HashTable<nil, Key, Hash> >& hs)
00111 :
00112 HashTable<nil, Key, Hash>(hs)
00113 {}
00114
00115
00116
00117 template<class AnyType>
00118 HashSet(const HashTable<AnyType, Key, Hash>&);
00119
00120
00121
00122
00123
00124
00125 bool insert(const Key& key)
00126 {
00127 return HashTable<nil, Key, Hash>::insert(key, nil());
00128 }
00129
00130
00131 bool set(const Key& key)
00132 {
00133 return HashTable<nil, Key, Hash>::insert(key, nil());
00134 }
00135
00136
00137
00138
00139 inline bool operator[](const Key&) const;
00140
00141
00142
00143 bool operator==(const HashSet<Key, Hash>&) const;
00144
00145
00146 bool operator!=(const HashSet<Key, Hash>&) const;
00147
00148
00149
00150 void operator|=(const HashSet<Key, Hash>&);
00151
00152
00153 void operator&=(const HashSet<Key, Hash>&);
00154
00155
00156 void operator^=(const HashSet<Key, Hash>&);
00157
00158
00159 inline void operator+=(const HashSet<Key, Hash>& rhs)
00160 {
00161 this->operator|=(rhs);
00162 }
00163
00164
00165 void operator-=(const HashSet<Key, Hash>&);
00166
00167 };
00168
00169
00170
00171
00172
00173 template<class Key, class Hash>
00174 HashSet<Key,Hash> operator|
00175 (
00176 const HashSet<Key,Hash>& hash1,
00177 const HashSet<Key,Hash>& hash2
00178 );
00179
00180
00181
00182 template<class Key, class Hash>
00183 HashSet<Key,Hash> operator&
00184 (
00185 const HashSet<Key,Hash>& hash1,
00186 const HashSet<Key,Hash>& hash2
00187 );
00188
00189
00190
00191 template<class Key, class Hash>
00192 HashSet<Key,Hash> operator^
00193 (
00194 const HashSet<Key,Hash>& hash1,
00195 const HashSet<Key,Hash>& hash2
00196 );
00197
00198
00199
00200 typedef HashSet<> wordHashSet;
00201
00202
00203 typedef HashSet<label, Hash<label> > labelHashSet;
00204
00205
00206
00207
00208 }
00209
00210
00211
00212 #ifdef NoRepository
00213 # include "HashSet.C"
00214 #endif
00215
00216
00217
00218 #endif
00219
00220