Hello
Is there somewhere the hash algorithm string::hash is explained?
Thanks
Peter
-
- VIP Member
- Posts: 1469
- Joined: 28 Feb 2000 0:01
Re: hash algorithm
The hash algorithm is not "constant", we may decide to change it to another one.
Currently it is MurmurHash2A.
I'm not really sure what information you want, so just ask more if it is something else you want to know.
Currently it is MurmurHash2A.
I'm not really sure what information you want, so just ask more if it is something else you want to know.
Regards Thomas Linder Puls
PDC
PDC
-
- Posts: 10
- Joined: 7 May 2024 12:02
Re: hash algorithm
Thanks Thomas.
I was looking to create a hash table of words of text and found the hash function in PFC. I've looked the hash algorithm up on-line and have the information I need at present.
I was stumped by the issue of unsigned vs integer as the hash function returns unsigned. I thought the compiler should convert automatically. I programmed my way around the issue.
I've done assembly level programming on several different computer types and don't recall computers with both signed and unsigned integer instructions. I did use one system with an instruction that counted bits set in a machine word which was very useful in one project. I wonder if unsigned operations are more complex at a machine instruction level.
Thanks for answering questions by users such as myself. But perhaps that is in your JD.
Peter
I was looking to create a hash table of words of text and found the hash function in PFC. I've looked the hash algorithm up on-line and have the information I need at present.
I was stumped by the issue of unsigned vs integer as the hash function returns unsigned. I thought the compiler should convert automatically. I programmed my way around the issue.
I've done assembly level programming on several different computer types and don't recall computers with both signed and unsigned integer instructions. I did use one system with an instruction that counted bits set in a machine word which was very useful in one project. I wonder if unsigned operations are more complex at a machine instruction level.
Thanks for answering questions by users such as myself. But perhaps that is in your JD.
Peter
-
- VIP Member
- Posts: 1469
- Joined: 28 Feb 2000 0:01
Re: hash algorithm
Did you notice that pfc already have a "hash table" for "strings (and also for anything else you provide a hash table for):
There is a corresponding "set" in case you don't need to attach data to the words.
Visual Prolog distinguishes between integers and unsigned and since some unsigned are too large to be converted to an integer the conversion and some integers are too small to be converted to unsigned there is no automatic/implicit conversion.
Some CPU-operations are the same for signed and unsigned, but overflow detection is different (and Visual Prolog performs overflow detection). Furthermore, multiplication and division have different operations for signed and unsigned.
Code: Select all
class mapM_hash{@Key, @Value} : mapM_hash{@Key, @Value}
open core
...
predicates
new_string : () -> mapM_hash{string, A} HashMap.
% @short Create a hash map for string keys.
% @end
end class mapM_hash
Visual Prolog distinguishes between integers and unsigned and since some unsigned are too large to be converted to an integer the conversion and some integers are too small to be converted to unsigned there is no automatic/implicit conversion.
Some CPU-operations are the same for signed and unsigned, but overflow detection is different (and Visual Prolog performs overflow detection). Furthermore, multiplication and division have different operations for signed and unsigned.
Regards Thomas Linder Puls
PDC
PDC