Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
ccdb49aa
Commit
ccdb49aa
authored
Aug 02, 2013
by
Mukund Sivaraman
Browse files
[2811] Cleanup color testing code
parent
f36f677e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/memory/domaintree.h
View file @
ccdb49aa
...
...
@@ -356,6 +356,16 @@ private:
}
}
/// \brief Returns if the node color is black
bool
isBlack
()
const
{
return
(
getColor
()
==
BLACK
);
}
/// \brief Returns if the node color is red
bool
isRed
()
const
{
return
(
!
isBlack
());
}
/// \brief Sets the color of this node
void
setColor
(
const
DomainTreeNodeColor
color
)
{
if
(
color
==
RED
)
{
...
...
@@ -1976,14 +1986,14 @@ DomainTree<T>::insertRebalance
// subtree root to its children colored BLACK) but doesn't
// change the red-black properties.
DomainTreeNode
<
T
>*
parent
=
node
->
getParent
();
if
(
parent
->
getColor
()
==
DomainTreeNode
<
T
>::
BLACK
)
{
if
(
parent
->
isBlack
()
)
{
break
;
}
DomainTreeNode
<
T
>*
uncle
=
node
->
getUncle
();
DomainTreeNode
<
T
>*
grandparent
=
node
->
getGrandParent
();
if
((
uncle
!=
NULL
)
&&
(
uncle
->
getColor
()
==
DomainTreeNode
<
T
>::
RED
))
{
if
((
uncle
!=
NULL
)
&&
uncle
->
isRed
(
))
{
// Case 3. Here, the node's parent is colored RED and the
// uncle node is also RED. In this case, the grandparent
// must be BLACK (due to existing red-black state). We set
...
...
@@ -2171,7 +2181,7 @@ DomainTree<T>::dumpTreeHelper(std::ostream& os,
indent
(
os
,
depth
);
os
<<
node
->
getLabels
()
<<
" ("
<<
(
(
node
->
getColor
()
==
DomainTreeNode
<
T
>::
BLACK
)
?
"black"
:
"red"
)
<<
(
node
->
isBlack
(
)
?
"black"
:
"red"
)
<<
")"
;
if
(
node
->
isEmpty
())
{
os
<<
" [invisible]"
;
...
...
@@ -2235,7 +2245,7 @@ DomainTree<T>::dumpDotHelper(std::ostream& os,
}
os
<<
"
\"
] ["
;
if
(
node
->
getColor
()
==
DomainTreeNode
<
T
>::
RED
)
{
if
(
node
->
isRed
()
)
{
os
<<
"color=red"
;
}
else
{
os
<<
"color=black"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment