Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saschagrunert/indextree
Arena based tree 🌲 structure by using indices instead of reference counted pointers
https://github.com/saschagrunert/indextree
arena data-structrues rust tree-structure
Last synced: 6 days ago
JSON representation
Arena based tree 🌲 structure by using indices instead of reference counted pointers
- Host: GitHub
- URL: https://github.com/saschagrunert/indextree
- Owner: saschagrunert
- License: mit
- Created: 2016-12-20T13:57:28.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2025-01-20T08:43:20.000Z (22 days ago)
- Last Synced: 2025-01-30T02:41:22.753Z (13 days ago)
- Topics: arena, data-structrues, rust, tree-structure
- Language: Rust
- Homepage:
- Size: 5.12 MB
- Stars: 721
- Watchers: 9
- Forks: 56
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# indextree
[![GitHub Actions](https://github.com/saschagrunert/indextree/actions/workflows/test.yml/badge.svg)](https://github.com/saschagrunert/indextree/actions/workflows/test.yml)
[![Coverage](https://codecov.io/gh/saschagrunert/indextree/branch/main/graph/badge.svg)](https://codecov.io/gh/saschagrunert/indextree)
[![Dependency Status](https://deps.rs/repo/github/saschagrunert/indextree/status.svg)](https://deps.rs/repo/github/saschagrunert/indextree)
[![Doc indextree](https://img.shields.io/badge/main-indextree-blue.svg)](https://saschagrunert.github.io/indextree/doc/indextree)
[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/saschagrunert/indextree/blob/main/LICENSE)
[![Crates.io](https://img.shields.io/crates/v/indextree.svg)](https://crates.io/crates/indextree)
[![doc.rs](https://docs.rs/indextree/badge.svg)](https://docs.rs/indextree)## 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
```rust
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