This project provides trees data structure serving for general purpose.
Quickstart
Impatient readers can start with the notations.
Features
-
Step-by-step creating, reading, updating, deleting and iterating nodes with assocated data items.
-
Compact notations to express trees:
-
,/
encoded or tuple encoded trees. -
Depth first search cursor.
-
Breadth first search iterators.
-
Trees can be built by stages, with nodes stored scatteredly among memory.
-
Trees can be built once through, with nodes stored contiguously.
-
Support exclusive ownership with static borrow check.
-
Support shared ownership with dynamic borrow check.
Examples
-
notation of a literal tree
use tr; let scattered_tree = tr / /; let piled_tree = from;
They both encode a tree drawn as follows:
............. . 0 . . / \ . . 1 4 . . / \ / \ . .2 3 5 6. .............
-
use tree notation to reduce syntax noise, quoted from crate
reflection_derive
, version 0.1.1:quote!
The starting of tree operations are denoted by
-(
and/(
which are humble enough to let the reader focusing on the data part. -
use iterators if the tree travesal is a "driving wheel"( you can iterate over the tree on your own ).
use ; use Display; let tree = tr / /; assert_eq!;
-
use
TreeWalk
when the tree travesal is a "driven wheel"( driven by other library ). Quoted from cratetsv
, version 0.1.0:The
serde
library is driving on the schema tree when (de)serializing variables. UseTreeWalk
methods such asnext_column
andrevisit
to follow the step.
License
Under Apache License 2.0 or MIT License, at your will.