Closed thomastay closed 3 years ago
Just quickly passing through. Shoot me an email to axefrog at gmail and we'll go from there.
@axefrog sent you an email last week, did you get it?
@axefrog sent you an email last week, did you get it?
I have replied now. Sorry for the delay!
don't merge yet, i want to update the package.jsons
Hi @axefrog, I'm working on the same team as @eliranek1. We've found another issue with rebalancing when there is a one element tree. When creating a tree with two elements, the root is black and child is red. However, upon removal of the root, the child is promoted but not set to black. Later on, when another element is pushed, this allows for a red node to have a red child.
A test case which does not rely on the internals is attached. But you can see this by setting a breakpoint after
set(3, 12, tree)
, and noting that there are two consecutive red nodes.This issue seems to have been introduced in https://github.com/frptools/collectable/commit/22afb0335cc7708d21480e03c2e0d75d13413758, in which the check if
if (tree.size > 1)
was added to prevent rebalancing of trees of size 1.The fix is to simply set the root to always be black. This follows the approach in CLRS, where the root is always set to black after rebalancing.
Regarding maintenance, we would be happy to co-maintain the package, you can reach out to Eliran or me. Understand that you are busy, and we also want to be able to publish new versions of this package quickly.