#arena #index #trie #tree

no-std indextree

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

27 stable releases (4 major)

4.7.4 May 7, 2025
4.7.3 Oct 21, 2024
4.7.2 Aug 13, 2024
4.7.0 Jul 30, 2024
0.1.1 Dec 22, 2016

#47 in Data structures

Download history 6410/week @ 2025-01-31 7622/week @ 2025-02-07 5880/week @ 2025-02-14 7983/week @ 2025-02-21 7735/week @ 2025-02-28 10790/week @ 2025-03-07 11828/week @ 2025-03-14 9856/week @ 2025-03-21 12835/week @ 2025-03-28 15115/week @ 2025-04-04 13996/week @ 2025-04-11 14992/week @ 2025-04-18 15112/week @ 2025-04-25 9737/week @ 2025-05-02 8933/week @ 2025-05-09 13272/week @ 2025-05-16

49,019 downloads per month
Used in 130 crates (42 directly)

MIT license

120KB
1.5K SLoC

indextree

GitHub Actions 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);

Benchmarks

https://github.com/mooman219/generational_arena_bench

Dependencies

~0–490KB
~10K SLoC