Module generational_lru::arena
source · [−]Expand description
Module providing a generational arena based off a vector.
Usage:
use generational_lru::arena::Arena;
let mut arena = Arena::<i32>::with_capacity(10); // create arena
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; // this close from greatness
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. This is inspired from the crate “generational-arena”
Arena out of memory error.
Index in vector to allocated entry. Used to access items allocated in the arena.
Enums
Entry represents an arena allocation entry. It is used to track free and Occupied blocks along with generation counters for Occupied blocks.