lily/docs/spec/hash.md
koniifer fd42e53ae5 lots of work again (mostly broken on libc target)
implement foldhash
implement hashmap
squash & log some more bugs
clean up Target & Config interfaces
add rudimentary math functions
extract allocators to new directory
implement vec.get_ref
fix capitalisation
document some of lily's type spec
2025-01-10 19:32:27 +00:00

901 B

hashers

  1. hashers must not allocate on the heap.
  2. all spec compliant hashers should implement:

unless otherwise stated, functions can be optionally inline.
names of arguments are up to programmer discretion.
names and signature of functions must be identical to shown below.

Hasher := struct {
    new := fn(seed: SeedType): Self
    /// prepare to be deallocated
    deinit := fn(self: ^Self): void
    /// should always use a constant or randomised seed
    /// randomised seeds should (for now) use lily.Target.getrandom()
    /// never use values from the environment
    default := fn(): Self
    /// pointers: treat as uint
    /// slices: read bytes and hash
    /// other: hash bytes directly
    write := fn(self: ^Self, any: @Any()): void
    /// should not reset the state of the hasher
    finish := fn(self: ^Self): uint
    reset := fn(self: ^Self): void
}