Ensure we cannot remove an item outside the current length of the queue

This commit is contained in:
Zander Khan 2021-01-16 17:52:14 +00:00
parent ecee1cae45
commit a162a21947

View File

@ -191,6 +191,7 @@ pub fn PriorityDequeue(comptime T: type) type {
/// same order as iterator, which is not necessarily priority /// same order as iterator, which is not necessarily priority
/// order. /// order.
pub fn removeIndex(self: *Self, index: usize) T { pub fn removeIndex(self: *Self, index: usize) T {
assert(self.len > index);
const item = self.items[index]; const item = self.items[index];
const last = self.items[self.len - 1]; const last = self.items[self.len - 1];