本文整理汇总了C++中sid::String::hash方法的典型用法代码示例。如果您正苦于以下问题:C++ String::hash方法的具体用法?C++ String::hash怎么用?C++ String::hash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sid::String
的用法示例。
在下文中一共展示了String::hash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testHash
void StringTestCase::testHash()
{
CPPUNIT_ASSERT(Sid::String().hash() == 0);
CPPUNIT_ASSERT(Sid::String().hash(16) == 0);
CPPUNIT_ASSERT(Sid::String("").hash() == 0);
CPPUNIT_ASSERT(Sid::String("").hash(16) == 0);
CPPUNIT_ASSERT(Sid::String("fOo").hash(1024) != Sid::String("Foo").hash(1024));
{
Sid::String test = Sid::String::from("\xff\xf0\x00\x90",4);
Sid::String test2 = Sid::String::from("\xfb\xf0\x00\x90",4);
// !bwc! This hash seems to fare poorly with small differences, this is the
// smallest modulus (that is a power of two) that yields different results.
// The 19 least significant bits are identical. Might be worth considering
// updating the hash function with something a little nicer.
CPPUNIT_ASSERT(test.hash(0x080000) != test2.hash(0x080000));
}
}