util/RedBlackTree: swap colors when swapping with successor

Swapping was incomplete without swapping the colors; this led to
assertion failures under certain conditions.
This commit is contained in:
Max Kellermann 2024-04-10 12:15:22 +02:00 committed by Max Kellermann
parent 3cf0896998
commit 88475f2e2b
1 changed files with 2 additions and 0 deletions

View File

@ -275,6 +275,8 @@ public:
auto &p = *parent;
const auto direction_in_parent = p.GetChildDirection(*this);
std::swap(color, successor.color);
successor.SetChild(Direction::LEFT, GetLeft());
SetChild(Direction::LEFT, nullptr);
SetChild(Direction::RIGHT, successor.GetRight());