Skip to main content

Module hash

Module hash 

Source
Expand description

Specialized hash containers.

Two keys in this crate already carry enough entropy to skip the default hasher:

  • Entity is a pair of integers packed into one u64. EntityHash spreads that value upward with a Fibonacci multiply, which is where the SwissTable needs the bits, while leaving the low bits so that entities spawned together land together.
  • TypeId is itself a high-quality hash, so TypeIdHashMap uses NoOpHash and NoOpHasher forwards the u64 the Hash impl writes.

EntityHasher panics on a key that is not u64-shaped, which is a programming error in this crate’s own use of it. NoOpHasher does not: it folds byte-wise writes rather than panicking, so a container that hashes a non-u64 key still works, if with a worse hash.

Re-exportsΒ§

use core::any::TypeId; πŸ”’
use core::hash::BuildHasher; πŸ”’
use core::hash::Hash; πŸ”’
use core::hash::Hash; πŸ”’
use core::hash::Hasher; πŸ”’
use hashbrown::HashMap; πŸ”’
use hashbrown::HashSet; πŸ”’
use crate::entity::Entity; πŸ”’

StructsΒ§

EntityHash
A BuildHasher for generational indices.
EntityHasher
The hasher of EntityHash.
NoOpHash
A BuildHasher that passes u64 keys through unchanged.
NoOpHasher
The hasher of NoOpHash.

Type AliasesΒ§

EntityHashMap
A hash map keyed by Entity.
EntityHashSet
A hash set of Entitys.
TypeIdHashMap
A hash map keyed by TypeId.
TypeIdHashSet
A hash set of TypeIds.