#arena-allocator #generational-arena #generational #arena #slab

no-std loro-thunderdome

Fork of thunderdome: Fast arena allocator with compact generational indices

1 unstable release

0.6.2 Oct 28, 2023

#255 in Memory management

Download history 113/week @ 2024-06-17 48/week @ 2024-06-24 160/week @ 2024-07-08 92/week @ 2024-07-15 39/week @ 2024-07-22 96/week @ 2024-07-29 127/week @ 2024-08-05 180/week @ 2024-08-12 251/week @ 2024-08-19 49/week @ 2024-08-26 324/week @ 2024-09-02 247/week @ 2024-09-09 182/week @ 2024-09-16 110/week @ 2024-09-23 125/week @ 2024-09-30

686 downloads per month
Used in 4 crates (via generic-btree)

MIT/Apache

58KB
1K SLoC

Thunderdome fork

This fork add a reserve method.

GitHub CI Status thunderdome on crates.io thunderdome docs

Thunderdome is a gladitorial generational arena inspired by generational-arena, slotmap, and slab. It provides constant time insertion, lookup, and removal via small (8 byte) keys returned from Arena.

Thunderdome's key type, Index, is still 8 bytes when put inside of an Option<T> thanks to Rust's NonZero* types.

Basic Examples

let mut arena = Arena::new();

let foo = arena.insert("Foo");
let bar = arena.insert("Bar");

assert_eq!(arena[foo], "Foo");
assert_eq!(arena[bar], "Bar");

arena[bar] = "Replaced";
assert_eq!(arena[bar], "Replaced");

let foo_value = arena.remove(foo);
assert_eq!(foo_value, Some("Foo"));

// The slot previously used by foo will be reused for baz
let baz = arena.insert("Baz");
assert_eq!(arena[baz], "Baz");

// foo is no longer a valid key
assert_eq!(arena.get(foo), None);

Comparison With Similar Crates

Feature Thunderdome generational-arena slotmap slab
Generational Indices¹ Yes Yes Yes No
size_of::<Index>() 8 16 8 8
size_of::<Option<Index>>() 8 24 8 16
Max Elements 2³² 2⁶⁴ 2³² 2⁶⁴
Non-Copy Values Yes Yes Yes Yes
no_std Support Yes Yes Yes No
Serde Support No Yes Yes No
  1. Generational indices help solve the ABA Problem, which can cause dangling keys to mistakenly access newly-inserted data.

Minimum Supported Rust Version (MSRV)

Thunderdome supports Rust 1.47.0 and newer. Until Thunderdome reaches 1.0, changes to the MSRV will require major version bumps. After 1.0, MSRV changes will only require minor version bumps, but will need significant justification.

Crate Features

  • std (default): Use the standard library. Disable to make this crate no-std compatible.

License

Licensed under either of

at your option.

Contribution

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

Features