zig/lib/std/hash
Andrew Kelley cf88cf2657 std: make ArrayHashMap eql function accept an additional param
which is the index of the key that already exists in the hash map.

This enables the use case of using `AutoArrayHashMap(void, void)` which
may seem surprising at first, but is actually pretty handy!
This commit includes a proof-of-concept of how I want to use it, with a
new InternArena abstraction for stage2 that provides a compact way to
store values (and types) in an "internment arena", thus making types
stored exactly once (per arena), representable with a single u32 as a
reference to a type within an InternArena, and comparable with a
simple u32 integer comparison. If both types are in the same
InternArena, you can check if they are equal by seeing if their index is
the same.

What's neat about `AutoArrayHashMap(void, void)` is that it allows us to
look up the indexes by key, *without actually storing the keys*.
Instead, keys are treated as ephemeral values that are constructed as
needed.

As a result, we have an extremely efficient encoding of types and
values, represented only by three arrays, which has no pointers, and can
therefore be serialized and deserialized by a single writev/readv call.
The `map` field is denormalized data and can be computed from the other
two fields.

This is in contrast to our current Type/Value system which makes
extensive use of pointers.

The test at the bottom of InternArena.zig passes in this commit.
2022-01-31 01:20:45 -07:00
..
adler.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
auto_hash.zig std: make ArrayHashMap eql function accept an additional param 2022-01-31 01:20:45 -07:00
benchmark.zig allocgate: renamed getAllocator function to allocator 2021-11-30 23:32:47 +00:00
cityhash.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
crc.zig migrate from std.Target.current to @import("builtin").target 2021-10-04 23:48:55 -07:00
fnv.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
murmur.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
wyhash.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00