Dusk Kelvin Map
Binary search tree implementation with no associated value on the nodes.
It will extend the standard properties of a default BST. The worst case scenario time complexity for inserting and searching is O(n)
.
This map-like implementation uses Microkelvin as backend and is optimized to work under constrained/hosted environments such as WASM runtimes.
Example
use MemStore;
use Map;
// Create a new map u64 -> u32 that will use MemStore as storage backend
let mut map: = default;
// Insert a new mapping 2 -> 4
map.insert.expect;
// Fetch the key 2 and expect it to be 4
let value = map
.get
.expect
.expect;
assert_eq!;
// Replace the key 2 with 5 via `insert` method
let old = map
.insert
.expect
.expect;
let new = map
.get
.expect
.expect;
assert_eq!;
assert_eq!;
// Mutate the key 2 to the previous value + 2, and return the new value + 1
// Since the previous value is 5, the new value should be 7, and the returned mapping should be 8
let map_mutated = map
.map_mut
.expect
.expect;
let value = map
.get
.expect
.expect;
assert_eq!;
assert_eq!;
// Remove the key 2
let value = map
.remove
.expect
.expect;
assert_eq!;