I need an STL-like bidirectional iterator (operator<, begin(), rbegin(), end(), rend()) as an inner class to the following (I already spent considerable time all by myself to put together a working tree from a C# article in J of Object Tech and translated it to C++):
template<typename K, typename V> class rbtree {
public:
rbtree(){
root = NULL;
numberElements = 0;
insertedNode = NULL;
nodeBeingDeleted = NULL; // Set in DeleteNode
siblingToRight = false; // Sibling of curNode
parentToRight = false; // Of grand parent
nodeToDeleteRed = false; // Color of deleted node
}
//...
private:
struct Node {
// Fields
K key; // Generic object held by each node
Node* left; Node* right; Node* parent; // Links to children and parent
bool red;// = true; // Color of node
// Constructor
Node(){
red = true;
}
Node(K key, Node* parent) {
this->key = key;
this->parent = parent;
left = NULL; right = NULL;
red = true;
}
};
// Fields
Node* root;
//...
};