Skip to main content

EntityMap

Struct EntityMap 

Source
pub struct EntityMap<I: EntityId, K: Hash + Eq, V, RS: BuildHasher = RandomState> { /* private fields */ }
Expand description

An [IndexMap] with strongly-typed indices.

An EntityMap assigns sequential IDs to each inserted (K, V) pair. Entries may be looked up either by the key K, or the index I (by means of the Index trait).

§Accessors at a glance

AccessorRequiresObtains
&map[id]I&V
&mut map[id]I&mut V
keyI&K
get&KOption<(I, &V)>
get_mut&KOption<(I, &mut V)>

Implementations§

Source§

impl<I, K, V, RS> EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher,

Source

pub fn with_hasher(h: RS) -> Self

Source

pub fn with_capacity_and_hasher(n: usize, h: RS) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn next_id(&self) -> I

Source

pub fn clear(&mut self)

Source

pub fn insert(&mut self, k: K, v: V) -> (I, Option<V>)

Source

pub fn insert_new(&mut self, k: K, v: V) -> I

Source

pub fn key(&self, id: I) -> &K

Source

pub fn get<Q>(&self, key: &Q) -> Option<(I, &V)>
where Q: ?Sized + Hash + Equivalent<K>,

Source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<(I, &mut V)>
where Q: ?Sized + Hash + Equivalent<K>,

Source

pub fn get_full<Q>(&self, key: &Q) -> Option<(I, &K, &V)>
where Q: ?Sized + Hash + Equivalent<K>,

Source

pub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(I, &K, &mut V)>
where Q: ?Sized + Hash + Equivalent<K>,

Source

pub fn entry(&mut self, key: K) -> Entry<'_, I, K, V>

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where Q: ?Sized + Hash + Equivalent<K>,

Source

pub fn ids(&self) -> EntityRange<I>

Source

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

Source

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

Source

pub fn keys(&self) -> Keys<'_, K, V> ⓘ

Source

pub fn into_keys(self) -> IntoKeys<K, V> ⓘ

Source

pub fn values(&self) -> Values<'_, K, V> ⓘ

Source

pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ

Source

pub fn into_values(self) -> IntoValues<K, V> ⓘ

Source

pub fn into_vec(self) -> EntityVec<I, (K, V)>

Source§

impl<I, K, V> EntityMap<I, K, V>
where I: EntityId, K: Hash + Eq,

Source

pub fn new() -> Self

Source

pub fn with_capacity(n: usize) -> Self

Trait Implementations§

Source§

impl<I: Clone + EntityId, K: Clone + Hash + Eq, V: Clone, RS: Clone + BuildHasher> Clone for EntityMap<I, K, V, RS>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I, K, V, RS> Debug for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq + Debug, V: Debug, RS: BuildHasher,

Source§

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

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

impl<I, K, V> Default for EntityMap<I, K, V>
where I: EntityId, K: Hash + Eq,

Source§

fn default() -> Self

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

impl<I, K, V, RS> Eq for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, V: Eq, RS: BuildHasher,

Source§

impl<I, K, V, RS> Extend<(K, V)> for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher + Default,

Source§

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

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

fn extend_one(&mut self, item: T)

🔬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<I, K, V, RS> FromIterator<(K, V)> for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher + Default,

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = (K, V)>,

Creates a value from an iterator. Read more
Source§

impl<I, K, V, RS> Index<I> for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher,

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: I) -> &V

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

impl<I, K, V, RS> IndexMut<I> for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher,

Source§

fn index_mut(&mut self, index: I) -> &mut V

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

impl<I, K, V, RS> IntoIterator for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher,

Source§

type Item = (I, K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<I, K, 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, I, K, V, RS> IntoIterator for &'a EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher,

Source§

type Item = (I, &'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, I, K, 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, I, K, V, RS> IntoIterator for &'a mut EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, RS: BuildHasher,

Source§

type Item = (I, &'a K, &'a mut V)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, I, K, 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<I, K, V, RS, RS2> PartialEq<EntityMap<I, K, V, RS2>> for EntityMap<I, K, V, RS>
where I: EntityId, K: Hash + Eq, V: PartialEq, RS: BuildHasher, RS2: BuildHasher,

Source§

fn eq(&self, other: &EntityMap<I, K, V, RS2>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<I, K, V, RS> Freeze for EntityMap<I, K, V, RS>
where RS: Freeze,

§

impl<I, K, V, RS> RefUnwindSafe for EntityMap<I, K, V, RS>

§

impl<I, K, V, RS> Send for EntityMap<I, K, V, RS>
where RS: Send, K: Send, V: Send,

§

impl<I, K, V, RS> Sync for EntityMap<I, K, V, RS>
where RS: Sync, K: Sync, V: Sync,

§

impl<I, K, V, RS> Unpin for EntityMap<I, K, V, RS>
where RS: Unpin, I: Unpin, K: Unpin, V: Unpin,

§

impl<I, K, V, RS> UnsafeUnpin for EntityMap<I, K, V, RS>
where RS: UnsafeUnpin,

§

impl<I, K, V, RS> UnwindSafe for EntityMap<I, K, V, RS>

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

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.