BDE 4.14.0 Production release
|
#include <bslalg_rbtreenode.h>
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) |
Set the color of this node to the specified 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 |
Return true if this node is black. | |
bool | isRed () const |
Return true if this node is red. | |
const RbTreeNode * | leftChild () const |
const RbTreeNode * | rightChild () const |
Color | color () const |
Return the color of this node. | |
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. Note that this type does not contain any "payload" member data: Clients creating a red-black binary search tree must define an appropriate node type that incorporates RbTreeNode
(generally via inheritance), and that holds the "key" value and any associated data.
|
default |
|
default |
|
default |
|
inline |
|
inline |
|
inline |
|
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. Note that this operation is at least as fast as (and potentially faster than) setColor
.
|
inline |
Set the color of this node to red. Note that this operation is at least as fast as (and potentially faster than) 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 |
|
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). The behavior is undefined unless 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. Note that this operation is at least as fast as (and potentially faster than) setColor
.