Trait bagpipe::bag::SharedWeakBag [] [src]

pub trait SharedWeakBag {
    type Item;
    fn new() -> Self;
fn try_push(&self, it: Self::Item) -> Result<(), Self::Item>;
fn try_pop(&self) -> PopResult<Self::Item>; fn push(&self, it: Self::Item) { ... }
fn pop(&self) -> Option<Self::Item> { ... }
fn debug(&self) { ... } }

A best-effort Bag data-structure.

As embodied in the PopResult definition, try_pop is permitted to fail even if the bag in question is not empty.

Associated Types

Required Methods

Returns a new instance of the data-structure.

Attempts to push it onto the data-structure.

If successful, try_push will return true.

Attempts to pop a value from the data-structure.

There is no guaranteed ordering of popped values. This method may fail arbitrarily even if there are accessible values in the data-structure.

Provided Methods

A push operation that will not fail.

The default implementation of push simply calls try_push in a loop. until it succeeds. Depending on the underlying data-structure this may loop infinitely under some circumstances.

push also creates a Guard for the duration of the function to avoid excessive checking in the hot loop.

A pop operation that will not fail.

Same caveats apply to those of push.

Implementors