Expand description
§Arena based tree data structure
This arena tree structure is using just a single Vec
and numerical
identifiers (indices in the vector) instead of reference counted pointers
like. This means there is no RefCell
and mutability is handled in a way
much more idiomatic to Rust through unique (&mut) access to the arena. The
tree can be sent or shared across threads like a Vec
. This enables
general multiprocessing support like parallel tree traversals.
§Example usage
use indextree::Arena;
// Create a new arena
let arena = &mut Arena::new();
// Add some new nodes to the arena
let a = arena.new_node(1);
let b = arena.new_node(2);
// Append b to a
a.append(b, arena);
assert_eq!(b.ancestors(arena).into_iter().count(), 2);
Re-exports§
pub use indextree_macros as macros;
Structs§
- An iterator of the IDs of the ancestors of a given node.
- An
Arena
structure containing certainNode
s. - An iterator of the IDs of the children of a given node, in insertion order.
- Tree printer for debugging.
- An iterator of the IDs of a given node and its descendants, as a pre-order depth-first search where children are visited in insertion order.
- An iterator of the IDs of the siblings after a given node.
- A node within a particular
Arena
. - A node identifier within a particular
Arena
. - An iterator of the IDs of the siblings before a given node.
- An iterator of the IDs of the predecessors of a given node.
- Reverse
Children Deprecated An iterator of the IDs of the children of a given node, in reverse insertion order. - An iterator of the “sides” of a node visited during a depth-first pre-order traversal, where nodes are visited end to start and children are visited in reverse insertion order.
- An iterator of the “sides” of a node visited during a depth-first pre-order traversal, where node sides are visited start to end and children are visited in insertion order.
Enums§
- Indicator if the node is at a start or endpoint of the tree
- Possible node failures.