hamt
hamt

SimonLSchlee/hamt

MIT

HAMT and StencilArrays implementation in Zig

2 2 0 0
1
build.zig.zon  build.zig 
View on Github  
Updated: 10:11:26 AM Mon Nov 25 2024 Size: 31KB Created: 1:55:02 AM Fri Nov 22 2024
Dependencies:
No known dependencies
Supports Zig Version 0.13.0
zig  fetch  --save  git+https://github.com/SimonLSchlee/hamt

HAMT and StencilArrays

A work-in-progress implementation of HAMTs (Hash Array Mapped Tries) and StencilArrays (StencilVectors) in Zig.

Based on the ideas presented in theses papers:

Description

HAMTs are bitwise tries that have a compact memory layout, they are useful data structures that can be used as a key-value mapping, they also can be used as a persistent data structure, which means that old versions keep working and different versions can share nodes, this can be useful to implement things like undo, or wherever it is helpful to keep old versions of a value, without having to create full copies manually.

This implementation contains dynamic variants for runtime usage with both pointer and index support, imperative and persistent (old versions stay valid) behavior based on user configuration.

It also has simplified static implementations that can be modified at comptime without needing an allocator and then frozen and queried at runtime.

If you have ideas for improvements, feel free to open an issue.

Docs

https://simonlschlee.github.io/hamt/

Examples

Take a look at src/example.zig for some example code, you can run this after cloning this repository by running zig run src/example.zig, the documentation also contains usage examples in the form of doc-tests.