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 #ifndef HashSet_C
00028 #define HashSet_C
00029
00030 #include "HashSet.H"
00031
00032
00033
00034 template<class Key, class Hash>
00035 template<class AnyType>
00036 Foam::HashSet<Key, Hash>::HashSet(const HashTable<AnyType, Key, Hash>& h)
00037 :
00038 HashTable<nil, Key, Hash>(h.size())
00039 {
00040 for
00041 (
00042 typename HashTable<AnyType, Key, Hash>::const_iterator cit = h.cbegin();
00043 cit != h.cend();
00044 ++cit
00045 )
00046 {
00047 insert(cit.key());
00048 }
00049 }
00050
00051
00052
00053
00054 template<class Key, class Hash>
00055 inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
00056 {
00057 return found(key);
00058 }
00059
00060
00061 template<class Key, class Hash>
00062 bool Foam::HashSet<Key, Hash>::operator==(const HashSet<Key, Hash>& rhs) const
00063 {
00064
00065 for (const_iterator iter = this->cbegin(); iter != this->cend(); ++iter)
00066 {
00067 if (!rhs.found(iter.key()))
00068 {
00069 return false;
00070 }
00071 }
00072
00073
00074 for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
00075 {
00076 if (!found(iter.key()))
00077 {
00078 return false;
00079 }
00080 }
00081
00082 return true;
00083 }
00084
00085
00086 template<class Key, class Hash>
00087 bool Foam::HashSet<Key, Hash>::operator!=(const HashSet<Key, Hash>& rhs) const
00088 {
00089 return !(operator==(rhs));
00090 }
00091
00092
00093 template<class Key, class Hash>
00094 void Foam::HashSet<Key, Hash>::operator|=(const HashSet<Key, Hash>& rhs)
00095 {
00096
00097 for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
00098 {
00099 insert(iter.key());
00100 }
00101 }
00102
00103
00104 template<class Key, class Hash>
00105 void Foam::HashSet<Key, Hash>::operator&=(const HashSet<Key, Hash>& rhs)
00106 {
00107
00108 for (iterator iter = this->cbegin(); iter != this->cend(); ++iter)
00109 {
00110 if (!rhs.found(iter.key()))
00111 {
00112 erase(iter);
00113 }
00114 }
00115 }
00116
00117
00118 template<class Key, class Hash>
00119 void Foam::HashSet<Key, Hash>::operator^=(const HashSet<Key, Hash>& rhs)
00120 {
00121
00122 for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
00123 {
00124 if (found(iter.key()))
00125 {
00126 erase(iter.key());
00127 }
00128 else
00129 {
00130 insert(iter.key());
00131 }
00132 }
00133 }
00134
00135
00136
00137 template<class Key, class Hash>
00138 void Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
00139 {
00140
00141 for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter)
00142 {
00143 erase(iter.key());
00144 }
00145 }
00146
00147
00148
00149
00150
00151
00152 template<class Key, class Hash>
00153 Foam::HashSet<Key, Hash>
00154 Foam::operator|
00155 (
00156 const HashSet<Key, Hash>& hash1,
00157 const HashSet<Key, Hash>& hash2
00158 )
00159 {
00160 HashSet<Key, Hash> out(hash1);
00161 out |= hash2;
00162 return out;
00163 }
00164
00165
00166 template<class Key, class Hash>
00167 Foam::HashSet<Key, Hash>
00168 Foam::operator&
00169 (
00170 const HashSet<Key, Hash>& hash1,
00171 const HashSet<Key, Hash>& hash2
00172 )
00173 {
00174 HashSet<Key, Hash> out(hash1);
00175 out &= hash2;
00176 return out;
00177 }
00178
00179
00180 template<class Key, class Hash>
00181 Foam::HashSet<Key, Hash>
00182 Foam::operator^
00183 (
00184 const HashSet<Key, Hash>& hash1,
00185 const HashSet<Key, Hash>& hash2
00186 )
00187 {
00188 HashSet<Key, Hash> out(hash1);
00189 out ^= hash2;
00190 return out;
00191 }
00192
00193
00194
00195 #endif
00196
00197