Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/canscale/StableRBTree
Stable Red Black Trees in Motoko
https://github.com/canscale/StableRBTree
Last synced: 3 months ago
JSON representation
Stable Red Black Trees in Motoko
- Host: GitHub
- URL: https://github.com/canscale/StableRBTree
- Owner: canscale
- License: apache-2.0
- Created: 2022-03-09T04:47:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-15T16:21:26.000Z (over 1 year ago)
- Last Synced: 2024-08-03T00:14:17.838Z (6 months ago)
- Language: Motoko
- Size: 35.2 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-motoko - Stable Red-Black Trees - (Heap-based) Stable Red-Black Trees in Motoko. (Libraries / Data structures)
- awesome-motoko - Stable Red-Black Trees - (Heap-based) Stable Red-Black Trees in Motoko. (Libraries / Data structures)
README
# StableRBTree
Stable Red Black Trees in Motoko.
## Motivation
Inspiration taken from [this back and forth in the Dfinity developer forums](https://forum.dfinity.org/t/clarification-on-stable-types-with-examples/11075).## API Documentation
API documentation for this library can be found at https://canscale.github.io/StableRBTree
## StableRBTree
This module is a direct deconstruction of the object oriented [RBTree.mo class in motoko-base]
(https://github.com/dfinity/motoko-base/blob/master/src/RBTree.mo)
into a series of functions and is meant to be persistent across updates, with the tradeoff
being larger function signatures.## Usage
Install vessel and ensure this is included in your package-set.dhall and vessel.dhall
```
import RBT "mo:stableRBT/StableRBTree";
...// immutable updates
let t = RBT.init();
let nt = RBT.put(t, Text.compare, "John", 52);// or mutable updates
var t = RBT.init();
t := RBT.put(t, Text.compare, "John", 52);
```## License
StableRBTree is distributed under the terms of the Apache License (Version 2.0).See LICENSE for details.