https://github.com/raviqqe/hamt
Immutable and Memory-Efficient Maps and Sets in Go
https://github.com/raviqqe/hamt
functional-programming go hamt immutable map set
Last synced: 5 months ago
JSON representation
Immutable and Memory-Efficient Maps and Sets in Go
- Host: GitHub
- URL: https://github.com/raviqqe/hamt
- Owner: raviqqe
- License: unlicense
- Created: 2017-10-29T02:13:23.000Z (almost 8 years ago)
- Default Branch: v2
- Last Pushed: 2025-03-25T08:42:19.000Z (7 months ago)
- Last Synced: 2025-04-08T18:19:36.935Z (6 months ago)
- Topics: functional-programming, go, hamt, immutable, map, set
- Language: Go
- Homepage:
- Size: 133 KB
- Stars: 240
- Watchers: 8
- Forks: 13
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hamt
[](https://github.com/raviqqe/hamt/actions)
[](https://codecov.io/gh/raviqqe/hamt)
[](https://goreportcard.com/report/github.com/raviqqe/hamt)
[][unlicense]> For the old `any`-based API, refer to [the `main` branch](https://github.com/raviqqe/hamt/tree/main).
Immutable and Memory Efficient Maps and Sets in Go.
This package `hamt` provides immutable collection types of maps (associative arrays)
and sets implemented as Hash-Array Mapped Tries (HAMTs).
All operations of the collections, such as insert and delete, are immutable and
create new ones keeping original ones unmodified.[Hash-Array Mapped Trie (HAMT)](https://en.wikipedia.org/wiki/Hash_array_mapped_trie)
is a data structure popular as a map (a.k.a. associative array or dictionary)
or set.
Its immutable variant is adopted widely by functional programming languages
like Scala and Clojure to implement immutable and memory-efficient associative
arrays and sets.## Installation
```
go get github.com/raviqqe/hamt/v2
```## Documentation
[GoDoc](https://godoc.org/github.com/raviqqe/hamt/v2)
## Technical notes
The implementation canonicalizes tree structures of HAMTs by eliminating
intermediate nodes during delete operations as described
in [the CHAMP paper][champ].## References
- [Ideal Hash Trees](https://infoscience.epfl.ch/record/64398/files/idealhashtrees.pdf)
- [Optimizing Hash-Array Mapped Tries for Fast and Lean Immutable JVM Collections][champ]## License
[The Unlicense][unlicense]
[champ]: https://michael.steindorfer.name/publications/oopsla15.pdf
[unlicense]: https://unlicense.org/