Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tpl_binNodeAux.H File Reference

Binary tree node base definitions and declaration macros. More...

#include <ahDefs.H>
#include <ahAssert.H>
#include <ahNew.H>
Include dependency graph for tpl_binNodeAux.H:

Go to the source code of this file.

Classes

class  BinNode< Key >
 Basic binary node with no extra control data. More...
 
class  BinNodeVtl< Key >
 

Macros

#define CORPUS_BINNODE(name, height, Control_Data)
 Macro to generate binary node class body.
 
#define DECLARE_BINNODE(name, height, Control_Data)
 Declare a binary node class and its virtual destructor variant.
 
#define SET_BINNODE_nullptr_POINTER(ptr, name)
 Initialize the static NullPtr sentinel for a node type.
 

Detailed Description

Binary tree node base definitions and declaration macros.

This file provides macros for declaring binary tree node classes with customizable control data (balance factors, colors, priorities, etc.).

Macro System

The macros generate consistent binary node structures:

Generated Class Members

Each declared node class includes:

  • key: The stored key value
  • lLink, rLink: Left and right child pointers
  • NullPtr: Static sentinel pointer
  • MaxHeight: Maximum tree height constant
  • Constructors for various initialization scenarios

Usage Example

// Define custom control data (e.g., for AVL balance factor)
class MyNodeData {
int balance = 0;
public:
int& getBalance() { return balance; }
void reset() { balance = 0; }
};
// Declare node type with control data
DECLARE_BINNODE(MyNode, 64, MyNodeData);
SET_BINNODE_nullptr_POINTER(nullptr, MyNode);
// Use the node
MyNode<int>* node = new MyNode<int>(42);
#define DECLARE_BINNODE(Name, height, Control_Data)
Specify tree node for a binary tree.
#define SET_BINNODE_nullptr_POINTER(ptr, name)
Initialize the static NullPtr sentinel for a node type.
See also
tpl_binNode.H Extended node with sentinel support
tpl_binNodeUtils.H Node utility functions
Author
Leandro Rabindranath León

Definition in file tpl_binNodeAux.H.

Macro Definition Documentation

◆ CORPUS_BINNODE

#define CORPUS_BINNODE (   name,
  height,
  Control_Data 
)

Macro to generate binary node class body.

Creates a template class with:

  • Key storage and left/right pointers
  • Static NullPtr sentinel
  • Multiple constructors
  • Control data inheritance
Parameters
nameClass name to generate
heightMaximum tree height (for stack sizing)
Control_DataBase class with balance/color data

Definition at line 101 of file tpl_binNodeAux.H.

◆ DECLARE_BINNODE

#define DECLARE_BINNODE (   name,
  height,
  Control_Data 
)
Value:
CORPUS_BINNODE(name, height, Control_Data) \
}; \
CORPUS_BINNODE(name##Vtl, height, Control_Data) \
virtual ~name##Vtl() { /* empty */ } \
}
#define CORPUS_BINNODE(name, height, Control_Data)
Macro to generate binary node class body.

Declare a binary node class and its virtual destructor variant.

Creates two classes:

  • name<Key>: Basic node class
  • nameVtl<Key>: Same with virtual destructor for polymorphism
Parameters
nameBase class name
heightMaximum supported tree height
Control_DataBase class with node-specific data

Definition at line 165 of file tpl_binNodeAux.H.

◆ SET_BINNODE_nullptr_POINTER

#define SET_BINNODE_nullptr_POINTER (   ptr,
  name 
)
Value:
template <class Key> name<Key> * name<Key>::NullPtr = ptr; \
template <class Key> name##Vtl<Key> * name##Vtl<Key>::NullPtr = ptr

Initialize the static NullPtr sentinel for a node type.

Parameters
ptrPointer value for sentinel (usually nullptr)
nameNode class name

Definition at line 178 of file tpl_binNodeAux.H.