pub struct Arena<K: ArenaKey, T> { /* private fields */ }Expand description
A slot map: dense Vec storage with O(1) insert/remove/lookup by key.
Implementations§
Source§impl<K: ArenaKey, T> Arena<K, T>
impl<K: ArenaKey, T> Arena<K, T>
Sourcepub fn insert_with(&mut self, make: impl FnOnce(K) -> T) -> K
pub fn insert_with(&mut self, make: impl FnOnce(K) -> T) -> K
Insert a value that needs to know its own key (e.g. a node that stores
its own NodeId).
Sourcepub fn remove(&mut self, key: K) -> Option<T>
pub fn remove(&mut self, key: K) -> Option<T>
Remove and return the entry for key, recycling the slot.
Sourcepub fn iter(&self) -> impl Iterator<Item = (K, &T)>
pub fn iter(&self) -> impl Iterator<Item = (K, &T)>
Iterate over (key, &value) for all live entries, in ascending key order.
Sourcepub fn values_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut T>
Iterate over &mut value for all live entries.
Trait Implementations§
Auto Trait Implementations§
impl<K, T> Freeze for Arena<K, T>
impl<K, T> RefUnwindSafe for Arena<K, T>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<K, T> Send for Arena<K, T>
impl<K, T> Sync for Arena<K, T>
impl<K, T> Unpin for Arena<K, T>
impl<K, T> UnsafeUnpin for Arena<K, T>
impl<K, T> UnwindSafe for Arena<K, T>where
K: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more