65 #ifndef Foam_HashSet_H 66 #define Foam_HashSet_H 77 template<
class T>
class MinMax;
78 template<
class Key,
class Hash>
class HashSet;
93 template<
class Key,
class Hash=Foam::Hash<Key>>
101 template<
class InputIter>
102 inline label assignMany
137 explicit HashSet(
const label initialCapacity)
172 HashSet(std::initializer_list<Key> list);
176 template<
class AnyType,
class AnyHash>
184 bool test(
const Key&
key)
const 201 bool set(
const Key&
key)
216 void merge(HashSet<Key, Hash>& source);
228 template<
class InputIter>
229 inline label
insert(InputIter first, InputIter last);
233 inline label
insert(std::initializer_list<Key> list);
250 template<
class InputIter>
251 inline label
set(InputIter first, InputIter last)
253 return insert(first, last);
257 inline label
set(std::initializer_list<Key> list)
264 inline label
set(
const FixedList<Key, N>& list)
270 inline label
set(
const UList<Key>& list)
277 inline label
set(
const IndirectListBase<Key, Addr>& list)
284 template<
class InputIter>
285 inline label
setMany(InputIter first, InputIter last)
287 return insert(first, last);
292 template<
class InputIter>
293 inline label
unset(InputIter first, InputIter last);
297 inline label
unset(std::initializer_list<Key> list);
302 inline label
unset(
const FixedList<Key, N>& list);
306 inline label
unset(
const UList<Key>& list);
311 inline label
unset(
const IndirectListBase<Key, Addr>& list);
378 void operator=(std::initializer_list<Key> rhs);
402 template<
class UnaryPredicate>
406 template<
class BinaryPredicate>
410 template<
class UnaryPredicate>
411 label
countValues(
const UnaryPredicate&,
const bool) =
delete;
414 template<
class BinaryPredicate>
415 label
countEntries(
const BinaryPredicate&,
const bool) =
delete;
418 template<
class UnaryPredicate>
419 label
filterValues(
const UnaryPredicate&,
const bool) =
delete;
422 template<
class BinaryPredicate>
423 label
filterEntries(
const BinaryPredicate&,
const bool) =
delete;
446 template<
class Key,
class Hash>
447 Ostream& operator<<(Ostream& os, const HashSet<Key, Hash>& rhs);
452 template<
class Key,
class Hash>
461 template<
class Key,
class Hash>
470 template<
class Key,
class Hash>
479 template<
class Key,
class Hash>
A HashTable with keys but without contents that is similar to std::unordered_set. ...
List< Key > tocEntries(const BinaryPredicate &, const bool)=delete
Not applicable for HashSet.
this_type & operator^=(const this_type &rhs)
Only retain unique entries (xor)
bool emplace(const Key &key, Args &&... args)
Emplace insert a new entry, not overwriting existing entries.
A 1D vector of objects of type <T> with a fixed length <N>.
label filterValues(const UnaryPredicate &, const bool)=delete
Not applicable for HashSet.
bool operator()(const Key &key) const noexcept
Return true if the entry exists, same as contains()
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
bool test(const Key &key) const
Same as contains() - return true if key exists in the set.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
A min/max value pair with additional methods. In addition to conveniently storing values...
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write unordered keys (list), with line-breaks when length exceeds shortLen.
bool operator==(const this_type &rhs) const
Sets are equal if all keys are equal, independent of order or underlying storage size.
this_type & operator|=(const this_type &rhs)
Add entries to this HashSet.
void operator=(const this_type &rhs)
Copy assign.
constexpr const_iterator cend() const noexcept
void merge(HashSet< Key, Hash > &source)
Attempts to extract entries from source parameter and insert them into this, does not overwrite exist...
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
label filterEntries(const BinaryPredicate &, const bool)=delete
Not applicable for HashSet.
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
HashSet() noexcept=default
Default construct: empty without allocation (capacity=0)
key_iterator_base< iterator > key_iterator
Forward iterator returning the key.
bool unset(const Key &key)
Unset the specified key - same as erase.
bool contains(const Key &key) const
True if hashed key is contained (found) in table.
Ostream & writeKeys(Ostream &os, const label shortLen=0) const
Write unordered keys (list), with line-breaks when length exceeds shortLen.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
void operator=(const this_type &rhs)
Copy assign.
this_type & operator-=(const this_type &rhs)
Remove entries from this HashSet. Uses erase()
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
A HashTable similar to std::unordered_map.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
An Ostream is an abstract base class for all output systems (streams, files, token lists...
key_iterator_base< const_iterator > const_key_iterator
Forward const iterator returning the key.
OBJstream os(runTime.globalPath()/outputName)
label setMany(InputIter first, InputIter last)
Same as insert (no value to overwrite)
label countValues(const UnaryPredicate &, const bool)=delete
Not applicable for HashSet.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
this_type & operator &=(const this_type &rhs)
Only retain entries contained in both HashSets.
typename parent_type::key_iterator iterator
An iterator, returning reference to the key.
List< Key > tocValues(const UnaryPredicate &, const bool)=delete
Not applicable for HashSet.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
label countEntries(const BinaryPredicate &, const bool)=delete
Not applicable for HashSet.
HashTable< Foam::zero, Key, Hash > parent_type
The template instance used for the parent HashTable.
HashSet< Key, Hash > this_type
The template instance used for this HashSet.
bool operator[](const Key &key) const noexcept
Return true if the entry exists, same as contains().
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
this_type & operator+=(const this_type &rhs)
Add entries to this HashSet. Same as the '|=' operator.
typename parent_type::const_key_iterator const_iterator
A const_iterator, returning reference to the key.
const_iterator cbegin() const
bool operator!=(const this_type &rhs) const
The opposite of the equality operation.