diff options
| author | Zander Khan <git@zander.xyz> | 2021-01-16 18:11:26 +0000 |
|---|---|---|
| committer | Zander Khan <git@zander.xyz> | 2021-01-16 18:11:26 +0000 |
| commit | c6986f29f94ee404ae3a3221449dc4af5599ca1f (patch) | |
| tree | aa59a32a53037ce289b0dd4ef0b9f6ec9969c2f6 /lib/std/priority_dequeue.zig | |
| parent | 4600b489a6daf3990afc8464dd7f2b9a1a4efa72 (diff) | |
| download | zig-c6986f29f94ee404ae3a3221449dc4af5599ca1f.tar.gz zig-c6986f29f94ee404ae3a3221449dc4af5599ca1f.zip | |
Fix update might change an element no longer in the queue
Diffstat (limited to 'lib/std/priority_dequeue.zig')
| -rw-r--r-- | lib/std/priority_dequeue.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/std/priority_dequeue.zig b/lib/std/priority_dequeue.zig index 9dbb457bac..0d789bbdc8 100644 --- a/lib/std/priority_dequeue.zig +++ b/lib/std/priority_dequeue.zig @@ -389,7 +389,7 @@ pub fn PriorityDequeue(comptime T: type) type { } pub fn update(self: *Self, elem: T, new_elem: T) !void { - var old_index: usize = std.mem.indexOfScalar(T, self.items, elem) orelse return error.ElementNotFound; + var old_index: usize = std.mem.indexOfScalar(T, self.items[0 .. self.len - 1], elem) orelse return error.ElementNotFound; _ = self.removeIndex(old_index); self.addUnchecked(new_elem); } |
