Advertisement
Guest User

Untitled

a guest
Jun 8th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. using namespace std;
  2.  
  3. typedef enum colore{R, B} Color; //0->Red 1->Black
  4.  
  5. template<typename T>
  6. class Nodo
  7. {
  8.     private:
  9.         int key;
  10.         Nodo<T> *parent;
  11.         Nodo<T> *left;  
  12.         Nodo<T> *right;
  13.         Color color;
  14.         T data;
  15.     public:
  16.         Nodo() : parent{nullptr}, left{nullptr},right{nullptr} {;}
  17.         Nodo(int key, T data): parent{nullptr}, left{nullptr},right{nullptr}{ this->key = key; this->data = data; }
  18.         Nodo(int key, T data, Color c) : parent{nullptr}, left{nullptr},right{nullptr}{this->key=key; this->data=data; color = c; }
  19.         int getKey(){ return key; }
  20.         void setKey(int a){this->key=a;}
  21.  
  22.         T& getData(){ return data; }
  23.         void setData(T dat){data = dat;}
  24.  
  25.         void setParent(Nodo<T> *p){ parent=p; }
  26.         Nodo<T> *getParent(){ return parent; }
  27.  
  28.         void setLeft(Nodo<T> *l){ left=l; }
  29.         Nodo<T> *getLeft(){ return left; }
  30.  
  31.         void setRight(Nodo<T> *r){ right=r; }
  32.         Nodo<T> *getRight(){ return right; }
  33.  
  34.         void setColor(Color c){ color = c; }
  35.         Color getColor(){ return color; }
  36.  
  37.         virtual ~Nodo() {;}
  38. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement