[][src]Struct rate_common::memory::StackMapping

pub struct StackMapping<Key: Offset + Copy + Debug, T: Copy + Debug> { /* fields omitted */ }

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]

Construct a new StackMapping.

Parameters

  • array_value: see default_value
  • array_size: the size of the array, must be large enough to hold the highest expected value of type Key
  • 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]

pub fn is_empty(&self) -> bool[src]

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]

Returns the last key in the vector.

Panics

Panics if the vector is empty.

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]

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]

Trait Implementations

impl<Key: Offset + Copy + Debug, T: Copy + Debug> HeapSpace for StackMapping<Key, T>[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?

impl<Key: Default + Offset + Copy + Debug, T: Default + Copy + Debug> Default for 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]

type Output = T

The returned type after indexing.

Auto Trait Implementations

impl<Key, T> Send for StackMapping<Key, T> where
    Key: Send,
    T: Send

impl<Key, T> Sync for StackMapping<Key, T> where
    Key: Sync,
    T: Sync

impl<Key, T> Unpin for StackMapping<Key, T> where
    Key: Unpin,
    T: Unpin

impl<Key, T> UnwindSafe for StackMapping<Key, T> where
    Key: UnwindSafe,
    T: UnwindSafe

impl<Key, T> RefUnwindSafe for StackMapping<Key, T> where
    Key: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> HeapSpace for T where
    T: Copy
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]