DoxigAlpha

update

Function parameters

Parameters

#
self:*Self
elem:T
new_elem:T

Priority Dequeue for storing generic data.

Functions

#
PriorityDequeue
Priority Dequeue for storing generic data.

Source

Implementation

#
pub fn update(self: *Self, elem: T, new_elem: T) !void {
    const old_index = blk: {
        var idx: usize = 0;
        while (idx < self.len) : (idx += 1) {
            const item = self.items[idx];
            if (compareFn(self.context, item, elem) == .eq) break :blk idx;
        }
        return error.ElementNotFound;
    };
    _ = self.removeIndex(old_index);
    self.addUnchecked(new_elem);
}