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› class SGLHash;
part of SGEXTN module SG_Containers
Hash function struct for use with SGEXTN Containers
list of all including inherited members
preprocessor file inclusion directive: #include ‹SGLHash.h›
CMake target for BuildLah: SGEXTN::SG_Containers
see this link for more information about BuildLah
parent class: (none)
children classes: (none)
[[nodiscard]] int operator()(const T& x) const;
SGLHash provides a hash function struct for use with SGEXTN Containers, this should be used most of the time when using SGLUnorderedSet, SGLUnorderedMultiSet, or SGLUnorderedMap. You need hash() defined to use SGLEqualsTo with custom structs. SGLHash works with all object pointers and C++ builtin types although they do not define hash(). This is a template based class with no separate source file.
SGLHash calls hash() on the corresponding data type if it is a custom struct. If it is a C++ builtin type or a object pointer, SGLHash is implemented separately but still works. Implementations of hash() use SGLHashAlgorithm.
Returns the hash of x.
This is internally used by SGLUnorderedSet, SGLUnorderedMultiSet, and SGLUnorderedMap when SGLHash is selected as the hash function struct.
The presense of operator() makes SGLHash a functor.
Correct implementations of hash() must return a int, not a unsigned int.
For good hash function quality, implementations of hash() for custom structs should use SGLHashAlgorithm.
Due to padding, attempting to hash the entire memory of custom structs is undefined behaviour. Instead hash only the defined fields.
This will not compile if hash() is not defined for T. Check the source code of any SGEXTN struct (SGXChar, SGXString, SGXColourRGBA, SGXColourHSLA, SGXIdentifier, SGXTimeStamp, SGXVector2) to see how to define hash().
©2025 05524F.sg (Singapore)