pub struct Queue<T, P = RcK>where
P: SharedPointerKind,{ /* private fields */ }
Expand description
A persistent queue with structural sharing.
§Complexity
Let n be the number of elements in the queue.
§Temporal complexity
Operation | Average | Worst 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, P> Queue<T, P>where
P: SharedPointerKind,
impl<T, P> Queue<T, P>where
P: SharedPointerKind,
pub fn new_with_ptr_kind() -> Queue<T, P>
pub fn peek(&self) -> Option<&T>
pub fn dequeue(&self) -> Option<Queue<T, P>>
pub fn dequeue_mut(&mut self) -> bool
pub fn enqueue(&self, v: T) -> Queue<T, P>
pub fn enqueue_mut(&mut self, v: T)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, T, P>
Trait Implementations§
Source§impl<T, P> Clone for Queue<T, P>where
P: SharedPointerKind,
impl<T, P> Clone for Queue<T, P>where
P: SharedPointerKind,
Source§impl<T, P> Default for Queue<T, P>where
P: SharedPointerKind,
impl<T, P> Default for Queue<T, P>where
P: SharedPointerKind,
Source§impl<'de, T, P> Deserialize<'de> for Queue<T, P>where
T: Deserialize<'de>,
P: SharedPointerKind,
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>
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, P> FromIterator<T> for Queue<T, P>where
P: SharedPointerKind,
impl<T, P> FromIterator<T> for Queue<T, P>where
P: SharedPointerKind,
Source§impl<'a, T, P> IntoIterator for &'a Queue<T, P>where
P: SharedPointerKind,
impl<'a, T, P> IntoIterator for &'a Queue<T, P>where
P: SharedPointerKind,
Source§type IntoIter = Map<Chain<IterPtr<'a, T, P>, LazilyReversedListIter<'a, T, P>>, fn(_: &SharedPointer<T, P>) -> &T>
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§impl<T: Ord, P> Ord for Queue<T, P>where
P: SharedPointerKind,
impl<T: Ord, P> Ord for Queue<T, P>where
P: SharedPointerKind,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq, P, PO> PartialEq<Queue<T, PO>> for Queue<T, P>where
P: SharedPointerKind,
PO: SharedPointerKind,
impl<T: PartialEq, P, PO> PartialEq<Queue<T, PO>> for Queue<T, P>where
P: SharedPointerKind,
PO: SharedPointerKind,
Source§impl<T: PartialOrd<T>, P, PO> PartialOrd<Queue<T, PO>> for Queue<T, P>where
P: SharedPointerKind,
PO: SharedPointerKind,
impl<T: PartialOrd<T>, P, PO> PartialOrd<Queue<T, PO>> for Queue<T, P>where
P: SharedPointerKind,
PO: SharedPointerKind,
impl<T: Eq, P> Eq for Queue<T, P>where
P: SharedPointerKind,
Auto Trait Implementations§
impl<T, P> Freeze for Queue<T, P>where
P: Freeze,
impl<T, P> RefUnwindSafe for Queue<T, P>where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for Queue<T, P>
impl<T, P> Sync for Queue<T, P>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more