Skip to content

Make siftUp and siftDown public and edit add in the std.PriorityQueue. #23791

@ANDRVV

Description

@ANDRVV

Summary

As for siftUp and siftDown they should be handled by the user too. The solution is to make them public.
In cache-like systems where an item has been taken you need to do a siftUp to update the priority. Flexibility and control over it is important.

It is also needed in the function addSiftUp that it replaces add. This is because there are some contexts where add should not do a siftUp.

It is not a proposal: the std.PriorityQueue function is just that. And having these limits is an implementation error.

💡 Proposed Solution

pub fn add(self: *Self, elem: T) !void
pub fn addSiftUp(self: *Self, elem: T) !void
pub fn siftUp(self: *Self, index: usize) void
pub fn siftDown(self: *Self, index: usize) void

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions