Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node{
- public:
- Node(int height){
- this->height = height;
- }
- Node(Key_t key, Mapped_t obj, int height){
- value = std::make_pair(key, obj);
- this->height = height;
- }
- SkipList<Key_t, Mapped_t>::Node *next[height];
- int getHeight(){return height;}
- Key_t getKey(){return value.first;}
- Mapped_t getObj(){return value.second;}
- private:
- std::pair<Key_t, Mapped_t> value;
- int height;
- };
- class Node{
- private:
- std::pair<Key_t, Mapped_t> value;
- int height;
- public:
- Node(int height){
- this->height = height;
- }
- Node(Key_t key, Mapped_t obj, int height){
- value = std::make_pair(key, obj);
- this->height = height;
- }
- SkipList<Key_t, Mapped_t>::Node *next[height];
- int getHeight(){return height;}
- Key_t getKey(){return value.first;}
- Mapped_t getObj(){return value.second;}
- };
- template <class Key_t, class Mapped_t>
- class SkipList{
- public:
- SkipList(int prob, int max){
- probOutOf100 = prob;
- maxHeight = max;
- head = new SkipList<Key_t, Mapped_t>::Node(maxHeight);
- tail = new SkipList<Key_t, Mapped_t>::Node(maxHeight);
- for(int i = 0; i < maxHeight; i++){
- head->next[i] = tail;
- }
- }
- ~SkipList(){
- delete head;
- delete tail;
- }
- class Node{
- public:
- Node(int height){
- this->height = height;
- }
- Node(Key_t key, Mapped_t obj, int height){
- value = std::make_pair(key, obj);
- this->height = height;
- }
- SkipList<Key_t, Mapped_t>::Node *next[height];
- int getHeight(){return height;}
- Key_t getKey(){return value.first;}
- Mapped_t getObj(){return value.second;}
- private:
- std::pair<Key_t, Mapped_t> value;
- int height;
- };
- Node *head;
- Node *tail;
- int probOutOf100;
- int maxHeight;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement