Cactus
This library provides an immutable cactus stuck (also called a spaghetti stack
or parent pointer tree). A cactus stack is a (possibly empty) node with a
(possibly null) pointer to a parent node. Any given node has a unique path back
to the root node. Rather than mutably updating the stack, one creates and
obtains access to immutable nodes (when a node becomes unreachable its memory is
automatically reclaimed). A new child node pointing to a parent can be created
via the child
function (analogous to the normal push
) and a parent can be
retrieved via the parent
function (analogous to the normal pop
).
use Cactus;
let c = new;
assert!;
let c2 = c.child;
assert_eq!;
assert_eq!;
let c3 = c2.parent.unwrap;
assert!;
From a given node one can create multiple sub-stacks:
use Cactus;
let c = new.child;
let c2 = c.child;
let c3 = c.child;
assert!;
assert_eq!;
assert_eq!;