Expand description
wiki | Various hash functions for cards
The common FNV hashes are often used for implementing hash tables and doing quick checksumming for tests. They are not collision-free, but are fast and simple.
Positional hashes treat cards (or ranks) as digits of a base-64 (or base-16) number. They therefore order-dependent and limited in size, but inherently collision-free and useful for ranking hands.
Bitfield hashes represent each card as a bit in a 64-bit integer. This is inherently collision-free and order-independent, and very fast, but can’t handle duplicate cards and produces huge numbers.
Prime hashes based on the product of prime numbers are inherently collision-free, order-independent, handle duplicates, and produce smaller numbers, but can only handle very small sets.
The “mp” functions convert a bitfield to a minimal perfect hash, and are very specific to number of cards and type of deck.
Functions§
- wiki | 64-bit bitfield hash
- wiki | 32-bit FNV-1a hash
- wiki | 64-bit FNV-1a hash
- wiki | Convert bitfield to MPH Given a bitfield with exactly 5 bits set, return the lexicographic index of that particular set of bits for minimal perfect hash.
- wiki | 32-bit positional hash
- wiki | 32-bit positional rank hash
- wiki | 64-bit positional hash
- wiki | 64-bit positional rank hash
- wiki | 32-bit prime rank hash
- wiki | 64-bit prime hash
- wiki | 64-bit prime rank hash