Skip to content

Proposal: Make Red-Black tree in std.rb generic #2

Open
@joachimschmidt557

Description

@joachimschmidt557

At the moment, the implementation of red-black trees in the standard library are not generic and need to be embedded in other structs in order to work as intended.

https://github.com/ziglang/zig/blob/a2bb246db4c2bb88f402215d5db79a535dbff4b6/lib/std/rb.zig#L16-L27

This is in contrast to other data structures in the standard library such as the linked lists, which are generic:

https://github.com/ziglang/zig/blob/a2bb246db4c2bb88f402215d5db79a535dbff4b6/lib/std/linked_list.zig#L15

https://github.com/ziglang/zig/blob/a2bb246db4c2bb88f402215d5db79a535dbff4b6/lib/std/linked_list.zig#L164

https://github.com/ziglang/zig/blob/a2bb246db4c2bb88f402215d5db79a535dbff4b6/lib/std/atomic/queue.zig#L10

https://github.com/ziglang/zig/blob/a2bb246db4c2bb88f402215d5db79a535dbff4b6/lib/std/atomic/stack.zig#L8

Are there any downsides to making the RBTree Node and Tree data structures generic like the other pointer-oriented data structures?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions