| ... | @@ -391,7 +391,12 @@ pub fn PriorityDequeue(comptime T: type, comptime Context: type, comptime compar | ... | @@ -391,7 +391,12 @@ pub fn PriorityDequeue(comptime T: type, comptime Context: type, comptime compar |
| 391 | } | 391 | } |
| 392 | | 392 | |
| 393 | pub fn update(self: *Self, elem: T, new_elem: T) !void { | 393 | pub fn update(self: *Self, elem: T, new_elem: T) !void { |
| 394 | var old_index: usize = std.mem.indexOfScalar(T, self.items[0..self.len], elem) orelse return error.ElementNotFound; | 394 | const old_index = blk: { |
| | 395 | for (self.items) |item, idx| { |
| | 396 | if (compareFn(self.context, item, elem).compare(.eq)) break :blk idx; |
| | 397 | } |
| | 398 | return error.ElementNotFound; |
| | 399 | }; |
| 395 | _ = self.removeIndex(old_index); | 400 | _ = self.removeIndex(old_index); |
| 396 | self.addUnchecked(new_elem); | 401 | self.addUnchecked(new_elem); |
| 397 | } | 402 | } |