When using a custom comparator, the test to see whether the node's key
is different to the parent key is broken. It inadvertently tests
against the node's own key, instead of the parent.
Herewith the trivial patch.
--- src/RedBlack.pm (revision 15361)
+++ src/RedBlack.pm (working copy)
@@ -137,7 +137,7 @@
return $val;
}
$node = $parent->new($key, $value);
- if ($this->{'cmp'} ? $this->{'cmp'}->($key, $node->key) < 0
+ if ($this->{'cmp'} ? $this->{'cmp'}->($key, $parent->key) < 0
: $key lt $parent->key) {
$parent->left($node);
} else {
Credit for this to Andre Lucas <andre@ae-35.com> who found and fixed it,
I'm just reporting it on his behalf.