cBSTLite Review
template <typename T, class P = LessThan<T> >
class BST
{
public:
typedef T ValueType;
typedef P PredicateType;
T& Get (const T& t);
void Put (const T& t);
bool Retrieve (T& t) const;
void Clear ();
size_t Size () const;
int Height () const;
template < class F >
void Traverse (F f) const;
void Display (std::ostream&, char ofc = '\0') const;
const P& GetPredicate () const;
// proper type
BST ();
explicit BST (P p);
~BST ();
BST ( const BST& );
BST& operator= ( const BST& );
// development assistants
void Dump (std::ostream&) const;
void Dump (std::ostream&, int cw) const;
void Dump (std::ostream&, int cw, char fill) const;
protected:
class Node
{
T value_;
Node * lchild_;
Node * rchild_;
Node (const T& t) : value_(t), lchild_(0), rchild_(0) {}
friend class BST<T,P>;
};
Node * root_;
PredicateType pred_;
static size_t RSize (const Node * n);
static int RHeight (const Node * n);
static void RRelease (Node* n);
static Node* RClone (const Node* n);
template < class F >
static void RTraverse (Node* n, F f);
};