10#include <unordered_set>
11#include <initializer_list>
35 using Data = std::unordered_set<T>;
72 d = std::move(
other.d);
123 return d.insert(
value).second;
132 return d.insert(std::move(
value)).second;
141 return d.erase(
value) > 0;
177 for(
const auto &v :
other.d)
ret.d.insert(v);
188 for(
const auto &v : d) {
201 for(
const auto &v : d) {
225 template <
typename Func>
227 for(
const auto &v : d) func(v);
Unordered unique-element container wrapping std::unordered_set.
Definition hashset.h:28
HashSet & operator=(HashSet &&other) noexcept
Move assignment operator.
Definition hashset.h:71
Iterator begin() noexcept
Returns a mutable iterator to the first element.
Definition hashset.h:79
HashSet()=default
Default constructor. Creates an empty hash set.
HashSet & operator=(const HashSet &other)
Copy assignment operator.
Definition hashset.h:65
void swap(HashSet &other) noexcept
Swaps contents with another hash set.
Definition hashset.h:163
ConstIterator cend() const noexcept
Returns a const iterator to one past the last element.
Definition hashset.h:97
HashSet intersect(const HashSet &other) const
Returns the intersection of this set and other.
Definition hashset.h:186
size_t size() const noexcept
Returns the number of elements.
Definition hashset.h:108
ConstIterator constEnd() const noexcept
Returns a const iterator to one past the last element.
Definition hashset.h:100
bool remove(const T &value)
Removes value from the hash set.
Definition hashset.h:140
List< T > toList() const
Converts the hash set to a List.
Definition hashset.h:213
ConstIterator cbegin() const noexcept
Returns a const iterator to the first element.
Definition hashset.h:85
HashSet unite(const HashSet &other) const
Returns the union of this set and other.
Definition hashset.h:175
HashSet(const HashSet &other)
Copy constructor.
Definition hashset.h:50
typename Data::iterator Iterator
Mutable forward iterator.
Definition hashset.h:41
ConstIterator constBegin() const noexcept
Returns a const iterator to the first element.
Definition hashset.h:88
std::unordered_set< T > Data
Underlying std::unordered_set storage type.
Definition hashset.h:35
bool insert(const T &value)
Inserts a value into the hash set.
Definition hashset.h:122
void forEach(Func &&func) const
Calls func for every element.
Definition hashset.h:226
friend bool operator==(const HashSet &lhs, const HashSet &rhs)
Returns true if both hash sets have identical contents.
Definition hashset.h:234
void clear() noexcept
Removes all elements.
Definition hashset.h:154
~HashSet()=default
Destructor.
bool isEmpty() const noexcept
Returns true if the hash set has no elements.
Definition hashset.h:105
HashSet(std::initializer_list< T > initList)
Constructs a hash set from an initializer list.
Definition hashset.h:59
HashSet(HashSet &&other) noexcept
Move constructor.
Definition hashset.h:53
Iterator end() noexcept
Returns a mutable iterator to one past the last element.
Definition hashset.h:91
Iterator remove(Iterator pos)
Removes the element at pos.
Definition hashset.h:149
ConstIterator begin() const noexcept
Returns a const iterator to the first element.
Definition hashset.h:82
bool insert(T &&value)
Inserts a value into the hash set (move overload).
Definition hashset.h:131
bool contains(const T &value) const
Returns true if value exists in the hash set.
Definition hashset.h:113
typename Data::const_iterator ConstIterator
Const forward iterator.
Definition hashset.h:44
friend bool operator!=(const HashSet &lhs, const HashSet &rhs)
Returns true if the hash sets differ.
Definition hashset.h:237
HashSet subtract(const HashSet &other) const
Returns this set minus other.
Definition hashset.h:199
ConstIterator end() const noexcept
Returns a const iterator to one past the last element.
Definition hashset.h:94
Dynamic array container wrapping std::vector.
Definition list.h:40
bool contains(const T &val) const
Returns true if the list contains the given value.
Definition list.h:593
void reserve(size_t newCapacity)
Pre-allocates storage for at least newCapacity elements.
Definition list.h:314
void pushToBack(const T &value)
Pushes an item onto the back of the list.
Definition list.h:455
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
const T & value(const Result< T > &r)
Returns the value from a Result.
Definition result.h:56
#define PROMEKI_SHARED_FINAL(TYPE)
Macro for non-polymorphic native shared objects.
Definition sharedptr.h:88