Crates.io | israeli_queue_etc |
lib.rs | israeli_queue_etc |
version | 0.2.2 |
source | src |
created_at | 2024-07-21 18:17:28.832168 |
updated_at | 2024-10-11 20:35:53.745884 |
description | various queues |
homepage | |
repository | https://github.com/Cobord/israeli |
max_upload_size | |
id | 1310496 |
size | 44,778 |
In order to create a uniform set of functions that all sorts of priority queues use, they are encompassed in this trait. This is even if the implementer is doing more than an ordinary PriorityQueue like the IsraeliQueue is.
This isn't really an Israeli queue, because we have a shibboleth rather than iterating through to look for friends. But by using a trait with a generic we can avoid that iteration.
The items must implement Friendly
That way we have the regular priority queue for the shibboleths and how the shibboleths translate to nonempty lists of items.
The specification of how priorities combine when a new item joins a currently waiting friend group is variable. Often it is described as being the maximum priority of any of the friends. Sometimes it is the sum. Instead of committing to one of these, the function to do so is part of the queue itself. It defaults to using the maximum, but you can change it.
Consider the bucket queue, each bucket stores items of the same priority. Instead of that here we have a coarse grained priority which is a monotone function of the original priorities. The individual buckets are now something that implements AbstractPriorityQueue and the AbstractPriorityQueue operations of the nested queue use those operations on the individual buckets as appropriate
If priorities don't matter a transparent wrapper of VecDequeue implements these operations and ignores the priorities
PriorityQueue from the priority_queue crate implements the trait as well.