Struct StochasticQueue

Source
pub struct StochasticQueue<T> { /* private fields */ }
Expand description

A queue which pops items at random uniformly. It cannot be iterated or peeked.

Implementations§

Source§

impl<T> StochasticQueue<T>

Source

pub fn with_capacity(cap: usize) -> Self

Create a queue with an initial capacity.

Source

pub fn new() -> Self

Create a queue.

Source

pub fn len(&self) -> usize

Get the amount of items in the queue. These items can be popped.

Source

pub fn is_empty(&self) -> bool

Checks whether or not the queue has no items.

Source

pub fn peek_iter(&self) -> impl Iterator<Item = &T>

Returns an iterator over all items in the queue without popping them. The order is arbitrary.

Source

pub fn push(&mut self, val: T)

Adds an item to the queue. When it will be chosen to be popped is nondeterministic.

Source

pub fn pop(&mut self) -> Option<T>

Removes an item from the queue, or returns None if the queue is empty. Which item will be popped is nondeterministic, but all items have an equal chance of being popped. If there is at least one item present, an item will definitely be popped.

Source

pub fn clear(&mut self)

Removes all items from the queue.

Auto Trait Implementations§

§

impl<T> Freeze for StochasticQueue<T>

§

impl<T> RefUnwindSafe for StochasticQueue<T>
where T: RefUnwindSafe,

§

impl<T> Send for StochasticQueue<T>
where T: Send,

§

impl<T> Sync for StochasticQueue<T>
where T: Sync,

§

impl<T> Unpin for StochasticQueue<T>
where T: Unpin,

§

impl<T> UnwindSafe for StochasticQueue<T>
where T: 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V