mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 05:12:40 +02:00
graphics/deko3d: fix and simplify rbtree code
This commit is contained in:
parent
b55cb17676
commit
0947425fc5
@ -192,7 +192,7 @@ void CIntrusiveTreeBase::remove(N* node)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
child = node->left() ? node->right() : node->left();
|
child = node->left() ? node->left() : node->right();
|
||||||
parent = node->getParent();
|
parent = node->getParent();
|
||||||
color = node->getColor();
|
color = node->getColor();
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public:
|
|||||||
|
|
||||||
T* first() const { return toType(minmax(N::Left)); }
|
T* first() const { return toType(minmax(N::Left)); }
|
||||||
T* last() const { return toType(minmax(N::Right)); }
|
T* last() const { return toType(minmax(N::Right)); }
|
||||||
bool empty() const { return m_root != nullptr; }
|
bool empty() const { return m_root == nullptr; }
|
||||||
void clear() { m_root = nullptr; }
|
void clear() { m_root = nullptr; }
|
||||||
|
|
||||||
T* prev(T* node) const { return toType(walk(toNode(node), N::Left)); }
|
T* prev(T* node) const { return toType(walk(toNode(node), N::Left)); }
|
||||||
@ -194,31 +194,11 @@ public:
|
|||||||
mode != UpperBound ? N::Left : N::Right,
|
mode != UpperBound ? N::Left : N::Right,
|
||||||
[&lambda](N* curnode) { return lambda(toType(curnode)); });
|
[&lambda](N* curnode) { return lambda(toType(curnode)); });
|
||||||
|
|
||||||
switch (mode)
|
if (mode != Exact) {
|
||||||
{
|
if (mode == UpperBound && node)
|
||||||
default:
|
|
||||||
case Exact:
|
|
||||||
break;
|
|
||||||
case LowerBound:
|
|
||||||
if (!node && parent)
|
|
||||||
{
|
|
||||||
if (&parent->left() == &point)
|
|
||||||
node = parent;
|
|
||||||
else
|
|
||||||
node = walk(parent, N::Right);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case UpperBound:
|
|
||||||
if (node)
|
|
||||||
node = walk(node, N::Right);
|
node = walk(node, N::Right);
|
||||||
else if (parent)
|
else if (!node && parent)
|
||||||
{
|
node = &parent->left() == &point ? parent : walk(parent, N::Right);
|
||||||
if (&parent->right() == &point)
|
|
||||||
node = walk(parent, N::Right);
|
|
||||||
else
|
|
||||||
node = parent;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return toType(node);
|
return toType(node);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user