最好用的Hash

uint32_t  hashCode(const char * guid)
{
	const  char *keys = guid;
	uint32_t hash = 0;
	uint32_t size = strlen(keys);
	for (uint32_t i = 0; i < size; i++)
	{
		hash += (uint32_t)keys[i];
		hash += (hash << 10);
		hash ^= (hash >> 6);
	}
	hash += (hash <<  3);
	hash ^= (hash >> 11);
	hash += (hash << 15);

	return hash;
}

猜你喜欢

转载自blog.csdn.net/Swallow_he/article/details/88901244