键名(字符串)包装器,内部存储着一个
using value_type = std::uint64_t;
字符串哈希值的类型,是一个占
static constexpr value_type base;
BKDRHash 算法需要的进制数。
static constexpr value_type mod;
BKDRHash 算法需要的模数。
template<std::size_t _Size>
constexpr KwargsKey(const char (&__str)[_Size]) noexcept
使用字符串字面量构造。
constexpr KwargsKey(const char* const __str, std::size_t __size) noexcept
使用字符串指针构造。
Warning
\0
结束符,否则 \0
也将一起参与哈希计算。
constexpr explicit KwargsKey(value_type __option) noexcept
直接使用计算后的哈希值进行构造(不推荐使用)。
在原有的字符串哈希值的基础上,在末尾再次添加一个字符并重新计算哈希值。
constexpr void pushBack(char __c) noexcept
推入一个字符。
template<typename... _Args>
constexpr void pushBack(char __c, _Args&&... __args) noexcept
一次性推入多个字符。
示例:
KwargsKey key("Hel");
key.pushBack('l', 'o');
// 此时 key 中的字符串哈希值同等于 "Hello" 的哈希值。
constexpr operator value_type() const noexcept
返回哈希值。
constexpr bool operator==(KwargsKey __other) const noexcept
比较字符串的哈希值是否相等。
Warning
哈希算法可能会发生 哈希碰撞,两个不相等的字符串的哈希值在极小概率的情况下也有可能会相同,但是两个相同的字符串的哈希值一定相同。
constexpr bool operator<(KwargsKey __other) const noexcept