2016-08-17 18:45 GMT+02:00 silvioprog <silviop...@gmail.com>: > 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; > 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
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal