pub struct Stacko<T, K: Key = DefaultKey> { /* private fields */ }
Expand description
A Stacko
for storing values of a single type.
Implementations§
Source§impl<T, K: Key> Stacko<T, K>
impl<T, K: Key> Stacko<T, K>
Sourcepub fn new() -> Self
pub fn new() -> Self
Constructs an empty Stacko
with a capacity of DEFAULT_CAPACITY
.
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Constructs an empty Stacko
able to store at least capacity values before
needing to allocate.
Sourcepub fn push(&self, value: T) -> (K, &T)
pub fn push(&self, value: T) -> (K, &T)
Pushes a value onto the Stacko
potentially allocating more memory.
Sourcepub fn get_mut(&mut self, key: K) -> Option<&mut T>
pub fn get_mut(&mut self, key: K) -> Option<&mut T>
Returns an exclusive reference to the value stored for the given key.
For details see get
.
Sourcepub fn key_from_index(&self, index: usize) -> Option<K>
pub fn key_from_index(&self, index: usize) -> Option<K>
Returns a key corresponding to the provided index if a value is stored at the given index.
The complexity is O(log n).
Trait Implementations§
Source§impl<T, K: Key> FromIterator<T> for Stacko<T, K>
impl<T, K: Key> FromIterator<T> for Stacko<T, K>
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Creates a value from an iterator. Read more
Source§impl<'p, T, K: Key> IntoIterator for &'p Stacko<T, K>
impl<'p, T, K: Key> IntoIterator for &'p Stacko<T, K>
Auto Trait Implementations§
impl<T, K = DefaultKey> !Freeze for Stacko<T, K>
impl<T, K = DefaultKey> !RefUnwindSafe for Stacko<T, K>
impl<T, K> Send for Stacko<T, K>
impl<T, K = DefaultKey> !Sync for Stacko<T, K>
impl<T, K> Unpin for Stacko<T, K>
impl<T, K> UnwindSafe for Stacko<T, K>where
K: UnwindSafe,
T: 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