Struct rpds::stack::Stack
[−]
[src]
pub struct Stack<T> { /* fields omitted */ }A persistent stack with structural sharing. This data structure supports fast push(),
pop(), and peek().
Complexity
Let n be the number of elements in the stack.
Temporal complexity
| Operation | Best case | Average | Worst case |
|---|---|---|---|
new() |
Θ(1) | Θ(1) | Θ(1) |
push() |
Θ(1) | Θ(1) | Θ(1) |
pop() |
Θ(1) | Θ(1) | Θ(1) |
peek() |
Θ(1) | Θ(1) | Θ(1) |
size() |
Θ(1) | Θ(1) | Θ(1) |
clone() |
Θ(1) | Θ(1) | Θ(1) |
| iterator creation | Θ(1) | Θ(1) | Θ(1) |
| iterator step | Θ(1) | Θ(1) | Θ(1) |
| iterator full | Θ(n) | Θ(n) | Θ(n) |
Implementation details
This is a thin wrapper around a List.
Methods
impl<T> Stack<T>[src]
fn new() -> Stack<T>[src]
fn peek(&self) -> Option<&T>[src]
fn pop(&self) -> Option<Stack<T>>[src]
fn push(&self, v: T) -> Stack<T>[src]
fn size(&self) -> usize[src]
fn is_empty(&self) -> bool[src]
fn iter(&self) -> Iter<T>[src]
Trait Implementations
impl<T: Debug> Debug for Stack<T>[src]
impl<T> Default for Stack<T>[src]
impl<T: PartialEq> PartialEq for Stack<T>[src]
fn eq(&self, other: &Stack<T>) -> bool[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
This method tests for !=.
impl<T: Eq> Eq for Stack<T>[src]
impl<T: PartialOrd<T>> PartialOrd<Stack<T>> for Stack<T>[src]
fn partial_cmp(&self, other: &Stack<T>) -> Option<Ordering>[src]
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0[src]
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0[src]
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<T: Ord> Ord for Stack<T>[src]
fn cmp(&self, other: &Stack<T>) -> Ordering[src]
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<T: Hash> Hash for Stack<T>[src]
fn hash<H: Hasher>(&self, state: &mut H)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher]. Read more
impl<T> Clone for Stack<T>[src]
fn clone(&self) -> Stack<T>[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
impl<T: Display> Display for Stack<T>[src]
fn fmt(&self, fmt: &mut Formatter) -> Result[src]
Formats the value using the given formatter. Read more
impl<'a, T> IntoIterator for &'a Stack<T>[src]
type Item = &'a T
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, T>[src]
Creates an iterator from a value. Read more
impl<T> FromIterator<T> for Stack<T>[src]
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Stack<T>[src]
Creates a value from an iterator. Read more