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 K, typename V, typename EqualityCheck, typename HashFunction› class SGLUnorderedMap;
part of SGEXTN module SG_Containers
unordered map for any type of data
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGLUnorderedMap.h›
CMake target for BuildLah: SGEXTN::SG_Containers
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
[[nodiscard]] V& at(const K& x);
[[nodiscard]] const V& at(const K &x) const;
[[nodiscard]] SGLUnorderedMap::Iterator begin();
[[nodiscard]] SGLUnorderedMap::ConstIterator constBegin() const;
[[nodiscard]] SGLUnorderedMap::ConstIterator constEnd() const;
[[nodiscard]] bool contains(const K& x) const;
[[nodiscard]] int count(const K& x) const;
[[nodiscard]] SGLUnorderedMap::Iterator end();
bool erase(SGLUnorderedMap::Iterator& x);
bool erase(const K& x);
[[nodiscard]] SGLUnorderedMap::Iterator find(const K& x);
[[nodiscard]] SGLUnorderedMap::ConstIterator find(const K& x) const;
bool insert(const K& xKey, const V& xValue);
[[nodiscard]] int length() const;
void reserve(int newMemoryLength);
SGLUnorderedMap provides a template based unordered map that can be used with any data type. Use SGLMap instead if ordering matters. SGEXTN does not provide any unordered multimap so you must use a SGLMap‹K, SGLVector‹V››. 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.
SGLUnorderedMap maintains an open addressed linear probing hash table with a load factor of 0.33 Due to the extremely low load factor, SGLUnorderedMap 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 SGLUnorderedMap.
Returns a reference to the value associated with key x in the SGLUnorderedMap.
Since this returns a reference and not a copy, assigning to it directly (using it as a lvalue) would modify the SGLUnorderedMap.
This will crash if x is not in the SGLUnorderedMap. Use SGLUnorderedMap::contains to check if x is in the SGLUnorderedMap if unsure.
Returns a constant reference to the value associated with key x in the SGLUnorderedMap.
This will crash if x is not in the SGLUnorderedMap. Use SGLUnorderedMap::contains to check if x is in the SGLUnorderedMap if unsure.
Returns a iterator to the first key value pair in the SGLUnorderedMap.
SGLUnorderedMap iterators behave circularly. This is equivalent to running operator++ on SGLUnorderedMap::end.
SGLUnorderedMap::Iterator allows modifying the SGLUnorderedMap through it. If modification is not needed, use SGLUnorderedMap::ConstIterator instead. The SGLUnorderedMap::ConstIterator equivalent to this function is SGLUnorderedMap::constBegin.
If the SGLUnorderedMap is empty, this is the same as SGLUnorderedMap::end.
Returns a constant iterator to the first key value pair in the SGLUnorderedMap.
SGLUnorderedMap iterators behave circularly. This is equivalent to running operator++ on SGLUnorderedMap::constEnd.
If the SGLUnorderedMap is empty, this is the same as SGLUnorderedMap::constEnd.
Returns a null constant iterator associated to this SGLUnorderedMap.
SGLUnorderedMap iterators behave circularly. This is equivalent to running operator-- on SGLUnorderedMap::constBegin.
Attempting to access the key or value that this iterator points to will crash.
Returns if the SGLUnorderedMap contains x as a key
Returns the number of copies of the key x is found inside the SGLMap.
This is either 0 or 1, functionally identical to SGLUnorderedMap::contains. It is provided purely for API consistency.
Returns a null iterator associated to this SGLUnorderedMap.
SGLUnorderedMap iterators behave circularly. This is equivalent to running operator-- on SGLUnorderedMap::begin.
SGLUnorderedMap::Iterator allows modifying the SGLUnorderedMap through it. If modification is not needed, use SGLUnorderedMap::ConstIterator instead. The SGLUnorderedMap::ConstIterator equivalent to this function is SGLUnorderedMap::constEnd.
Attempting to access the key or value that this iterator points to will crash.
Removes the key value pair associated with x from the SGLUnorderedMap.
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 SGLUnorderedMap.
This return false if x is SGLUnorderedMap::end and true otherwise.
Do not write any special logic to modify iterators while removing elements from a SGLUnorderedMap in a loop, SGLUnorderedMap::eraseSGLUnorderedMap::erase handles this for you automatically.
Removes the key x and its associated value from the SGLUnorderedMap.
If x is not in the SGLUnorderedMap, this will return false, otherwise this returns true.
Returns the iterator pointing to key x.
SGLUnorderedMap::end is returned if x is not in the SGLUnorderedMap.
Returns the constant iterator pointing to key x.
SGLUnorderedMap::constEnd is returned if x is not in the SGLUnorderedMap.
Inserts the key value pair (xKey, xValue) into the SGLUnorderedMap.
If xKey already exists in the SGLUnorderedMap, this will return false, otherwise this returns true.
Returns the length of the SGLUnorderedMap, which is the number of key value pairs currently stored inside it.
Pre allocates enough space for (newMemoryLength / 3) - 1 elements to be stored in the SGLUnorderedMap without exceeding the load factor.
If there is already sufficient memory allocated, this is ignored.
©2025 05524F.sg (Singapore)