2016-08-17 18:45 GMT+02:00 silvioprog :
Show quoted text 8 lines
I changed it to a function:
function ExtendedHasher(constref AValue: string): UInt32;
begin
TDefaultHashFactory.GetHashList(Pointer(AValue),
Length(AValue) * SizeOf(Char), @Result);
end;
Still bad implementation (see my previous message). Is highly probable to obtain different hashes for 'foo' and 'Foo'. Usage of GetHashList in that context is also improper, GetHashList is generally dedicated for more complicated structures (for example for cuckoo hashing). The proper code is:
function MyHasher(constref AValue: string): UInt32;
var
temp: string;
begin
temp := LowerCase(AValue);
Result := TDefaultHashFactory.GetHashCode(Pointer(temp), Length(temp) *
SizeOf(Char), 0);
end;
Show quoted text 5 lines
because the "Error: Incompatible type for arg no. 2: Got
"ExtendedHasher(constref AnsiString;PDWord);", expected "<procedure
variable type of function(constref AnsiString):DWord;Register>"".
Point for you, that was code from my memory, sorry ;) ExtendedHasher in presented form is dedicated for TExtendedEqualityComparer<T>.Construct(...) which is used for THashMap<K,V> (THashMap is much faster than TDictionary for big data)
Best regards,
Maciej Izak