This commit is contained in:
2025-04-09 14:54:13 -04:00
parent 4a334d4f66
commit d4cbf229a6
697 changed files with 1831 additions and 4 deletions

View File

@@ -817,19 +817,33 @@ impl PartialEq for Order {
}
}
//
// If Some(shadow) then peek should return a reference to shadow, and pop should replace shadow with v[next[0]]
//
struct OrderQueue {
v: Vec<Order>,
shadowing: bool,
shadow: Option<Order>,
next: Vec<usize>,
order_finder: HashMap<usize,usize>, // Maps OrderIDs to locations in v
}
impl OrderQueue {
fn new()->Self {
OrderQueue {
v: Vec::new(),
shadowing: false,
shadow: None,
next: Vec::new(),
order_finder:HashMap::new(),
}
}
fn start_shadow(&mut self) {
assert!(self.shadowing==false);
self.shadowing=true;
self.shadow=if self.v.len()>0 { Some(self.v[0].clone()) } else { None }
}
fn peek(&mut self) -> &mut Order {
self.v.first_mut().unwrap()
}