Struct rpds::queue::Queue

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

A persistent queue with structural sharing.

Complexity

Let n be the number of elements in the queue.

Temporal complexity

OperationAverageWorst case
new()Θ(1)Θ(1)
enqueue()Θ(1)Θ(1)
dequeue()Θ(1)Θ(n)
dequeue() amortizedΘ(1)Θ(1)
peek()Θ(1)Θ(1)
len()Θ(1)Θ(1)
clone()Θ(1)Θ(1)
iterator creationΘ(1)Θ(1)
iterator stepΘ(1)Θ(n)
iterator fullΘ(n)Θ(n)

Implementation details

This queue is implemented as described in Immutability in C# Part Four: An Immutable Queue.

Implementations§

source§

impl<T> Queue<T, ArcTK>

source

pub fn new_sync() -> QueueSync<T>

source§

impl<T> Queue<T>

source

pub fn new() -> Queue<T>

source§

impl<T, P> Queue<T, P>

source

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

source

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

source

pub fn dequeue(&self) -> Option<Queue<T, P>>

source

pub fn dequeue_mut(&mut self) -> bool

source

pub fn enqueue(&self, v: T) -> Queue<T, P>

source

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

source

pub fn len(&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 Queue<T, P>

source§

fn clone(&self) -> Queue<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 Queue<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 Queue<T, P>

source§

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

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

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

source§

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

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

impl<T: Display, P> Display for Queue<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 Queue<T, P>

source§

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

Creates a value from an iterator. Read more
source§

impl<T: Hash, P> Hash for Queue<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 Queue<T, P>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Map<Chain<IterPtr<'a, T, P>, LazilyReversedListIter<'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 Queue<T, P>

source§

fn cmp(&self, other: &Queue<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<Queue<T, PO>> for Queue<T, P>

source§

fn eq(&self, other: &Queue<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<Queue<T, PO>> for Queue<T, P>

source§

fn partial_cmp(&self, other: &Queue<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 Queue<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 Queue<T, P>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T, P> UnwindSafe for Queue<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>,