|
Ocular Engine
|
#include <HashGenerator.hpp>
Public Member Functions | |
| uint32_t | getHash32 (std::string const &str) |
| uint64_t | getHash64 (std::string const &str) |
| uint32_t | getHash32 (std::string const &str, uint32_t last) |
| uint64_t | getHash64 (std::string const &str, uint64_t last) |
Generates 32 or 64-bit hash values from strings using the FNV-1A algorithm.
Internally, this class tracks the previous hash value (one 32 and one 64) to be used when computing a new hash. This is used to avoid collisions by generating different hashes for identical strings. Example:
getHash32("Hello World!") -> 3422776359
gethash32("Hello World!") -> 707894204
If one wants to create reproducible hashes, they can use the alternate getter methods which allow the specifying of their own last hash value. Example:
getHash32("Hello World!", 0) -> 3422776359
getHash32("Hello World!", 0) -> 3422776359
| uint32_t Ocular::Utils::HashGenerator::getHash32 | ( | std::string const & | str | ) |
Generates a 32-bit hash value from the specified string.
If you want to hash a non-string value (for example a spatial point like in Ocular::Math::Noise::WorleyNoise) you can use Ocular::Utils::StringComposer.
| [in] | str |
| uint32_t Ocular::Utils::HashGenerator::getHash32 | ( | std::string const & | str, |
| uint32_t | last | ||
| ) |
Generates a 32-bit hash value from the specified string. By specifying your own last value, you can create reproducible hash values.
| [in] | str | |
| [in] | last |
| uint64_t Ocular::Utils::HashGenerator::getHash64 | ( | std::string const & | str | ) |
Generates a 64-bit hash value from the specified string.
If you want to hash a non-string value (for example a spatial point like in Ocular::Math::Noise::WorleyNoise) you can use Ocular::Utils::StringComposer.
| [in] | str |
| uint64_t Ocular::Utils::HashGenerator::getHash64 | ( | std::string const & | str, |
| uint64_t | last | ||
| ) |
Generates a 64-bit hash value from the specified string. By specifying your own last value, you can create reproducible hash values.
| [in] | str | |
| [in] | last |