sincerely
Singaporean
If you have not done so, read this full tutorial on how to use SGEXTN to build an application.
(no source file, everything inside header)
template ‹typename T, typename EqualityCheck, typename HashFunction› class SGLUnorderedSet;
part of SGEXTN module SG_Containers
unordered set for any type of data
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGLUnorderedSet.h›
CMake target for BuildLah: SGEXTN::SG_Containers
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
[[nodiscard]] SGLUnorderedSet::Iterator begin();
[[nodiscard]] SGLUnorderedSet::ConstIterator constBegin() const;
[[nodiscard]] SGLUnorderedSet::ConstIterator constEnd() const;
[[nodiscard]] bool contains(const T& x) const;
[[nodiscard]] int count(const T& x) const;
[[nodiscard]] SGLUnorderedSet::Iterator end();
bool erase(SGLUnorderedSet::Iterator& x);
bool erase(const T& x);
[[nodiscard]] SGLUnorderedSet::ConstIterator find(const T& x) const;
[[nodiscard]] SGLUnorderedSet::Iterator find(const T& x);
bool insert(const T& x);
[[nodiscard]] int length() const;
void reserve(int newMemoryLength);
SGLUnorderedSet provides a template based unordered set that can be used with any data type. Use SGLSet instead if ordering matters. This is a template based class with no separate source file. This class is a SGEXTN container. Copy constructor, copy assignment, move constructor, move assignment, and destructor work as expected. A deep copy is performed whenever this class is copied, and the new instance will not be linked to the old instance in any way. It is assumed that the contents placed into this SGEXTN container can be copied and moved. This means that their copy constructor copy assignment, move constructor, move assignment, and destructor work as expected. If this is not the case or if you want the container to store references or constant references, store pointers instead.
SGLUnorderedSet maintains an open addressed linear probing hash table with a load factor of 0.33 Due to the extremely low load factor, SGLUnorderedSet is much faster than most implementations of unordered map (especially the Standard Template Library one, which is not even open addressed) at the cost of higher memory usage. The hash table is stored in a C array memory buffer that triples in size when the load factor is reached.
Creates an empty SGLUnorderedSet.
Returns a iterator to the first element in the SGLUnorderedSet.
SGLUnorderedSet iterators behave circularly. This is equivalent to running operator++ on SGLUnorderedSet::end.
SGLUnorderedSet::Iterator allows modifying the SGLUnorderedSet through it. If modification is not needed, use SGLUnorderedSet::ConstIterator instead. The SGLUnorderedSet::ConstIterator equivalent to this function is SGLUnorderedSet::constBegin.
If the SGLUnorderedSet is empty, this is the same as SGLUnorderedSet::end.
Returns a constant iterator to the first element in the SGLUnorderedSet.
SGLUnorderedSet iterators behave circularly. This is equivalent to running operator++ on SGLUnorderedSet::constEnd.
If the SGLUnorderedSet is empty, this is the same as SGLUnorderedSet::constEnd.
Returns a null constant iterator associated to this SGLUnorderedSet.
SGLUnorderedSet iterators behave circularly. This is equivalent to running operator-- on SGLUnorderedSet::constBegin.
Attempting to access the element that this iterator points to will crash.
Returns if the SGLUnorderedSet contains x.
Returns the number of copies of x in the SGLUnorderedSet, this is either 0 or 1.
This has identical functionality to SGLUnorderedSet::contains, it is included for API consistency.
Returns a null iterator associated to this SGLUnorderedSet.
SGLUnorderedSet iterators behave circularly. This is equivalent to running operator-- on SGLUnorderedSet::begin.
SGLUnorderedSet::Iterator allows modifying the SGLUnorderedSet through it. If modification is not needed, use SGLUnorderedSet::ConstIterator instead. The SGLUnorderedSet::ConstIterator equivalent to this function is SGLUnorderedSet::constEnd.
Attempting to access the element that this iterator points to will crash.
Removes the element associated with x from the SGLUnorderedSet.
After the removal, x which is passed as a reference, is decremented. This means that you do not have to do any special handling for removed elements when iterating over a SGLUnorderedSet.
This returns false if x is SGLUnorderedSet::end and true otherwise.
Do not write any special logic to modify iterators while removing elements from a SGLUnorderedSet in a loop, SGLUnorderedSet::eraseSGLUnorderedSet::erase handles this for you automatically.
Removes x from the SGLUnorderedSet.
If the SGLUnorderedSet does not contain x, this function will return false, otherwise this returns true.
Returns the constant iterator pointing to element x.
SGLUnorderedSet::constEnd is returned if x is not in the SGLUnorderedSet.
Returns the iterator pointing to element x.
SGLUnorderedSet::end is returned if x is not in the SGLUnorderedSet.
Inserts x into the SGLUnorderedSet.
If the SGLUnorderedSet already contains x, this function will return false, otherwise this returns true.
Returns the length of the SGLUnorderedSet, which is the number of elements currently stored in the SGLUnorderedSet.
Pre allocates enough memory to store (newMemoryLength / 3) - 1 elements in the SGLUnorderedSet without resizing.
If the existing memory is sufficient, this does nothing.
©2025 05524F.sg (Singapore)