#ifndef BSTNODE_H
#define BSTNODE_H

template <class T>
class BST;

// a node for the binary search tree
template <class T>
class BSTNode {
	private:
		T data;
		BSTNode<T> *left;  // pointer to left child
		BSTNode<T> *right; // pointer to right child
	public:
		BSTNode(T data);
		~BSTNode();
		T getData();
		BSTNode<T> *getLeft();
		BSTNode<T> *getRight();
		void setLeft(BSTNode<T> *l);
		void setRight(BSTNode<T> *r);
		friend BST<T>; // allow BST class to access private members

};

// constructor
template <class T>
BSTNode<T>::BSTNode(T d) {
	data = d;
	left = right = 0;
}

// destructor
template <class T>
BSTNode<T>::~BSTNode() {
}

template <class T>
T BSTNode<T>::getData() {
	return data;
}

template <class T>
BSTNode<T> *BSTNode<T>::getLeft() {
	return left;
}

template <class T>
BSTNode<T> *BSTNode<T>::getRight() {
	return right;
}

template <class T>
void BSTNode<T>::setLeft(BSTNode<T> *l) {
	left = l;
}

template <class T>
void BSTNode<T>::setRight(BSTNode<T> *r) {
	right = r;
}

#endif
