Discovering the term "Hash Map" or "Associative array" in these different threads:
Multi-pattern searching
Hash-Map vs LL
Associative arrays
...I try to find a code which calculates the fingerprint of a string. Actually Crc32 is a very good method but I think we could accelerate this operation.
So, I suggest a code I update these days.
>> In an associative array, when we want to declare, check or remove an element, we give the string to a fingerprint procedure (usually Crc32). This procedure loses time to calculate the fingerprint. If we are able to accelerate this calculation, we accelerate too the general data base access.
This code "digests" a message (= a null terminal string) cutting it, double word after double word (= a long variable). Each double word is "xored" (logical operation) with a global double word which is used as result of the procedure.
The last operation consists to reduce the double word (4 bytes) into a 24bits sized number (3 bytes). I extract the first byte (bits 24 to 31), "xor" it with the 3 others bytes and remove it.
Reading definition of Crc overview, my method is "archaic". But testing its speed and the little number of collisions I get, I think it's a possible choice.
So, I hope I am clear and I am sorry for the langage errors.
I'll add an little example.
Code: Select all
Procedure.L MD24(St.S)
Protected Length.I
Protected Result.L
Protected Stamp.I
Protected Dest.I
Length = Len(St)
St + " " ; Allocate 4 bytes
*Adr = @St
PokeL(*Adr + Length, 0) ; reset these 4 bytes
Dest = *Adr + Length - 1
For I = *Adr To Dest Step 4
Result ! PeekL(I)
Next I
; last operation
Stamp = Result & $FF000000
Stamp >> 8
Result ! Stamp
Stamp >> 8
Result ! Stamp
Stamp >> 8
Result ! Stamp
Result & $FFFFFF
ProcedureReturn Result
EndProcedure
Structure CamX
*Ptr[1 << 24]
EndStructure
CamX.CamX