Struct im::queue::Queue
[−]
[src]
pub struct Queue<A>(_, _);
A strict queue backed by a pair of linked lists.
All operations run in O(1) amortised time, but the pop
operation may run in O(n) time in the worst case.
Methods
impl<A> Queue<A>
[src]
fn new() -> Self
Construct an empty queue.
fn is_empty(&self) -> bool
Test whether a queue is empty.
Time: O(1)
fn len(&self) -> usize
Get the length of a queue.
Time: O(1)
fn push<R>(&self, v: R) -> Self where
Arc<A>: From<R>,
Arc<A>: From<R>,
Construct a new queue by appending an element to the end of the current queue.
Time: O(1)
fn pop(&self) -> Option<(Arc<A>, Queue<A>)>
Get the first element out of a queue, as well as the remainder of the queue.
Returns None
if the queue is empty. Otherwise, you get a tuple
of the first element and the remainder of the queue.
fn iter(&self) -> Iter<A>
Get an iterator over a queue.
Trait Implementations
impl<A> Clone for Queue<A>
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<A> IntoIterator for Queue<A>
[src]
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, A> IntoIterator for &'a Queue<A>
[src]
type Item = Arc<A>
The type of the elements being iterated over.
type IntoIter = Iter<A>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<A, T> FromIterator<T> for Queue<A> where
Arc<A>: From<T>,
[src]
Arc<A>: From<T>,
fn from_iter<I>(source: I) -> Self where
I: IntoIterator<Item = T>,
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more