indextree

Crates.ioindextree
lib.rsindextree
version4.7.3
sourcesrc
created_at2016-12-20 14:29:39.109816
updated_at2024-10-21 06:17:57.955052
descriptionArena based tree structure by using indices instead of reference counted pointers
homepagehttps://github.com/saschagrunert/indextree
repositoryhttps://github.com/saschagrunert/indextree
max_upload_size
id7689
size151,023
Sascha Grunert (saschagrunert)

documentation

https://docs.rs/indextree

README

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

Commit count: 175

cargo fmt