pub struct StableArena<Id: Identifier, T> { /* private fields */ }Expand description
Stable logical IDs over compact, dense physical payload storage.
Implementations§
Source§impl<Id: Identifier, T> StableArena<Id, T>
impl<Id: Identifier, T> StableArena<Id, T>
Sourcepub fn issued_len(&self) -> usize
pub fn issued_len(&self) -> usize
Returns the number of logical IDs issued, including removed IDs.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the payload capacity reserved by the dense value vector.
Sourcepub fn structural_bytes(&self) -> usize
pub fn structural_bytes(&self) -> usize
Returns bytes reserved by the arena’s three structural vectors.
Allocations owned by T itself are deliberately excluded.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Releases structural capacity retained beyond the current live/issued lengths.
Identifiers, liveness, and dense physical order are unchanged; only allocator capacity is returned. Intended for explicit end-of-mutation boundaries — shrinking after every removal would reallocate on the next growth.
Sourcepub fn get(&self, id: Id) -> Option<Identified<Id, &T>>
pub fn get(&self, id: Id) -> Option<Identified<Id, &T>>
Returns the live payload identified by id, if any.
Sourcepub fn get_mut(&mut self, id: Id) -> Option<Identified<Id, &mut T>>
pub fn get_mut(&mut self, id: Id) -> Option<Identified<Id, &mut T>>
Returns the live payload identified by id mutably, if any.
Sourcepub fn remove(&mut self, id: Id) -> T
pub fn remove(&mut self, id: Id) -> T
Removes and returns id’s payload while preserving every other ID.
§Panics
Panics when id is unknown or was already removed.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Drops every payload and starts issuing ids from zero again, keeping the capacity already allocated.
Every id issued before is invalid afterwards, and will be issued again: this begins a new epoch of the arena, and a stale id from the previous one silently names a different payload. Only an owner that can vouch no such id survives may call this.
Sourcepub fn truncate_issued(&mut self, issued: usize)
pub fn truncate_issued(&mut self, issued: usize)
Removes every payload whose id is issued or above and stops counting
those ids as issued, so the next push reuses the first of them.
The payloads are removed newest first, so an arena that only ever
pushed since the ids below issued were issued keeps its dense order.
Like clear, this reissues ids: it is for taking back
a batch of pushes whose ids never escaped.
Trait Implementations§
Source§impl<Id: Clone + Identifier, T: Clone> Clone for StableArena<Id, T>
impl<Id: Clone + Identifier, T: Clone> Clone for StableArena<Id, T>
Source§fn clone(&self) -> StableArena<Id, T>
fn clone(&self) -> StableArena<Id, T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more