pub struct Stack<T, P = RcK> where
P: SharedPointerKind, { /* private fields */ }Expand description
A persistent stack with structural sharing.
Complexity
Let n be the number of elements in the stack.
Temporal complexity
| Operation | Average | Worst case |
|---|---|---|
new() | Θ(1) | Θ(1) |
push() | Θ(1) | Θ(1) |
pop() | Θ(1) | Θ(1) |
peek() | Θ(1) | Θ(1) |
size() | Θ(1) | Θ(1) |
clone() | Θ(1) | Θ(1) |
| iterator creation | Θ(1) | Θ(1) |
| iterator step | Θ(1) | Θ(1) |
| iterator full | Θ(n) | Θ(n) |
Implementation details
This is a thin wrapper around a List.
Implementations
sourceimpl<T, P> Stack<T, P> where
P: SharedPointerKind,
impl<T, P> Stack<T, P> where
P: SharedPointerKind,
pub fn new_with_ptr_kind() -> Stack<T, P>
pub fn peek(&self) -> Option<&T>
pub fn pop(&self) -> Option<Stack<T, P>>
pub fn pop_mut(&mut self) -> bool
pub fn push(&self, v: T) -> Stack<T, P>
pub fn push_mut(&mut self, v: T)
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, T, P>
Trait Implementations
sourceimpl<T, P> Clone for Stack<T, P> where
P: SharedPointerKind,
impl<T, P> Clone for Stack<T, P> where
P: SharedPointerKind,
sourceimpl<T, P> Default for Stack<T, P> where
P: SharedPointerKind,
impl<T, P> Default for Stack<T, P> where
P: SharedPointerKind,
sourceimpl<'de, T, P> Deserialize<'de> for Stack<T, P> where
T: Deserialize<'de>,
P: SharedPointerKind,
impl<'de, T, P> Deserialize<'de> for Stack<T, P> where
T: Deserialize<'de>,
P: SharedPointerKind,
sourcefn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<Stack<T, P>, D::Error>
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<Stack<T, P>, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: Display, P> Display for Stack<T, P> where
P: SharedPointerKind,
impl<T: Display, P> Display for Stack<T, P> where
P: SharedPointerKind,
sourceimpl<T, P> FromIterator<T> for Stack<T, P> where
P: SharedPointerKind,
impl<T, P> FromIterator<T> for Stack<T, P> where
P: SharedPointerKind,
sourcefn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Stack<T, P>
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Stack<T, P>
Creates a value from an iterator. Read more
sourceimpl<T: Hash, P> Hash for Stack<T, P> where
P: SharedPointerKind,
impl<T: Hash, P> Hash for Stack<T, P> where
P: SharedPointerKind,
sourceimpl<'a, T, P> IntoIterator for &'a Stack<T, P> where
P: SharedPointerKind,
impl<'a, T, P> IntoIterator for &'a Stack<T, P> where
P: SharedPointerKind,
sourceimpl<T: Ord, P> Ord for Stack<T, P> where
P: SharedPointerKind,
impl<T: Ord, P> Ord for Stack<T, P> where
P: SharedPointerKind,
sourceimpl<T: PartialEq, P, PO> PartialEq<Stack<T, PO>> for Stack<T, P> where
P: SharedPointerKind,
PO: SharedPointerKind,
impl<T: PartialEq, P, PO> PartialEq<Stack<T, PO>> for Stack<T, P> where
P: SharedPointerKind,
PO: SharedPointerKind,
sourceimpl<T: PartialOrd<T>, P, PO> PartialOrd<Stack<T, PO>> for Stack<T, P> where
P: SharedPointerKind,
PO: SharedPointerKind,
impl<T: PartialOrd<T>, P, PO> PartialOrd<Stack<T, PO>> for Stack<T, P> where
P: SharedPointerKind,
PO: SharedPointerKind,
sourcefn partial_cmp(&self, other: &Stack<T, PO>) -> Option<Ordering>
fn partial_cmp(&self, other: &Stack<T, PO>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
sourceimpl<T, P> Serialize for Stack<T, P> where
T: Serialize,
P: SharedPointerKind,
impl<T, P> Serialize for Stack<T, P> where
T: Serialize,
P: SharedPointerKind,
impl<T: Eq, P> Eq for Stack<T, P> where
P: SharedPointerKind,
Auto Trait Implementations
impl<T, P> RefUnwindSafe for Stack<T, P> where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for Stack<T, P> where
P: Send,
T: Send,
impl<T, P> Sync for Stack<T, P> where
P: Sync,
T: Sync,
impl<T, P> Unpin for Stack<T, P> where
P: Unpin,
T: Unpin,
impl<T, P> UnwindSafe for Stack<T, P> where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more