/* Copyright (c) Microsoft Corporation All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. */ // // Fast, thorough hash functions returning 32 or 64 bit results. // // You can use hash table sizes that are a power of 2, and use & to // trim values, for example: // LOGSIZE=10; // Buckets *hash_table[(1<> 32), &uHash1, &uHash2); return uHash1 | (((UInt64)uHash2) << 32); } // // case-insensitive hash of null terminated string // produce the same hash as Compute on an uppercased string // static const UInt64 StringI ( const char *pString, Size_t uSize, UInt64 uSeed) { UInt32 uHash1, uHash2; DrHash32::StringI2( pString, uSize, (UInt32) uSeed, (UInt32) (uSeed >> 32), &uHash1, &uHash2); return uHash1 | (((UInt64)uHash2) << 32); } // Compute a 64-bit hash of a GUID static const UInt64 Guid ( const GUID *pGuid ) { UInt32 a = ((UInt32 *)pGuid)[0]; UInt32 b = ((UInt32 *)pGuid)[1]; UInt32 c = ((UInt32 *)pGuid)[2]; DrHash32::Mix(a,b,c); a ^= ((UInt32 *)pGuid)[3]; DrHash32::Final(a,b,c); return c | (((UInt64)b) << 32); } }; #pragma pack (pop) //JC} // namespace apsdk #ifdef USING_APSDK_NAMESPACE using namespace apsdk; #endif