|
BDE 4.39.x Production Release
|
#include <bslalg_rbtreenode.h>
This POD-like class describes a node suitable for use in a red-black binary search tree, holding the addresses of the parent, left-child, and right-child nodes (any of which may be 0), as well as a "color" (red or black). This class is a "POD-like" to facilitate efficient allocation and use in the context of a container implementation. In order to meet the essential requirements of a POD type, this class does not define a constructor or destructor. However its data members are private. Since this class will be aligned to a word boundary, a pointer type will be a multiple of 4. This class use this property to reduce its size by storing the color information in the least significant bit of the parent pointer.
RbTreeNode (generally via inheritance), and that holds the "key" value and any associated data.Public Types | |
| enum | Color { BSLALG_RED = 0 , BSLALG_BLACK = 1 } |
Public Member Functions | |
| RbTreeNode ()=default | |
| RbTreeNode (const RbTreeNode &original)=default | |
| ~RbTreeNode ()=default | |
| RbTreeNode & | operator= (const RbTreeNode &rhs)=default |
| void | makeBlack () |
| void | makeRed () |
| void | setParent (RbTreeNode *address) |
| void | setLeftChild (RbTreeNode *address) |
| void | setRightChild (RbTreeNode *address) |
| void | setColor (Color value) |
| void | toggleColor () |
| void | reset (RbTreeNode *parent, RbTreeNode *leftChild, RbTreeNode *rightChild, Color color) |
| RbTreeNode * | parent () |
| RbTreeNode * | leftChild () |
| RbTreeNode * | rightChild () |
| const RbTreeNode * | parent () const |
| bool | isBlack () const |
| bool | isRed () const |
| const RbTreeNode * | leftChild () const |
| const RbTreeNode * | rightChild () const |
| Color | color () const |
|
default |
|
default |
|
default |
|
inline |
Return the color of this node.
|
inline |
Return true if this node is black.
|
inline |
Return true if this node is red.
|
inline |
Return the address of the (modifiable) left child of this node if one exists, and 0 otherwise.
|
inline |
Return the address of the left child of this node if one exists, and 0 otherwise.
|
inline |
Set the color of this node to black.
setColor.
|
inline |
Set the color of this node to red.
setColor.
|
default |
|
inline |
Return the address of the (modifiable) parent of this node if one exists, and 0 otherwise.
|
inline |
Return the address of the parent of this node if one exists, and 0 otherwise.
|
inline |
Reset this object to have the specified parent, leftChild, rightChild, and color property values.
|
inline |
Return the address of the (modifiable) right child of this node if one exists, and 0 otherwise.
|
inline |
Return the address of the right child of this node if one exists, and 0 otherwise.
|
inline |
Set the color of this node to the specified value.
|
inline |
Set the left child of this node to the specified address. If address is 0, then this node will not have a left child.
|
inline |
Set the parent of this node to the specified address. If address is 0, then this node will have not have a parent node (i.e., it will be the root node).
address is aligned to at least two bytes.
|
inline |
Set the right child of this node to the specified address. If address is 0, then this node will not have a right child.
|
inline |
Set the color of this node to the alternative color. If this node's color is red, set it to black, and set it to red otherwise.
setColor.