pub struct ContiguousArena<Idx, T> { /* private fields */ }Expand description
This is a Vec behind a generational arena.
The goal of this structure is to have unique identifiers for elements
stored contiguously on a Vec.
Implementations§
Source§impl<Idx, T> ContiguousArena<Idx, T>
impl<Idx, T> ContiguousArena<Idx, T>
Sourcepub fn get_from_contiguous_index(&self, index: usize) -> Option<(&T, Idx)>where
Idx: From<ContiguousArenaIndex>,
pub fn get_from_contiguous_index(&self, index: usize) -> Option<(&T, Idx)>where
Idx: From<ContiguousArenaIndex>,
Get an element from its position on the contiguous array.
Sourcepub fn get(&self, handle: Idx) -> Option<&T>where
Idx: Into<ContiguousArenaIndex>,
pub fn get(&self, handle: Idx) -> Option<&T>where
Idx: Into<ContiguousArenaIndex>,
Gets a reference to the object identified by handle.
Sourcepub fn get_mut(&mut self, handle: Idx) -> Option<&mut T>where
Idx: Into<ContiguousArenaIndex>,
pub fn get_mut(&mut self, handle: Idx) -> Option<&mut T>where
Idx: Into<ContiguousArenaIndex>,
Gets a mutable reference to the object identified by handle.
Sourcepub fn values_mut(&mut self) -> IterMut<'_, T> ⓘ
pub fn values_mut(&mut self) -> IterMut<'_, T> ⓘ
Gets mutable references to all the objects on this set.
Sourcepub fn iter<'a>(&'a self) -> impl Iterator<Item = (Idx, &'a T)> + 'awhere
Idx: From<ContiguousArenaIndex>,
pub fn iter<'a>(&'a self) -> impl Iterator<Item = (Idx, &'a T)> + 'awhere
Idx: From<ContiguousArenaIndex>,
Iter through all the objects as well as their handle.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
Retrieves the set of objects as a mutable slice.
Sourcepub fn insert(&mut self, object: T) -> Idxwhere
Idx: From<ContiguousArenaIndex>,
pub fn insert(&mut self, object: T) -> Idxwhere
Idx: From<ContiguousArenaIndex>,
Insert an object into this set.
Sourcepub fn remove(&mut self, handle: Idx) -> Option<T>where
Idx: Into<ContiguousArenaIndex>,
pub fn remove(&mut self, handle: Idx) -> Option<T>where
Idx: Into<ContiguousArenaIndex>,
Remove an object from this set.
Trait Implementations§
Source§impl<Idx, T> AsMut<[T]> for ContiguousArena<Idx, T>
impl<Idx, T> AsMut<[T]> for ContiguousArena<Idx, T>
Source§impl<Idx, T> AsRef<[T]> for ContiguousArena<Idx, T>
impl<Idx, T> AsRef<[T]> for ContiguousArena<Idx, T>
Source§impl<Idx: Clone, T: Clone> Clone for ContiguousArena<Idx, T>
impl<Idx: Clone, T: Clone> Clone for ContiguousArena<Idx, T>
Source§fn clone(&self) -> ContiguousArena<Idx, T>
fn clone(&self) -> ContiguousArena<Idx, T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Idx: Into<ContiguousArenaIndex>, T> Index<Idx> for ContiguousArena<Idx, T>
impl<Idx: Into<ContiguousArenaIndex>, T> Index<Idx> for ContiguousArena<Idx, T>
Auto Trait Implementations§
impl<Idx, T> Freeze for ContiguousArena<Idx, T>
impl<Idx, T> RefUnwindSafe for ContiguousArena<Idx, T>where
Idx: RefUnwindSafe,
T: RefUnwindSafe,
impl<Idx, T> Send for ContiguousArena<Idx, T>
impl<Idx, T> Sync for ContiguousArena<Idx, T>
impl<Idx, T> Unpin for ContiguousArena<Idx, T>
impl<Idx, T> UnsafeUnpin for ContiguousArena<Idx, T>
impl<Idx, T> UnwindSafe for ContiguousArena<Idx, T>where
Idx: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.