Struct rpds::stack::Stack

source ·
pub struct Stack<T, P = RcK>{ /* private fields */ }
Expand description

A persistent stack with structural sharing.

Complexity

Let n be the number of elements in the stack.

Temporal complexity

OperationAverageWorst 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§

source§

impl<T> Stack<T, ArcTK>

source

pub fn new_sync() -> StackSync<T>

source§

impl<T> Stack<T>

source

pub fn new() -> Stack<T>

source§

impl<T, P> Stack<T, P>

source

pub fn new_with_ptr_kind() -> Stack<T, P>

source

pub fn peek(&self) -> Option<&T>

source

pub fn pop(&self) -> Option<Stack<T, P>>

source

pub fn pop_mut(&mut self) -> bool

source

pub fn push(&self, v: T) -> Stack<T, P>

source

pub fn push_mut(&mut self, v: T)

source

pub fn size(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn iter(&self) -> Iter<'_, T, P>

Trait Implementations§

source§

impl<T, P> Clone for Stack<T, P>

source§

fn clone(&self) -> Stack<T, P>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug, P> Debug for Stack<T, P>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, P> Default for Stack<T, P>

source§

fn default() -> Stack<T, P>

Returns the “default value” for a type. Read more
source§

impl<'de, T, P> Deserialize<'de> for Stack<T, P>
where T: Deserialize<'de>, P: SharedPointerKind,

source§

fn deserialize<D: Deserializer<'de>>( deserializer: D ) -> Result<Stack<T, P>, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T: Display, P> Display for Stack<T, P>

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, P> FromIterator<T> for Stack<T, P>

source§

fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Stack<T, P>

Creates a value from an iterator. Read more
source§

impl<T: Hash, P> Hash for Stack<T, P>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, T, P> IntoIterator for &'a Stack<T, P>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Map<IterPtr<'a, T, P>, fn(_: &SharedPointer<T, P>) -> &T>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Iter<'a, T, P>

Creates an iterator from a value. Read more
source§

impl<T: Ord, P> Ord for Stack<T, P>

source§

fn cmp(&self, other: &Stack<T, P>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T: PartialEq, P, PO> PartialEq<Stack<T, PO>> for Stack<T, P>

source§

fn eq(&self, other: &Stack<T, PO>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd<T>, P, PO> PartialOrd<Stack<T, PO>> for Stack<T, P>

source§

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 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T, P> Serialize for Stack<T, P>

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Eq, P> Eq for Stack<T, P>

Auto Trait Implementations§

§

impl<T, P> RefUnwindSafe for Stack<T, P>

§

impl<T, P> Send for Stack<T, P>
where P: Send + Sync, T: Send + Sync,

§

impl<T, P> Sync for Stack<T, P>
where P: Send + Sync, T: Send + Sync,

§

impl<T, P> Unpin for Stack<T, P>

§

impl<T, P> UnwindSafe for Stack<T, P>
where P: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,