EntityVec

Struct EntityVec 

Source
pub struct EntityVec<E: Entity, V> { /* private fields */ }
Expand description

A Vec-backed collection indexed by EntityId<E>.

Implementations§

Source§

impl<E: Entity, V> EntityVec<E, V>

Source

pub fn new() -> Self

Creates an empty EntityVec.

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an empty EntityVec with space for at least capacity items.

Source

pub fn len(&self) -> usize

Returns the number of values stored.

Source

pub fn capacity(&self) -> usize

Returns the capacity of the backing vector.

Source

pub fn is_empty(&self) -> bool

Returns true if no values are stored.

Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more values.

Source

pub fn shrink_to_fit(&mut self)

Shrinks the backing vector to fit its length.

Source

pub fn push(&mut self, value: V)

Appends value to the end of the vector.

Source

pub fn pop(&mut self) -> Option<V>

Removes and returns the last value, or None if empty.

Source

pub fn get(&self, entity_id: EntityId<E>) -> Option<&V>

Returns the value for entity_id, or None if this vector is not long enough.

Source

pub fn get_mut(&mut self, entity_id: EntityId<E>) -> Option<&mut V>

Returns the mutable value for entity_id, or None if this vector is not long enough.

Source

pub fn last(&self) -> Option<&V>

Returns the last value, or None if empty.

Source

pub fn last_mut(&mut self) -> Option<&mut V>

Returns the last value mutably, or None if empty.

Source

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

Returns the backing slice.

Source

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

Returns the backing slice mutably.

Source

pub fn iter(&self) -> Iter<'_, V>

Returns an iterator over the stored values.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, V>

Returns a mutable iterator over the stored values.

Source

pub fn clear(&mut self)

Clears the vector, removing all values.

Source

pub fn truncate(&mut self, len: usize)

Truncates the vector to len items.

Source

pub fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = V>,

Extends the vector with values from iter, assigning contiguous IDs to new items.

Source

pub fn resize(&mut self, new_len: usize, value: V)
where V: Clone,

Resizes the vector to new_len, cloning value as needed.

Source

pub fn resize_with<F>(&mut self, new_len: usize, f: F)
where F: FnMut() -> V,

Resizes the vector to new_len, generating values with f as needed.

Source

pub fn contains(&self, value: &V) -> bool
where V: PartialEq,

Returns true if the vector contains value.

Source

pub fn into_vec(self) -> Vec<V>

Consumes the EntityVec and returns the backing Vec.

Trait Implementations§

Source§

impl<E: Clone + Entity, V: Clone> Clone for EntityVec<E, V>

Source§

fn clone(&self) -> EntityVec<E, V>

Returns a duplicate 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<E: Entity, V: Debug> Debug for EntityVec<E, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<E: Entity, V> Default for EntityVec<E, V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<E: Entity, V> Extend<V> for EntityVec<E, V>

Source§

fn extend<I: IntoIterator<Item = V>>(&mut self, iter: I)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<E: Entity, V> From<EntityVec<E, V>> for Vec<V>

Source§

fn from(value: EntityVec<E, V>) -> Self

Converts to this type from the input type.
Source§

impl<E: Entity, V> From<Vec<V>> for EntityVec<E, V>

Source§

fn from(data: Vec<V>) -> Self

Converts to this type from the input type.
Source§

impl<E: Entity, V> FromIterator<V> for EntityVec<E, V>

Source§

fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<E: Hash + Entity, V: Hash> Hash for EntityVec<E, V>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<E: Entity, V> Index<EntityId<E>> for EntityVec<E, V>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: EntityId<E>) -> &Self::Output

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

impl<E: Entity, V> IndexMut<EntityId<E>> for EntityVec<E, V>

Source§

fn index_mut(&mut self, index: EntityId<E>) -> &mut Self::Output

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

impl<'a, E: Entity, V> IntoIterator for &'a EntityVec<E, V>

Source§

type Item = &'a V

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, E: Entity, V> IntoIterator for &'a mut EntityVec<E, V>

Source§

type Item = &'a mut V

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<E: Entity, V> IntoIterator for EntityVec<E, V>

Source§

type Item = V

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<E: PartialEq + Entity, V: PartialEq> PartialEq for EntityVec<E, V>

Source§

fn eq(&self, other: &EntityVec<E, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<E: Eq + Entity, V: Eq> Eq for EntityVec<E, V>

Source§

impl<E: Entity, V> StructuralPartialEq for EntityVec<E, V>

Auto Trait Implementations§

§

impl<E, V> Freeze for EntityVec<E, V>

§

impl<E, V> RefUnwindSafe for EntityVec<E, V>

§

impl<E, V> Send for EntityVec<E, V>
where E: Send, V: Send,

§

impl<E, V> Sync for EntityVec<E, V>
where E: Sync, V: Sync,

§

impl<E, V> Unpin for EntityVec<E, V>
where E: Unpin, V: Unpin,

§

impl<E, V> UnwindSafe for EntityVec<E, V>
where E: UnwindSafe, V: 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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V