pub struct PrioritySet<I: PartialEq, const N: usize> { /* private fields */ }
Expand description
PrioritySet is a fixed size Priority Set.
It never allocates, instead dropping the lowest priority item when inserting a new one.
Implementations§
Source§impl<I: PartialEq, const N: usize> PrioritySet<I, N>
impl<I: PartialEq, const N: usize> PrioritySet<I, N>
Sourcepub fn insert(&mut self, priority: Priority, item: I) -> InsertResult
pub fn insert(&mut self, priority: Priority, item: I) -> InsertResult
Inserts an item with priority.
If the item already exists in the set, the priority is updated. The highest priority is chosen between the existing priority and the new priority.
If the set is full the least prioritary item is dropped. If all items are of higher priority than the item being inserted, no change occurs.
Returns true
if the item was inserted, false
if it was dropped.
Sourcepub fn iter(&self) -> impl Iterator<Item = &PriorityEntry<I>>
pub fn iter(&self) -> impl Iterator<Item = &PriorityEntry<I>>
Returns an iterator over the entries
Iteration order is not guaranteed.
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut PriorityEntry<I>>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut PriorityEntry<I>>
Returns a mutable iterator over the entries
Iteration order is not guaranteed.
Sourcepub fn entry(&self, item: &I) -> Option<&PriorityEntry<I>>
pub fn entry(&self, item: &I) -> Option<&PriorityEntry<I>>
Finds an item entry
Sourcepub fn entry_mut(&mut self, item: &I) -> Option<&mut PriorityEntry<I>>
pub fn entry_mut(&mut self, item: &I) -> Option<&mut PriorityEntry<I>>
Returns a mutable entry to an item
Sourcepub fn pop_entry(&mut self) -> Option<PriorityEntry<I>>
pub fn pop_entry(&mut self) -> Option<PriorityEntry<I>>
Pops the highest priority item entry from the set