BloombergLP::bslalg::RbTreeNode

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.

Synopsis

Declared in <bslalg_rbtreenode.h>

class RbTreeNode;

Enums

NameDescription
Color Enumeration of the two colors used by red-black tree nodes.

Member Functions

NameDescription
color Return the color of this node.
isBlack Return true if this node is black.
isRed Return true if this node is red.
leftChild leftChild overloads
makeBlack Set the color of this node to black. Note that this operation is at least as fast as (and potentially faster than) setColor.
makeRed Set the color of this node to red. Note that this operation is at least as fast as (and potentially faster than) setColor.
parent parent overloads
reset Reset this object to have the specified parent, leftChild, rightChild, and color property values.
rightChild rightChild overloads
setColor Set the color of this node to the specified value.
setLeftChild Set the left child of this node to the specified address. If address is 0, then this node will not have a left child.
setParent 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.
setRightChild Set the right child of this node to the specified address. If address is 0, then this node will not have a right child.
toggleColor 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.

Derived Classes

NameDescription
TreeNode This POD-like class describes a node suitable for use in a red-black binary search tree of values of the parameterized VALUE. 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. The manipulator, value, returns a modifiable reference to d_value so that it may be constructed in-place by the appropriate bsl::allocator_traits object.