Cheat Sheet


STL Data Structures and Relevant Methods

Class Definitions of Data Structures from Class

class Dnode {
  public:
    string s;
    Dnode *flink;
    Dnode *blink;
};

class Dlist {
  public:
    Dlist();
    ~Dlist();
    int Empty();
    int Size();
    void Push_Front(string s);
    void Push_Back(string s);
    string Pop_Front();
    string Pop_Back();
    Dnode *Begin();
    Dnode *End();
    Dnode *Rbegin();
    Dnode *Rend();
    void Insert_Before(string s, Dnode *n);
    void Insert_After(string s, Dnode *n);
    void Erase(Dnode *n);
  protected:
    Dnode *sentinel;
    int size;
};
class Qnode {
  public:
    string s;
    Qnode *ptr;
};

class Queue {
  public:
    Queue();
    ~Queue();
    int Empty();
    int Size();
    void Push(string s);
    string Pop();
  protected:
    Qnode *first;
    Qnode *last;
    int size;
};
class Stacknode {
  public:
    string s;
    Stacknode *next;
};

class Stack {
  public:
    Stack();
    ~Stack();
    int Empty();
    void Push(string s);
    string Pop();
  protected:
    Stacknode *top;
};

class BSTNode {
  public:
    BSTNode *left;
    BSTNode *right;
    BSTNode *parent;
    string key;
    void *val;
};
class BSTree {
  public:
    BSTree();
    ~BSTree();
    int Insert(string key, void *val);
    void *Find(string key);
    int Delete(string key);
    void Print();
    int Size();
    int Empty();
    vector  Sorted_Vector();
  protected:
    BSTNode *sentinel;
    int size;
    vector  array;
   
    void recursive_inorder_print(int level, BSTNode *n);
    void recursive_make_vector(BSTNode *n);
    void recursive_destroy(BSTNode *n);

};