Module generational_cache::arena
source · Expand description
Module providing abstractions for a generational arena implemenation.
Usage
#[no_std]
use generational_cache::prelude::*;
const CAPACITY: usize = 5;
let mut arena = Arena::<_, i32>::with_vector(Array::<_, CAPACITY>::new());
let index = arena.insert(78).unwrap(); // allocate new element in arena
let i_ref = arena.get(&index);
assert_eq!(i_ref, Some(&78));
let i_m_ref = arena.get_mut(&index).unwrap();
*i_m_ref = -68418;
assert_eq!(arena.get(&index), Some(&-68418));
arena.remove(&index).unwrap();
assert!(arena.get(&index).is_none());
Structs
- A generational arena for allocating memory based off a vector. Every entry is associated with a generation counter to uniquely identify newer allocations from older reclaimed allocations at the same position in the vector.
- A generational counter augemented index to track arena allocation entries.
Enums
- Error type associated with arena operations.
- An allocation entry in a generational arena.