pub struct SecondaryMap<K, V>{ /* private fields */ }
Expand description
A mapping K -> V
for densely indexed entity references.
The SecondaryMap
data structure uses the dense index space to implement a map with a vector.
Unlike PrimaryMap
, an SecondaryMap
can’t be used to allocate entity references. It is used
to associate secondary information with entities.
The map does not track if an entry for a key has been inserted or not. Instead it behaves as if all keys have a default entry from the beginning.
Implementations§
Source§impl<K, V> SecondaryMap<K, V>
Shared SecondaryMap
implementation for all value types.
impl<K, V> SecondaryMap<K, V>
Shared SecondaryMap
implementation for all value types.
Sourcepub fn with_capacity(capacity: usize) -> Selfwhere
V: Default,
pub fn with_capacity(capacity: usize) -> Selfwhere
V: Default,
Create a new, empty map with the specified capacity.
The map will be able to hold exactly capacity
elements without reallocating.
Sourcepub fn with_default(default: V) -> Self
pub fn with_default(default: V) -> Self
Create a new empty map with a specified default value.
This constructor does not require V to implement Default.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the map can hold without reallocating.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
Iterate over all the keys and values in this map, mutable edition.
Sourcepub fn values_mut(&mut self) -> IterMut<'_, V> ⓘ
pub fn values_mut(&mut self) -> IterMut<'_, V> ⓘ
Iterate over all the values in this map, mutable edition.
Trait Implementations§
Source§impl<K, V> Archive for SecondaryMap<K, V>
impl<K, V> Archive for SecondaryMap<K, V>
Source§type Archived = ArchivedSecondaryMap<K, V>
type Archived = ArchivedSecondaryMap<K, V>
Source§type Resolver = SecondaryMapResolver<K, V>
type Resolver = SecondaryMapResolver<K, V>
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
Source§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize
. Read moreSource§impl<K, V> Clone for SecondaryMap<K, V>
impl<K, V> Clone for SecondaryMap<K, V>
Source§fn clone(&self) -> SecondaryMap<K, V>
fn clone(&self) -> SecondaryMap<K, V>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<K, V> Debug for SecondaryMap<K, V>
impl<K, V> Debug for SecondaryMap<K, V>
Source§impl<K, V> Default for SecondaryMap<K, V>
impl<K, V> Default for SecondaryMap<K, V>
Source§impl<__D: Fallible + ?Sized, K, V> Deserialize<SecondaryMap<K, V>, __D> for Archived<SecondaryMap<K, V>>where
K: EntityRef,
V: Clone + Archive,
Vec<V>: Archive,
<Vec<V> as Archive>::Archived: Deserialize<Vec<V>, __D>,
<V as Archive>::Archived: Deserialize<V, __D>,
PhantomData<K>: Archive,
<PhantomData<K> as Archive>::Archived: Deserialize<PhantomData<K>, __D>,
impl<__D: Fallible + ?Sized, K, V> Deserialize<SecondaryMap<K, V>, __D> for Archived<SecondaryMap<K, V>>where
K: EntityRef,
V: Clone + Archive,
Vec<V>: Archive,
<Vec<V> as Archive>::Archived: Deserialize<Vec<V>, __D>,
<V as Archive>::Archived: Deserialize<V, __D>,
PhantomData<K>: Archive,
<PhantomData<K> as Archive>::Archived: Deserialize<PhantomData<K>, __D>,
Source§fn deserialize(
&self,
deserializer: &mut __D,
) -> Result<SecondaryMap<K, V>, <__D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut __D, ) -> Result<SecondaryMap<K, V>, <__D as Fallible>::Error>
Source§impl<K, V> Index<K> for SecondaryMap<K, V>
Immutable indexing into an SecondaryMap
.
impl<K, V> Index<K> for SecondaryMap<K, V>
Immutable indexing into an SecondaryMap
.
All keys are permitted. Untouched entries have the default value.
Source§impl<K, V> IndexMut<K> for SecondaryMap<K, V>
Mutable indexing into an SecondaryMap
.
impl<K, V> IndexMut<K> for SecondaryMap<K, V>
Mutable indexing into an SecondaryMap
.
The map grows as needed to accommodate new keys.
Source§impl<K, V> PartialEq for SecondaryMap<K, V>
impl<K, V> PartialEq for SecondaryMap<K, V>
impl<K, V> Eq for SecondaryMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for SecondaryMap<K, V>where
V: Freeze,
impl<K, V> RefUnwindSafe for SecondaryMap<K, V>where
V: RefUnwindSafe,
K: RefUnwindSafe,
impl<K, V> Send for SecondaryMap<K, V>
impl<K, V> Sync for SecondaryMap<K, V>
impl<K, V> Unpin for SecondaryMap<K, V>
impl<K, V> UnwindSafe for SecondaryMap<K, V>where
V: UnwindSafe,
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.