mirror of
https://github.com/ziglang/zig.git
synced 2026-01-05 21:13:24 +00:00
rb: type Tree.sort with SortError
This commit is contained in:
parent
4ab9678b95
commit
ad15a73240
@ -11,6 +11,7 @@ const Red = Color.Red;
|
||||
const Black = Color.Black;
|
||||
|
||||
const ReplaceError = error{NotEqual};
|
||||
const SortError = error{NotUnique}; // The new comparison function results in duplicates.
|
||||
|
||||
/// Insert this into your struct that you want to add to a red-black tree.
|
||||
/// Do not use a pointer. Turn the *rb.Node results of the functions in rb
|
||||
@ -135,7 +136,7 @@ pub const Tree = struct {
|
||||
compareFn: fn (*Node, *Node, *Tree) Order,
|
||||
|
||||
/// Re-sorts a tree with a new compare function
|
||||
pub fn sort(tree: *Tree, newCompareFn: fn (*Node, *Node, *Tree) Order) !void {
|
||||
pub fn sort(tree: *Tree, newCompareFn: fn (*Node, *Node, *Tree) Order) SortError!void {
|
||||
var newTree = Tree.init(newCompareFn);
|
||||
var node: *Node = undefined;
|
||||
while (true) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user