pub struct StackMapping<Key: Offset + Copy + Debug, T: Copy + Debug> { /* private fields */ }
Expand description
A combination of a BoundedVector
and an Array
.
This provides Vec
-like semantics with elements of type Key
.
Additionally, each key is associated with one value of type T
(key is
mapped to value).
The value can be looked up in constant time using the index operator ([]
).
Implementations§
Source§impl<Key: Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
impl<Key: Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
Sourcepub fn with_array_value_size_stack_size(
array_value: T,
array_size: usize,
stack_size: usize,
) -> StackMapping<Key, T>
pub fn with_array_value_size_stack_size( array_value: T, array_size: usize, stack_size: usize, ) -> StackMapping<Key, T>
Construct a new StackMapping
.
§Parameters
array_value:
see default_valuearray_size:
the size of the array, must be large enough to hold the highest expected value of typeKey
stack_size:
the maximum size of the stack, e.g. the maximum number of keys that can be added to this stackmapping
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
See Vec::len()
.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
See Vec::is_empty()
.
Sourcepub fn pop(&mut self) -> Option<Key>
pub fn pop(&mut self) -> Option<Key>
This removs the top Key
and also resets the mapping of this key
to the default_value.
Sourcepub fn stack_at_mut(&mut self, offset: usize) -> &mut Key
pub fn stack_at_mut(&mut self, offset: usize) -> &mut Key
Returns the mutable key in the vector at the given index.
Sourcepub fn push_but_do_not_set(&mut self, key: Key)
pub fn push_but_do_not_set(&mut self, key: Key)
Pushes to the vector.
Sourcepub fn set_but_do_not_push(&mut self, key: Key, value: T)
pub fn set_but_do_not_push(&mut self, key: Key, value: T)
Maps key
to value
.
Source§impl<Key: Ord + Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
impl<Key: Ord + Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
Sourcepub fn sort_unstable(&mut self)
pub fn sort_unstable(&mut self)
See Vec::sort_unstable()
.
Source§impl<Key: Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
impl<Key: Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
Sourcepub fn sort_unstable_by_key<F, K>(&mut self, f: F)
pub fn sort_unstable_by_key<F, K>(&mut self, f: F)
Trait Implementations§
Source§impl<Key: Debug + Offset + Copy + Debug, T: Debug + Copy + Debug> Debug for StackMapping<Key, T>
impl<Key: Debug + Offset + Copy + Debug, T: Debug + Copy + Debug> Debug for StackMapping<Key, T>
Source§impl<Key: Default + Offset + Copy + Debug, T: Default + Copy + Debug> Default for StackMapping<Key, T>
impl<Key: Default + Offset + Copy + Debug, T: Default + Copy + Debug> Default for StackMapping<Key, T>
Source§fn default() -> StackMapping<Key, T>
fn default() -> StackMapping<Key, T>
Returns the “default value” for a type. Read more
Source§impl<Key: Offset + Copy + Debug, T: Copy + Debug> HeapSpace for StackMapping<Key, T>
impl<Key: Offset + Copy + Debug, T: Copy + Debug> HeapSpace for StackMapping<Key, T>
Source§fn heap_space(&self) -> usize
fn heap_space(&self) -> usize
The number of bytes allocated on the heap that this owns.
Source§impl<'a, Key: Offset + Copy + Debug, T: Copy + Debug> IntoIterator for &'a StackMapping<Key, T>
impl<'a, Key: Offset + Copy + Debug, T: Copy + Debug> IntoIterator for &'a StackMapping<Key, T>
Auto Trait Implementations§
impl<Key, T> Freeze for StackMapping<Key, T>where
T: Freeze,
impl<Key, T> RefUnwindSafe for StackMapping<Key, T>where
T: RefUnwindSafe,
Key: RefUnwindSafe,
impl<Key, T> Send for StackMapping<Key, T>
impl<Key, T> Sync for StackMapping<Key, T>
impl<Key, T> Unpin for StackMapping<Key, T>
impl<Key, T> UnwindSafe for StackMapping<Key, T>where
T: UnwindSafe,
Key: UnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more