FairQueue
FairQueue is a Rust no_std (alloc) library that implements FIFO (queue) and LIFO (stack) data structures with equitable interleaving of groups of values. Such distancing allows amortized O(1) round-robin retrieval while storing values by reference and avoiding heavy moves. The optional std feature adds zero-cost conveniences for callers that want to collect iterator results.
Example
use ;
let a1 = Event ;
let a2 = Event ;
let b1 = Event ;
let mut queue = new;
queue.insert;
queue.insert;
queue.insert;
assert_eq!;
assert_eq!;
assert_eq!;
let mut stack = new;
stack.push;
stack.push;
stack.push;
assert_eq!;
assert_eq!;
assert_eq!;
API Overview
FairGrouptrait - Defines group identity for items stored in either structure. Implementers usually rely on a key field or pointer identity so that comparisons remain near zero-cost.FairQueue- Implements FIFO queuing while keeping groups spatially separated. Core methods includenew,insert,pop,peek,len,is_empty, andgroup_count. Observability stays cheap through thegroup_headsiterator, withgroup_heads_vecavailable when thestdfeature is enabled.FairStack- Implements LIFO queuing with the same fairness guarantees. The API mirrors the queue withnew,push,pop,peek,peek_group,len,is_empty, andgroup_count. It also exposesgroup_headsand, under thestdfeature,group_heads_vecfor eager collection.
License
Licensed under the BSD Zero Clause License.