Utilities · zero-dependency · MIT

larzstruct

Essential data structures.

Bloom filter, disjoint-set (union-find) and ring buffer — the specialised data structures not big enough to deserve their own package. (A trie is its own package - trie - reused elsewhere, not duplicated here.)

larzscript pkg install struct
View on GitHub →Learn the stack

What you get

Try it

import "struct" as ds
let bf = ds.bloom_new(1000, 3)
ds.bloom_add(bf, "hello")
print(ds.bloom_might_contain(bf, "hello"))
print(ds.bloom_might_contain(bf, "nope"))
let dset = ds.dsu_new(5)
ds.dsu_union(dset, 0, 1)
print(ds.dsu_connected(dset, 0, 1))
print(ds.dsu_connected(dset, 0, 2))
let rb = ds.ring_new(3)
ds.ring_push(rb, 1); ds.ring_push(rb, 2); ds.ring_push(rb, 3); ds.ring_push(rb, 4)
print(ds.ring_to_list(rb))
Output
true
false
true
false
[2, 3, 4]

Why it's in the Larz Stack

larzstruct is a real Larzscript package (larzscript pkg install struct) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.