https://github.com/cogitatortech/ordered
A collection of data structures that keep data sorted by key (WIP)
https://github.com/cogitatortech/ordered
data-structures ordered-collections zig zig-library zig-package
Last synced: 5 months ago
JSON representation
A collection of data structures that keep data sorted by key (WIP)
- Host: GitHub
- URL: https://github.com/cogitatortech/ordered
- Owner: CogitatorTech
- License: mit
- Created: 2025-07-31T20:13:17.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-10-08T16:11:55.000Z (6 months ago)
- Last Synced: 2025-10-08T18:33:55.535Z (6 months ago)
- Topics: data-structures, ordered-collections, zig, zig-library, zig-package
- Language: Zig
- Homepage:
- Size: 2.67 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Ordered
[](https://github.com/CogitatorTech/ordered/actions/workflows/tests.yml)
[](https://github.com/CogitatorTech/ordered/actions/workflows/benches.yml)
[](https://www.codefactor.io/repository/github/CogitatorTech/ordered)
[](https://CogitatorTech.github.io/ordered/)
[](https://github.com/CogitatorTech/ordered/tree/main/examples)
[](https://ziglang.org/download/)
[](https://github.com/CogitatorTech/ordered/releases/latest)
[](https://github.com/CogitatorTech/ordered/blob/main/LICENSE)
A collection of data structures that keep data in order in pure Zig
---
Ordered is a Zig library that provides fast and efficient implementations of various popular data structures including
B-tree, skip list, trie, and red-black tree for Zig programming language.
### Supported Data Structures
Currently supported data structures include:
- [B-tree](src/ordered/btree_map.zig): A self-balancing search tree where nodes can have many children.
- [Sorted Set](src/ordered/sorted_set.zig): A data structure that stores a collection of unique elements in a consistently sorted order.
- [Skip List](src/ordered/skip_list.zig): A probabilistic data structure that uses multiple linked lists to create "express lanes" for fast, tree-like search.
- [Trie](src/ordered/trie.zig): A tree where paths from the root represent prefixes which makes it extremely fast for tasks like text autocomplete.
- [Red-black Tree](src/ordered/red_black_tree.zig): A self-balancing binary search tree that uses node colors to guarantee efficient operations.
- [Cartesian Tree](src/ordered/cartesian_tree.zig): A binary tree that uniquely combines a binary search tree property for its keys with a heap** property for its values.
| # | Data Structure | Build Complexity | Memory Complexity | Search Complexity |
|---|----------------|------------------|-------------------|----------------------|
| 1 | B-tree | $O(\log n)$ | $O(n)$ | $O(\log n)$ |
| 2 | Cartesian tree | $O(\log n)$\* | $O(n)$ | $O(\log n)$\* |
| 3 | Red-black tree | $O(\log n)$ | $O(n)$ | $O(\log n)$ |
| 4 | Skip list | $O(\log n)$\* | $O(n)$ | $O(\log n)$\* |
| 5 | Sorted set | $O(n)$ | $O(n)$ | $O(\log n)$ |
| 6 | Trie | $O(m)$ | $O(n \cdot m)$ | $O(m)$ |
- $n$: number of stored elements
- $m$: maximum length of a key
- \*: average case complexity
> [!IMPORTANT]
> Ordered is in early development, so bugs and breaking API changes are expected.
> Please use the [issues page](https://github.com/CogitatorTech/ordered/issues) to report bugs or request features.
---
### Getting Started
To be added.
---
### Documentation
You can find the API documentation for the latest release of Ordered [here](https://CogitatorTech.github.io/ordered/).
Alternatively, you can use the `make docs` command to generate the documentation for the current version of Ordered.
This will generate HTML documentation in the `docs/api` directory, which you can serve locally with `make serve-docs`
and view in a web browser.
### Examples
Check out the [examples](examples) directory for example usages of Ordered.
---
### Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to make a contribution.
### License
Ordered is licensed under the MIT License (see [LICENSE](LICENSE)).
### Acknowledgements
* The logo is from [SVG Repo](https://www.svgrepo.com/svg/469537/zig-zag-left-right-arrow) with some modifications.