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>

source

pub fn new() -> Self

Creates a new empty arena.

source

pub fn get_from_contiguous_index(&self, index: usize) -> Option<(&T, Idx)>

Get an element from its position on the contiguous array.

source

pub fn len(&self) -> usize

The number of objects on this arena.

source

pub fn get(&self, handle: Idx) -> Option<&T>

Gets a reference to the object identified by handle.

source

pub fn get_mut(&mut self, handle: Idx) -> Option<&mut T>

Gets a mutable reference to the object identified by handle.

source

pub fn values(&self) -> Iter<'_, T>

Gets references to all the objects on this set.

source

pub fn values_mut(&mut self) -> IterMut<'_, T>

Gets mutable references to all the objects on this set.

source

pub fn iter<'a>(&'a self) -> impl Iterator<Item = (Idx, &'a T)> + 'a

Iter through all the objects as well as their handle.

source

pub fn as_slice(&self) -> &[T]

Retrieves the set of objects as a slice.

source

pub fn as_mut_slice(&mut self) -> &mut [T]

Retrieves the set of objects as a mutable slice.

source

pub fn insert(&mut self, object: T) -> Idx

Insert an object into this set.

source

pub fn remove(&mut self, handle: Idx) -> Option<T>

Remove an object from this set.

Trait Implementations§

source§

impl<Idx, T> AsMut<[T]> for ContiguousArena<Idx, T>

source§

fn as_mut(&mut self) -> &mut [T]

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<Idx, T> AsRef<[T]> for ContiguousArena<Idx, T>

source§

fn as_ref(&self) -> &[T]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<Idx: Clone, T: Clone> Clone for ContiguousArena<Idx, T>

source§

fn clone(&self) -> ContiguousArena<Idx, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Idx: Into<ContiguousArenaIndex>, T> Index<Idx> for ContiguousArena<Idx, T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, i: Idx) -> &T

Performs the indexing (container[index]) operation. Read more
source§

impl<Idx: Into<ContiguousArenaIndex>, T> IndexMut<Idx> for ContiguousArena<Idx, T>

source§

fn index_mut(&mut self, i: Idx) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<Idx, T> RefUnwindSafe for ContiguousArena<Idx, T>

§

impl<Idx, T> Send for ContiguousArena<Idx, T>
where Idx: Send, T: Send,

§

impl<Idx, T> Sync for ContiguousArena<Idx, T>
where Idx: Sync, T: Sync,

§

impl<Idx, T> Unpin for ContiguousArena<Idx, T>
where Idx: Unpin, T: Unpin,

§

impl<Idx, T> UnwindSafe for ContiguousArena<Idx, T>
where Idx: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.