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
sourceimpl<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
sourceimpl<T, P> Clone for Queue<T, P> where
P: SharedPointerKind,
impl<T, P> Clone for Queue<T, P> where
P: SharedPointerKind,
sourceimpl<T, P> Default for Queue<T, P> where
P: SharedPointerKind,
impl<T, P> Default for Queue<T, P> where
P: SharedPointerKind,
sourceimpl<'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,
sourcefn 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
sourceimpl<T: Display, P> Display for Queue<T, P> where
P: SharedPointerKind,
impl<T: Display, P> Display for Queue<T, P> where
P: SharedPointerKind,
sourceimpl<T, P> FromIterator<T> for Queue<T, P> where
P: SharedPointerKind,
impl<T, P> FromIterator<T> for Queue<T, P> where
P: SharedPointerKind,
sourcefn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Queue<T, P>
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Queue<T, P>
Creates a value from an iterator. Read more
sourceimpl<T: Hash, P> Hash for Queue<T, P> where
P: SharedPointerKind,
impl<T: Hash, P> Hash for Queue<T, P> where
P: SharedPointerKind,
sourceimpl<'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,
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?
sourceimpl<T: Ord, P> Ord for Queue<T, P> where
P: SharedPointerKind,
impl<T: Ord, P> Ord for Queue<T, P> where
P: SharedPointerKind,
sourceimpl<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,
sourceimpl<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,
sourcefn partial_cmp(&self, other: &Queue<T, PO>) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
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 · sourcefn le(&self, other: &Rhs) -> bool
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
sourceimpl<T, P> Serialize for Queue<T, P> where
T: Serialize,
P: SharedPointerKind,
impl<T, P> Serialize for Queue<T, P> where
T: Serialize,
P: SharedPointerKind,
impl<T: Eq, P> Eq for Queue<T, P> where
P: SharedPointerKind,
Auto Trait Implementations
impl<T, P> RefUnwindSafe for Queue<T, P> where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, P> Send for Queue<T, P> where
P: Send,
T: Send,
impl<T, P> Sync for Queue<T, P> where
P: Sync,
T: Sync,
impl<T, P> Unpin for Queue<T, P> where
P: Unpin,
T: Unpin,
impl<T, P> UnwindSafe for Queue<T, P> where
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more