#arena-allocator #generational-arena #generational #arena #collection

no-std pulz-arena

A generational arena allocator with compact generational indices

6 releases (breaking)

0.4.0 Jan 5, 2022
0.3.0 Oct 10, 2021
0.2.0 Sep 25, 2021
0.1.1 Aug 16, 2021
0.0.1 Aug 16, 2021

#951 in Data structures

32 downloads per month
Used in 4 crates (via pulz-ecs)

MIT/Apache

70KB
1K SLoC

pulz-arena

Crates.io docs.rs license: MIT/Apache-2.0 Rust CI

A generational arena allocator inspired by generational-arena with compact generational indices.

When you insert a value into the arena, you get an index-pointer in return. You can then use this index-pointer to access the provided value.

Example

use pulz_arena::{Arena,Index};

let mut arena = Arena::new();

// insert some elements and remember the returned index
let a = arena.insert("foo");
let b = arena.insert("bar");

// access inserted elements by returned index
assert_eq!("bar", arena[b]);

// there are also the "checked" versions `get` and `get_mut` that returns Option. 
assert_eq!(Some(&"foo"), arena.get(a));

// items can be removed efficiently
assert_eq!(Some("foo"), arena.remove(a));
assert!(!arena.contains(a));

no_std

This crate should also work without std. No additional configuration required.

License

This repository is licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps