Struct wasmer_types::entity::SecondaryMap
source · 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>where
K: EntityRef,
V: Clone,
impl<K, V> SecondaryMap<K, V>where
K: EntityRef,
V: Clone,
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>where
K: EntityRef,
V: Clone + Archive,
Vec<V>: Archive,
PhantomData<K>: Archive,
impl<K, V> Archive for SecondaryMap<K, V>where
K: EntityRef,
V: Clone + Archive,
Vec<V>: Archive,
PhantomData<K>: Archive,
source§impl<K, V> Clone for SecondaryMap<K, V>where
K: EntityRef + Clone,
V: Clone + Clone,
impl<K, V> Clone for SecondaryMap<K, V>where
K: EntityRef + Clone,
V: Clone + Clone,
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<__D: Fallible + ?Sized, K, V> Deserialize<SecondaryMap<K, V>, __D> for Archived<SecondaryMap<K, V>>where
K: EntityRef,
V: Clone + Archive,
Vec<V>: Archive,
Archived<Vec<V>>: Deserialize<Vec<V>, __D>,
Archived<V>: Deserialize<V, __D>,
PhantomData<K>: Archive,
Archived<PhantomData<K>>: 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,
Archived<Vec<V>>: Deserialize<Vec<V>, __D>,
Archived<V>: Deserialize<V, __D>,
PhantomData<K>: Archive,
Archived<PhantomData<K>>: Deserialize<PhantomData<K>, __D>,
source§fn deserialize(
&self,
deserializer: &mut __D
) -> Result<SecondaryMap<K, V>, __D::Error>
fn deserialize(
&self,
deserializer: &mut __D
) -> Result<SecondaryMap<K, V>, __D::Error>
source§impl<K, V> Index<K> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone,
impl<K, V> Index<K> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone,
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>where
K: EntityRef,
V: Clone,
impl<K, V> IndexMut<K> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone,
Mutable indexing into an SecondaryMap
.
The map grows as needed to accommodate new keys.
source§impl<K, V> PartialEq<SecondaryMap<K, V>> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone + PartialEq,
impl<K, V> PartialEq<SecondaryMap<K, V>> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone + PartialEq,
source§impl<__S: Fallible + ?Sized, K, V> Serialize<__S> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone + Serialize<__S>,
Vec<V>: Serialize<__S>,
PhantomData<K>: Serialize<__S>,
impl<__S: Fallible + ?Sized, K, V> Serialize<__S> for SecondaryMap<K, V>where
K: EntityRef,
V: Clone + Serialize<__S>,
Vec<V>: Serialize<__S>,
PhantomData<K>: Serialize<__S>,
impl<K, V> Eq for SecondaryMap<K, V>where
K: EntityRef,
V: Clone + PartialEq + Eq,
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for SecondaryMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for SecondaryMap<K, V>where
K: Send,
V: Send,
impl<K, V> Sync for SecondaryMap<K, V>where
K: Sync,
V: Sync,
impl<K, V> Unpin for SecondaryMap<K, V>where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for SecondaryMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§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,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be unsized. Read more§type MetadataResolver = ()
type MetadataResolver = ()
source§unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
)
unsafe fn resolve_metadata(
&self,
_: usize,
_: <T as ArchiveUnsized>::MetadataResolver,
_: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
)
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.