Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

iacore/tree.zig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zig rewrite of trees from OpenBSD.

Data structures ported

  • splay tree
  • red-black tree (you may want to use AVL tree instead)

Usage

See src/main.zig for usage.

To use this library in your project, copy the file into your project and rename it as tree.zig or something.

Note about splay tree

There is potential footgun when freeing nodes of a tree. See test "how to free nodes correctly" in src/main.zig for correct usage.

Enhancements over the original:

  • proper generic type
  • tree.prev(node)

Also, the original C impl has some weird design choices, which I will not touch.

Also, invalid data given to the public API will not crash the program.

About

tree.h from OpenBSD, ported to Zig

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published