namespace Dali
{
+namespace //un-named namespace
+{
/*
* djb2 (http://www.cse.yorku.ca/~oz/hash.html)
*/
-unsigned long StringHash::operator()(const std::string& toHash)
-{
- unsigned long hash = 5381;
+const unsigned long INITIAL_HASH_VALUE = 5381;
- const char *str = toHash.c_str();
-
- while( int c = *str++ )
+inline void HashShader( const char* string, unsigned long& hash )
+{
+ while( int c = *string++ )
{
- hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
+ hash = hash * 33 + c;
}
+}
+} // un-named namespace
+
+unsigned long CalculateHash(const std::string& toHash)
+{
+ unsigned long hash = INITIAL_HASH_VALUE;
+
+ HashShader( toHash.c_str(), hash );
return hash;
}
+unsigned long CalculateHash(const std::string& string1, const std::string& string2)
+{
+ unsigned long hash = INITIAL_HASH_VALUE;
+
+ HashShader( string1.c_str(), hash);
+ HashShader( string2.c_str(), hash );
+ return hash;
+}
+
+
+
+
} // namespace Dali