// Вычисляю простое число соразмерное величине таблицы. В твоём случае - соразмерное разрядности ключа. function PJWHash(const aKey: string; aTableSize: integer): integer; var G: longint; i: integer; Hash: longint; begin Hash := 0; for i := 1 to Length(akey) do begin Hash := (Hash shl 4)+ord(aKey[i]); G := Hash and longint($F0000000); if (G <> 0) then Hash := (Hash xor (G shr 24)) xor G; end; Result := Hash mod aTableSize; end; // Собственно сам алгоритм. procedure ThiHashTableString._work_doKey; var Key:string; ind, KIndex:integer; begin aKey := ReadString(_Data,_data_Keystr); KIndex:=PJWHash(aKey,aTableSize); ind:= HashTable[0,KIndex]; // Key:=RuleLeft(FList.Items[ind]); // В твоём случае Key:=FList.Items[ind]; // Ниже проверяем на повторение ключа, если есть, то достраеваем дополнительную таблицу для повторов. if 0=AnsiCompareStr(aKey,Key) then begin _hi_CreateEvent(_Data, @_event_onString,RuleRight(FList.Items[ind])); FIndex:=ind; FString:=FList.Items[ind]; // _hi_OnEvent(_event_onString,RuleRight(FList.Items[ind])); exit; end else begin While HashTable[1,KIndex] > -1 do begin KIndex:=HashTable[1,KIndex]; ind:=HashTable[0,KIndex]; Key:=RuleLeft(FList.Items[ind]); if 0=AnsiCompareStr(aKey,Key) then begin _hi_CreateEvent(_Data, @_event_onString,RuleRight(FList.Items[ind])); FIndex:=ind; FString:=FList.Items[ind]; // _hi_OnEvent(_event_onString,RuleRight(FList.Items[ind])) ; exit; end end; // _hi_OnEvent(_event_onFalse,aKey); _hi_CreateEvent(_Data, @_event_onFalse); end