[−][src]Struct rate_common::memory::StackMapping
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 ([]
).
Methods
impl<Key: Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
[src]
pub fn with_array_value_size_stack_size(
array_value: T,
array_size: usize,
stack_size: usize
) -> StackMapping<Key, T>
[src]
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
pub fn len(&self) -> usize
[src]
See Vec::len()
.
pub fn is_empty(&self) -> bool
[src]
See Vec::is_empty()
.
pub fn pop(&mut self) -> Option<Key>
[src]
This removs the top Key
and also resets the mapping of this key
to the default_value.
pub fn peek(&self) -> Key
[src]
pub fn clear(&mut self)
[src]
This clears the vector and resets all mappings.
pub fn stack_at(&self, offset: usize) -> Key
[src]
Returns the key in the vector at the given index.
pub fn stack_at_mut(&mut self, offset: usize) -> &mut Key
[src]
Returns the mutable key in the vector at the given index.
pub fn push(&mut self, key: Key, value: T)
[src]
Pushes to the vector and maps key
to value
.
pub fn push_but_do_not_set(&mut self, key: Key)
[src]
Pushes to the vector.
pub fn set_but_do_not_push(&mut self, key: Key, value: T)
[src]
Maps key
to value
.
pub fn iter(&self) -> Iter<Key>
[src]
Returns an iterator over the keys in the vector.
impl<Key: Ord + Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
[src]
pub fn sort_unstable(&mut self)
[src]
See Vec::sort_unstable()
.
impl<Key: Offset + Copy + Debug, T: Copy + Debug> StackMapping<Key, T>
[src]
pub fn sort_unstable_by_key<F, K>(&mut self, f: F) where
F: FnMut(&Key) -> K,
K: Ord,
[src]
F: FnMut(&Key) -> K,
K: Ord,
Trait Implementations
impl<Key: Offset + Copy + Debug, T: Copy + Debug> HeapSpace for StackMapping<Key, T>
[src]
fn heap_space(&self) -> usize
[src]
impl<'a, Key: Offset + Copy + Debug, T: Copy + Debug> IntoIterator for &'a StackMapping<Key, T>
[src]
type Item = &'a Key
The type of the elements being iterated over.
type IntoIter = Iter<'a, Key>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<Key: Default + Offset + Copy + Debug, T: Default + Copy + Debug> Default for StackMapping<Key, T>
[src]
fn default() -> StackMapping<Key, T>
[src]
impl<Key: Debug + Offset + Copy, T: Debug + Copy> Debug for StackMapping<Key, T>
[src]
impl<Key: Offset + Copy + Debug, T: Copy + Debug> Index<Key> for StackMapping<Key, T>
[src]
Auto Trait Implementations
impl<Key, T> Send for StackMapping<Key, T> where
Key: Send,
T: Send,
Key: Send,
T: Send,
impl<Key, T> Sync for StackMapping<Key, T> where
Key: Sync,
T: Sync,
Key: Sync,
T: Sync,
impl<Key, T> Unpin for StackMapping<Key, T> where
Key: Unpin,
T: Unpin,
Key: Unpin,
T: Unpin,
impl<Key, T> UnwindSafe for StackMapping<Key, T> where
Key: UnwindSafe,
T: UnwindSafe,
Key: UnwindSafe,
T: UnwindSafe,
impl<Key, T> RefUnwindSafe for StackMapping<Key, T> where
Key: RefUnwindSafe,
T: RefUnwindSafe,
Key: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> HeapSpace for T where
T: Copy,
[src]
T: Copy,
fn heap_space(&Self) -> usize
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,