Struct IndexedPriorityQueue

Source
pub struct IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy, Priorities: Indexed<Index = Index, Output: Ord + Clone>, Positions: Indexed<Index = Index, Output = usize>,
{ /* private fields */ }
Expand description

Indexed Priority Queue.

Implementations§

Source§

impl<Index, Priorities, Positions> IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy, Priorities: Indexed<Index = Index, Output: Ord + Clone>, Positions: Indexed<Index = Index, Output = usize>,

Source

pub fn new( priorities: impl Into<Priorities>, positions: impl Into<Positions>, ) -> Self

Constructs a new, empty IndexedPriorityQueue.

Source

pub fn with_capacity( priorities: impl Into<Priorities>, positions: impl Into<Positions>, capacity: usize, ) -> Self

Constructs a new, empty IndexedPriorityQueue with at least the specified capacity.

Source

pub fn len(&self) -> usize

Returns the number of indices in the indexed priority queue.

Time complexity: O(1)

Source

pub fn is_empty(&self) -> bool

Returns true if the priority queue contains no indices.

Time complexity: O(1)

Source

pub fn contains(&self, index: Index) -> bool

Returns true if the priority queue contains the specified index.

Time complexity: O(1)

Source

pub fn min_priority(&self) -> Option<&Priorities::Output>

Returns the smallest priority in the queue, or None, if it is empty.

Time complexity: O(1)

Source

pub fn get_priority(&self, index: Index) -> Option<&Priorities::Output>

Returns the priority associated with the specified index, or None, if the index is not in the queue.

Time complexity: O(1)

Source

pub fn restore_index(&mut self, index: Index)

Reinserts a previously removed index into the queue with its last associated value.

Time complexity: O(log n)

Source

pub fn remove(&mut self, index: Index) -> Priorities::Output

Removes the specified index and its associated priority from the queue. This method should not be called with indices that are not present in the queue. Returns the removed priority.

Time complexity: O(log n)

Source

pub fn remove_index(&mut self, index: Index)

Removes the specified index from the queue, retaining its associated priority.

Time complexity: O(log n)

Source

pub fn clear(&mut self)

Clears all indices and their priorities from the queue.

Source

pub fn clear_indices(&mut self)

Clears all indices from the queue.

Source

pub fn push( &mut self, index: Index, value: Priorities::Output, ) -> Option<Priorities::Output>

Inserts an index-priority pair into the priority queue. Returns the previous priority associated with the index, if it existed.

Time complexity: O(log n)

Source

pub fn min(&self) -> Option<&Index>

Returns the index associated with the smallest priority in the queue, or None if it is empty.

Time complexity: O(1)

Source

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

Removes and returns the index associated with the smallest priority in the queue, or None if it is empty.

Time complexity: O(log n)

Source

pub fn update_priorities_order_preserving( &mut self, f: impl Fn(&mut Priorities::Output), )

Update the priorities of the values in the heap using a function The function must not change the relative order of any elements in the heap

Source§

impl<Index, Priorities, Positions> IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy, Priorities: Indexed<Index = Index, Output: Ord + Clone>, Positions: Indexed<Index = Index, Output = usize>,

Source

pub fn update_up( &mut self, index: Index, ) -> IPQMutRefUp<'_, Index, Priorities, Positions>

Source§

impl<Index, Priorities, Positions> IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy, Priorities: Indexed<Index = Index, Output: Ord + Clone>, Positions: Indexed<Index = Index, Output = usize>,

Source

pub fn update_down( &mut self, index: Index, ) -> IPQMutRefDown<'_, Index, Priorities, Positions>

Source§

impl<Index, Priorities, Positions> IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy, Priorities: Indexed<Index = Index, Output: Ord + Clone>, Positions: Indexed<Index = Index, Output = usize>,

Source

pub fn update_dyn( &mut self, index: Index, ) -> IPQMutRefDyn<'_, Index, Priorities, Positions>

Trait Implementations§

Source§

impl<Index, Priorities, Positions> Debug for IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy + Debug, Priorities: Indexed<Index = Index, Output: Ord + Clone> + Debug, Positions: Indexed<Index = Index, Output = usize> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Index, Priorities, Positions> Default for IndexedPriorityQueue<Index, Priorities, Positions>
where Index: Copy, Priorities: Indexed<Index = Index, Output: Ord + Clone> + Default, Positions: Indexed<Index = Index, Output = usize> + Default,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<Index, Priorities, Positions> Freeze for IndexedPriorityQueue<Index, Priorities, Positions>
where <Priorities as Indexed>::Output: Sized, Priorities: Freeze, Positions: Freeze,

§

impl<Index, Priorities, Positions> RefUnwindSafe for IndexedPriorityQueue<Index, Priorities, Positions>
where <Priorities as Indexed>::Output: Sized, Priorities: RefUnwindSafe, Positions: RefUnwindSafe, Index: RefUnwindSafe,

§

impl<Index, Priorities, Positions> Send for IndexedPriorityQueue<Index, Priorities, Positions>
where <Priorities as Indexed>::Output: Sized, Priorities: Send, Positions: Send, Index: Send,

§

impl<Index, Priorities, Positions> Sync for IndexedPriorityQueue<Index, Priorities, Positions>
where <Priorities as Indexed>::Output: Sized, Priorities: Sync, Positions: Sync, Index: Sync,

§

impl<Index, Priorities, Positions> Unpin for IndexedPriorityQueue<Index, Priorities, Positions>
where <Priorities as Indexed>::Output: Sized, Priorities: Unpin, Positions: Unpin, Index: Unpin,

§

impl<Index, Priorities, Positions> UnwindSafe for IndexedPriorityQueue<Index, Priorities, Positions>
where <Priorities as Indexed>::Output: Sized, Priorities: UnwindSafe, Positions: UnwindSafe, Index: 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.