Module onejoker::cards::hashes

source ·
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§