QueueStorage

Trait QueueStorage 

Source
pub trait QueueStorage {
    type Priority;
    type Item;

    // Required methods
    fn is_empty(&self, p: &Point<'_>) -> bool;
    fn pop(&self, p: &Point<'_>) -> Option<Self::Item>;
    fn push(&self, item: Self::Item, p: &Point<'_>);
    fn push_with_priority(
        &self,
        priority: Self::Priority,
        item: Self::Item,
        p: &Point<'_>,
    );
    fn remove_by<F>(&self, predicate: F, p: &Point<'_>) -> Option<Self::Item>
       where F: Fn(&Self::Item) -> bool + Clone;
    fn exists<F>(&self, predicate: F, p: &Point<'_>) -> bool
       where F: Fn(&Self::Item) -> bool + Clone;
    fn find<F>(&self, predicate: F, p: &Point<'_>) -> Option<Self::Item>
       where F: Fn(&Self::Item) -> bool + Clone,
             Self::Item: Clone;
}
Expand description

Represents a queue storage.

The queue storage either supports push, or push_with_priority, but it cannot support the both methods simulateneously.

Required Associated Types§

Source

type Priority

The type of priorities, if push_with_priority is supported. Otherwise, it may define the () type.

Source

type Item

The type of items.

Required Methods§

Source

fn is_empty(&self, p: &Point<'_>) -> bool

Test whether the storage is empty.

Source

fn pop(&self, p: &Point<'_>) -> Option<Self::Item>

Pop the front item.

Source

fn push(&self, item: Self::Item, p: &Point<'_>)

Push an item, or panic if only push_with_priority is supported.

Source

fn push_with_priority( &self, priority: Self::Priority, item: Self::Item, p: &Point<'_>, )

Push an item with the specified priority, or panic if only push is supported.

Source

fn remove_by<F>(&self, predicate: F, p: &Point<'_>) -> Option<Self::Item>
where F: Fn(&Self::Item) -> bool + Clone,

Try to remove an item satisfying the specified predicate and return the item removed.

Source

fn exists<F>(&self, predicate: F, p: &Point<'_>) -> bool
where F: Fn(&Self::Item) -> bool + Clone,

Detect whether there is an element satisfying the specified predicate in the queue.

Source

fn find<F>(&self, predicate: F, p: &Point<'_>) -> Option<Self::Item>
where F: Fn(&Self::Item) -> bool + Clone, Self::Item: Clone,

Find an element satisfying the specified predicate.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> QueueStorage for FCFSStorage<T>
where T: Clone + 'static,

Source§

impl<T> QueueStorage for LCFSStorage<T>
where T: Clone + 'static,