// File Names
bool HashCmpKeyFun::HashFun_CompareKeyWord_FileName( const void* pKeyWord1, const unsigned long nKeyWordLen1, 
													 const void* pKeyWord2, const unsigned long nKeyWordLen2 )
{
	char *pEndKey1, *pKey1, *pKey2;

	if( nKeyWordLen1 != nKeyWordLen2 )
	{
		return false;
	}

	pKey1 = (char*)pKeyWord1;
	pKey2 = (char*)pKeyWord2;
	pEndKey1 = pKey1 + nKeyWordLen1;
	
	while(pKey1 < pEndKey1)
	{
		if(hs_FilenameChar(*pKey1) != hs_FilenameChar(*pKey2))
		{
			return false;
		}

		++pKey1;
		++pKey2;
	}

	return true;
}
Example #2
0
static int hs_CompareKey_Filename(void *pData1, void *pData2, uint32 dataLen)
{
	char *pEndKey1, *pKey1, *pKey2;

	pKey1 = (char*)pData1;
	pKey2 = (char*)pData2;
	pEndKey1 = pKey1 + dataLen;
	
	while(pKey1 < pEndKey1)
	{
		if(hs_FilenameChar(*pKey1) != hs_FilenameChar(*pKey2))
			return 0;

		++pKey1;
		++pKey2;
	}

	return 1;
}
Example #3
0
static uint32 hs_GetCode_Filename(const void *pData, uint32 dataLen)
{
	char *pCurByte;
	uint32 sum, i;

	sum = 0;

	pCurByte = (char*)pData;
	for(i=0; i < dataLen; i++)
	{
		sum += ((uint32)hs_FilenameChar(*pCurByte)) * i;
		++pCurByte;
	}

	return sum;
}
// 计算一个文件名序列的 Code
// 
// 计算所有字符(如果是字母则转换为大写)的 ASCII 码数值与位置索引的乘积
// 的和
unsigned long HashFun::HashFun_GenerateCode_FileName( const void* pKeyWord, const unsigned long nKeyWordLen )
{
	char *pCurByte;
	unsigned long sum, i;

	sum = 0;

	char* szKeyWord = (char*)pKeyWord;
	unsigned long dataLen = strlen( szKeyWord );
	pCurByte = (char*)szKeyWord;
	for( i=0; i < dataLen; i++ )
	{
		sum += ((unsigned long)hs_FilenameChar(*pCurByte)) * i;
		++pCurByte;
	}

	return sum;
}