4 releases

new 0.1.3 May 7, 2025
0.1.2 Oct 21, 2024
0.1.1 Aug 12, 2024
0.1.0 Jul 30, 2024

#1348 in Procedural macros

Download history 3536/week @ 2025-01-16 3417/week @ 2025-01-23 3467/week @ 2025-01-30 4723/week @ 2025-02-06 3532/week @ 2025-02-13 5653/week @ 2025-02-20 5130/week @ 2025-02-27 6666/week @ 2025-03-06 9119/week @ 2025-03-13 7546/week @ 2025-03-20 7387/week @ 2025-03-27 15200/week @ 2025-04-03 11157/week @ 2025-04-10 11993/week @ 2025-04-17 10093/week @ 2025-04-24 6114/week @ 2025-05-01

41,914 downloads per month
Used in 2 crates

MIT license

11KB
184 lines

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.7–1.2MB
~25K SLoC