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
[src]
Construct an empty queue.
fn from<R, I>(it: I) -> Queue<A> where
I: IntoIterator<Item = R>,
R: Shared<A>,
[src]
I: IntoIterator<Item = R>,
R: Shared<A>,
Construct a queue by consuming an IntoIterator
.
Allows you to construct a queue out of anything that implements
the IntoIterator
trait.
Time: O(n)
fn is_empty(&self) -> bool
[src]
Test whether a queue is empty.
Time: O(1)
fn len(&self) -> usize
[src]
Get the length of a queue.
Time: O(1)
fn push<R>(&self, v: R) -> Self where
R: Shared<A>,
[src]
R: Shared<A>,
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>)>
[src]
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>
[src]
Get an iterator over a queue.
Trait Implementations
impl<A> Clone for Queue<A>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<A> Debug for Queue<A> where
A: Debug,
[src]
A: Debug,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl<A: PartialEq> PartialEq for Queue<A>
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<A: Eq> Eq for Queue<A>
[src]
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
[src]
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
[src]
Creates an iterator from a value. Read more
impl<A, T> FromIterator<T> for Queue<A> where
T: Shared<A>,
[src]
T: Shared<A>,
fn from_iter<I>(source: I) -> Self where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
impl<'a, A, T> From<&'a [T]> for Queue<A> where
&'a T: Shared<A>,
[src]
&'a T: Shared<A>,
impl<A, T> From<Vec<T>> for Queue<A> where
T: Shared<A>,
[src]
T: Shared<A>,
impl<'a, A, T> From<&'a Vec<T>> for Queue<A> where
&'a T: Shared<A>,
[src]
&'a T: Shared<A>,