12 releases

0.6.1 Jun 25, 2023
0.6.0 Oct 18, 2022
0.5.1 Jul 4, 2022
0.5.0 Oct 7, 2021
0.4.0 Nov 17, 2020

#64 in Memory management

Download history 1992/week @ 2024-08-15 2104/week @ 2024-08-22 2612/week @ 2024-08-29 2347/week @ 2024-09-05 1754/week @ 2024-09-12 2194/week @ 2024-09-19 1824/week @ 2024-09-26 1316/week @ 2024-10-03 1311/week @ 2024-10-10 1621/week @ 2024-10-17 1600/week @ 2024-10-24 1570/week @ 2024-10-31 994/week @ 2024-11-07 1071/week @ 2024-11-14 1767/week @ 2024-11-21 1802/week @ 2024-11-28

5,940 downloads per month
Used in 131 crates (23 directly)

MIT/Apache

57KB
1K SLoC

Thunderdome

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