Struct EitherQueue

Source
pub struct EitherQueue<L, R> { /* private fields */ }
Expand description

Representation of two queues in one.

Implementations§

Source§

impl<L, R> EitherQueue<L, R>

Source

pub fn new() -> Self

Allocate and return a new, empty, EitherQueue object.

Source

pub fn len(&self) -> usize

Returns the number of nodes in both left and right queues combined.

let mut q = eitherq::EitherQueue::<&str, u32>::new();
q.push_left("elena");
q.push_left("chloe");
q.push_right(42);
assert_eq!(q.len(), 3);
Source

pub fn left_len(&self) -> usize

Source

pub fn right_len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Returns true if both internal queues are empty.

let mut q = eitherq::EitherQueue::<&str, u32>::new();
assert_eq!(q.is_empty(), true);
q.push_left("charlie");
assert_eq!(q.is_empty(), false);
q.clear();
q.push_right(17);
assert_eq!(q.is_empty(), false);
Source

pub fn is_left_empty(&self) -> bool

Returns true if the left queue is empty. Returns false otherwise.

Source

pub fn is_right_empty(&self) -> bool

Returns true if the right queue is empty. Returns false otherwise.

Source

pub fn clear(&mut self)

Clears all elements from both queues.

let mut q = eitherq::EitherQueue::<&str, u32>::new();
q.push_left("sully");
q.push_right(11);
q.clear();
assert_eq!(q.len(), 0);
Source

pub fn push(&mut self, n: Either<L, R>)

Source

pub fn push_left(&mut self, n: L)

Source

pub fn push_right(&mut self, n: R)

Source

pub fn pop(&mut self) -> Option<Either<L, R>>

Take the “oldest” node off the queue.

Source

pub fn pop_left(&mut self) -> Option<L>

Take the oldest node off the left queue.

Source

pub fn pop_right(&mut self) -> Option<R>

Take the oldest node off the right queue.

Trait Implementations§

Source§

impl<L, R> Default for EitherQueue<L, R>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<L, R> Freeze for EitherQueue<L, R>

§

impl<L, R> RefUnwindSafe for EitherQueue<L, R>

§

impl<L, R> Send for EitherQueue<L, R>
where L: Send, R: Send,

§

impl<L, R> Sync for EitherQueue<L, R>
where L: Sync, R: Sync,

§

impl<L, R> Unpin for EitherQueue<L, R>
where L: Unpin, R: Unpin,

§

impl<L, R> UnwindSafe for EitherQueue<L, R>
where L: UnwindSafe, R: 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.