All Projects → travisstaloch → art.zig

travisstaloch / art.zig

Licence: MIT License
An Adaptive Radix Tree ported from c

Programming Languages

Zig
133 projects

Projects that are alternatives of or similar to art.zig

zgt
Zig GUI Toolkit: Portable library for making native GUIs in Zig
Stars: ✭ 218 (+522.86%)
Mutual labels:  zig-library, zig-package
zetaframe
lightweight zig game framework.
Stars: ✭ 14 (-60%)
Mutual labels:  zig-library, zig-package
SDL.zig
A shallow wrapper around SDL that provides object API and error handling
Stars: ✭ 102 (+191.43%)
Mutual labels:  zig-package
zig-opengl
OpenGL binding generator based on the opengl registry
Stars: ✭ 29 (-17.14%)
Mutual labels:  zig-package
qml zig
QML bindings for the Zig programming language
Stars: ✭ 25 (-28.57%)
Mutual labels:  zig-package
zero-graphics
Application framework based on OpenGL ES 2.0. Runs on desktop machines, Android phones and the web
Stars: ✭ 72 (+105.71%)
Mutual labels:  zig-package
zig-eddsa-key-blinding
A Zig implementation of EdDSA signatures with blind keys.
Stars: ✭ 15 (-57.14%)
Mutual labels:  zig-package
zig-header-gen
Automatically generate headers/bindings for other languages from Zig code
Stars: ✭ 40 (+14.29%)
Mutual labels:  zig-library
zacho
Zig's Mach-O parser
Stars: ✭ 27 (-22.86%)
Mutual labels:  zig-package
zbox
termbox like terminal UI library for zig
Stars: ✭ 30 (-14.29%)
Mutual labels:  zig-package
zigdig
naive dns client library in zig
Stars: ✭ 26 (-25.71%)
Mutual labels:  zig-package
mach-glfw
Ziggified GLFW bindings with 100% API coverage, zero-fuss installation, cross compilation, and more.
Stars: ✭ 186 (+431.43%)
Mutual labels:  zig-package
sdk
TinyVG software development kit
Stars: ✭ 135 (+285.71%)
Mutual labels:  zig-package
zlm
Zig linear mathemathics
Stars: ✭ 67 (+91.43%)
Mutual labels:  zig-package
zig-args
Simple-to-use argument parser with struct-based config
Stars: ✭ 106 (+202.86%)
Mutual labels:  zig-package
mecha
A parser combinator library for Zig
Stars: ✭ 220 (+528.57%)
Mutual labels:  zig-package
zigimg
Zig library for reading and writing different image formats
Stars: ✭ 112 (+220%)
Mutual labels:  zig-library
ansi-term
Zig library for dealing with ANSI terminals
Stars: ✭ 25 (-28.57%)
Mutual labels:  zig-package
IUPforZig
IUP (Portable User Interface Toolkit) bindings for the Zig language.
Stars: ✭ 56 (+60%)
Mutual labels:  zig-package

Features

This library provides a zig implementation of the Adaptive Radix Tree or ART. The ART operates similar to a traditional radix tree but avoids the wasted space of internal nodes by changing the node size. It makes use of 4 node sizes (4, 16, 48, 256), and can guarantee that the overhead is no more than 52 bytes per key, though in practice it is much lower. As a radix tree, it provides the following:

  • O(k) operations. In many cases, this can be faster than a hash table since the hash function is an O(k) operation, and hash tables have very poor cache locality.
  • Minimum / Maximum value lookups
  • Prefix compression
  • Ordered iteration
  • Prefix based iteration

NOTES:

taken from armon/libart

the memory footprint described here is unverified

Usage

See src/test_art.zig

Important Notes

This library accepts zig string slices ([:0]const u8) which means they are required to be null terminated.

Build

# creates zig-cache/lib/libart.a
# debug
$ zig build 

# release
$ zig build -Drelease-safe # or release-fast or release-small

Test

$ zig build test

Run repl

$ zig run src/art.zig -lc

REPL

The repl is very simple and responds to these commands:

  • :q - quit
  • key - adds 'key' with value = tree.size
  • key number - adds key with value = parse(number)
  • d:key - deletes key
  • :r - reset (destroy and then init) the tree

A representation of the tree will be printed after each operation.

Benchmarks

This simple benchark consists of inserting, searching for and deleting each line from testdata/words.txt (235886 lines). Benchmarks are compiled with --release-fast.

vs StringHashMap

(from zig's standard library) can be found here src/test_art.zig.

The results of the benchark on my machine:

Art           insert 507ms, search 481ms, delete 495ms, combined 1484ms
StringHashMap insert 487ms, search 482ms, delete 485ms, combined 1456ms
Operation % difference
insert 04.1% slower
search 00.2% faster
delete 02.0% slower
combined 01.9% slower

vs armon/libart

Can be found src/clibart.zig

art.zig insert 505ms, search 482ms, delete 494ms, combined 1481ms
art.c   insert 494ms, search 481ms, delete 484ms, combined 1459ms
Operation % difference
insert 2.22% slower
search 0.20% slower
delete 2.06% slower
combined 1.50% slower

References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].