Stable Red Black Trees in Motoko.
Inspiration taken from this back and forth in the Dfinity developer forums.
API documentation for this library can be found at https://canscale.github.io/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.
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<Text, Nat>();
let nt = RBT.put(t, Text.compare, "John", 52);
// or mutable updates
var t = RBT.init<Text, Nat>();
t := RBT.put(t, Text.compare, "John", 52);
StableRBTree is distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.