| ... | ... | @@ -11,6 +11,7 @@ const Red = Color.Red; |
| 11 | 11 | const Black = Color.Black; |
| 12 | 12 | |
| 13 | 13 | const ReplaceError = error{NotEqual}; |
| 14 | const SortError = error{NotUnique}; // The new comparison function results in duplicates. |
| 14 | 15 | |
| 15 | 16 | /// Insert this into your struct that you want to add to a red-black tree. |
| 16 | 17 | /// Do not use a pointer. Turn the *rb.Node results of the functions in rb |
| ... | ... | @@ -135,7 +136,7 @@ pub const Tree = struct { |
| 135 | 136 | compareFn: fn (*Node, *Node, *Tree) Order, |
| 136 | 137 | |
| 137 | 138 | /// Re-sorts a tree with a new compare function |
| 138 | | pub fn sort(tree: *Tree, newCompareFn: fn (*Node, *Node, *Tree) Order) !void { |
| 139 | pub fn sort(tree: *Tree, newCompareFn: fn (*Node, *Node, *Tree) Order) SortError!void { |
| 139 | 140 | var newTree = Tree.init(newCompareFn); |
| 140 | 141 | var node: *Node = undefined; |
| 141 | 142 | while (true) { |