Type Alias wasmtime_environ::SparseSet

source ·
pub type SparseSet<T> = SparseMap<T, T>;
Expand description

A sparse set of entity references.

Any type that implements EntityRef can be used as a sparse set value too.

Aliased Type§

struct SparseSet<T> { /* private fields */ }

Implementations§

source§

impl<K, V> SparseMap<K, V>where K: EntityRef, V: SparseMapValue<K>,

source

pub fn new() -> SparseMap<K, V>

Create a new empty mapping.

source

pub fn len(&self) -> usize

Returns the number of elements in the map.

source

pub fn is_empty(&self) -> bool

Returns true is the map contains no elements.

source

pub fn clear(&mut self)

Remove all elements from the mapping.

source

pub fn get(&self, key: K) -> Option<&V>

Returns a reference to the value corresponding to the key.

source

pub fn get_mut(&mut self, key: K) -> Option<&mut V>

Returns a mutable reference to the value corresponding to the key.

Note that the returned value must not be mutated in a way that would change its key. This would invalidate the sparse set data structure.

source

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

Return true if the map contains a value corresponding to key.

source

pub fn insert(&mut self, value: V) -> Option<V>

Insert a value into the map.

If the map did not have this key present, None is returned.

If the map did have this key present, the value is updated, and the old value is returned.

It is not necessary to provide a key since the value knows its own key already.

source

pub fn remove(&mut self, key: K) -> Option<V>

Remove a value from the map and return it.

source

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

Remove the last value from the map.

source

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

Get an iterator over the values in the map.

The iteration order is entirely determined by the preceding sequence of insert and remove operations. In particular, if no elements were removed, this is the insertion order.

source

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

Get the values as a slice.

Trait Implementations§

source§

impl<'de, K, V> Deserialize<'de> for SparseMap<K, V>where K: EntityRef + Deserialize<'de>, V: SparseMapValue<K> + Deserialize<'de>,

source§

fn deserialize<__D>( __deserializer: __D ) -> Result<SparseMap<K, V>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<K, V> Serialize for SparseMap<K, V>where K: EntityRef + Serialize, V: SparseMapValue<K> + Serialize,

source§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more