[−][src]Struct rpds::stack::Stack
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
.
Methods
impl<T> Stack<T>
[src]
#[must_use]
pub fn new() -> Stack<T>
[src]
#[must_use]
pub fn peek(&self) -> Option<&T>
[src]
#[must_use]
pub fn pop(&self) -> Option<Stack<T>>
[src]
pub fn pop_mut(&mut self) -> bool
[src]
#[must_use]
pub fn push(&self, v: T) -> Stack<T>
[src]
pub fn push_mut(&mut self, v: T)
[src]
#[must_use]
pub fn size(&self) -> usize
[src]
#[must_use]
pub fn is_empty(&self) -> bool
[src]
#[must_use]
pub fn iter(&self) -> Iter<T>
[src]
Trait Implementations
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]
impl<T: Eq> Eq for Stack<T>
[src]
impl<T> Clone for Stack<T>
[src]
fn clone(&self) -> Stack<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: PartialOrd<T>> PartialOrd<Stack<T>> for Stack<T>
[src]
fn partial_cmp(&self, other: &Stack<T>) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.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: PartialEq> PartialEq<Stack<T>> for Stack<T>
[src]
fn eq(&self, other: &Stack<T>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T> Default for Stack<T>
[src]
impl<T: Ord> Ord for Stack<T>
[src]
fn cmp(&self, other: &Stack<T>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.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]
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> FromIterator<T> for Stack<T>
[src]
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Stack<T>
[src]
impl<T: Debug> Debug for Stack<T>
[src]
impl<T: Display> Display for Stack<T>
[src]
impl<T> Serialize for Stack<T> where
T: Serialize,
[src]
T: Serialize,
impl<'de, T> Deserialize<'de> for Stack<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> Result<Stack<T>, D::Error>
[src]
deserializer: D
) -> Result<Stack<T>, D::Error>
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,