Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- typedef enum colore{R, B} Color; //0->Red 1->Black
- template<typename T>
- class Nodo
- {
- private:
- int key;
- Nodo<T> *parent;
- Nodo<T> *left;
- Nodo<T> *right;
- Color color;
- T data;
- public:
- Nodo() : parent{nullptr}, left{nullptr},right{nullptr} {;}
- Nodo(int key, T data): parent{nullptr}, left{nullptr},right{nullptr}{ this->key = key; this->data = data; }
- Nodo(int key, T data, Color c) : parent{nullptr}, left{nullptr},right{nullptr}{this->key=key; this->data=data; color = c; }
- int getKey(){ return key; }
- void setKey(int a){this->key=a;}
- T& getData(){ return data; }
- void setData(T dat){data = dat;}
- void setParent(Nodo<T> *p){ parent=p; }
- Nodo<T> *getParent(){ return parent; }
- void setLeft(Nodo<T> *l){ left=l; }
- Nodo<T> *getLeft(){ return left; }
- void setRight(Nodo<T> *r){ right=r; }
- Nodo<T> *getRight(){ return right; }
- void setColor(Color c){ color = c; }
- Color getColor(){ return color; }
- virtual ~Nodo() {;}
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement