#tree #arena #index #indextree #trie

indextree

Arena based tree structure by using indices instead of reference counted pointers

21 stable releases (4 major)

4.6.0 Mar 9, 2023
4.5.0 Sep 16, 2022
4.4.0 Mar 8, 2022
4.3.1 Sep 7, 2020
0.1.1 Dec 22, 2016

#39 in Data structures

Download history 2968/week @ 2022-12-04 3065/week @ 2022-12-11 3097/week @ 2022-12-18 1245/week @ 2022-12-25 2434/week @ 2023-01-01 2996/week @ 2023-01-08 2744/week @ 2023-01-15 2828/week @ 2023-01-22 3526/week @ 2023-01-29 3682/week @ 2023-02-05 3920/week @ 2023-02-12 4357/week @ 2023-02-19 3938/week @ 2023-02-26 4423/week @ 2023-03-05 4680/week @ 2023-03-12 5696/week @ 2023-03-19

19,032 downloads per month
Used in 52 crates (25 directly)

MIT license

115KB
1.5K SLoC

indextree

GitHub Actions Build status Coverage Dependency Status Doc indextree License MIT Crates.io doc.rs

Arena based tree structure with multithreading support

This arena tree structure is using just a single Vec and numerical identifiers (indices in the vector) instead of reference counted pointers. 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 a to b
assert!(a.append(b, arena).is_ok());
assert_eq!(b.ancestors(arena).into_iter().count(), 2);

Dependencies

~0–500KB
~11K SLoC