|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Red-Black tree node definition and validation utilities. More...
#include <tpl_binNode.H>Go to the source code of this file.
Classes | |
| class | RbNode_Data |
| Data portion of a Red-Black tree node. More... | |
| class | RbNode< Key > |
| Declare RbNode type with 128-byte pool allocation. More... | |
| class | RbNodeVtl< Key > |
Macros | |
| #define | COLOR(p) ((p)->getColor()) |
| Access the color of node p. | |
| #define | RED (0) |
| Red color constant (newly inserted nodes are red) | |
| #define | BLACK (1) |
| Black color constant. | |
Typedefs | |
| typedef unsigned char | Color |
| Color type for RB nodes. | |
Functions | |
| template<class Node > | |
| bool | test_black_condition (Node *p, int &max, int bh=0) |
| Test the black-height property of an RB tree. | |
| template<class Node > | |
| bool | is_red_black (Node *node) |
| Test all Red-Black tree properties for a node. | |
| template<class Node > | |
| bool | is_red_black_tree (Node *node) |
| Test RB properties for entire subtree. | |
| template<class Node , class Compare > | |
| bool | is_red_black_bst (Node *node, Compare &cmp) |
| Verify that tree is both a valid RB tree and valid BST. | |
Red-Black tree node definition and validation utilities.
This file defines the RbNode structure for Red-Black trees, including the color attribute (RED or BLACK) and functions to validate RB tree properties.
is_red_black(): Tests all RB propertiestest_black_condition(): Verifies black-height propertyis_red_black_bst(): Verifies RB + BST orderingDefinition in file rbNode.H.
| #define COLOR | ( | p | ) | ((p)->getColor()) |
| #define RED (0) |
Test all Red-Black tree properties for a node.
Validates that:
| Node | RB node type |
| node | Node to test |
Definition at line 157 of file rbNode.H.
References BLACK, COLOR, max(), RED, and test_black_condition().
Referenced by is_red_black_tree().
Verify that tree is both a valid RB tree and valid BST.
Combines RB property validation with BST ordering validation.
| Node | RB node type |
| Compare | Comparison functor for keys |
| node | Root of tree to validate |
| cmp | Comparison function object |
Definition at line 208 of file rbNode.H.
References cmp(), and is_red_black_tree().
Referenced by Aleph::HtdRbTree< Key, Compare >::verify(), and Aleph::Gen_Rb_Tree< NodeType, Key, Compare >::verify().
Test RB properties for entire subtree.
Recursively validates RB properties for node and all descendants.
| Node | RB node type |
| node | Root of subtree to test |
Definition at line 185 of file rbNode.H.
References is_red_black().
Referenced by is_red_black_bst().
Test the black-height property of an RB tree.
Verifies that all paths from node p to leaves have the same number of black nodes (black-height).
| Node | RB node type |
| p | Root of subtree to test |
| max | Reference to store/compare black heights (-1 initially) |
| bh | Current black height along this path (default 0) |
Definition at line 124 of file rbNode.H.
References BLACK, COLOR, max(), and test_black_condition().
Referenced by is_red_black(), and test_black_condition().