Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. class Node{
  2. public:
  3. Node(int height){
  4. this->height = height;
  5. }
  6. Node(Key_t key, Mapped_t obj, int height){
  7. value = std::make_pair(key, obj);
  8. this->height = height;
  9. }
  10. SkipList<Key_t, Mapped_t>::Node *next[height];
  11. int getHeight(){return height;}
  12. Key_t getKey(){return value.first;}
  13. Mapped_t getObj(){return value.second;}
  14. private:
  15. std::pair<Key_t, Mapped_t> value;
  16. int height;
  17. };
  18.  
  19. class Node{
  20. private:
  21. std::pair<Key_t, Mapped_t> value;
  22. int height;
  23. public:
  24. Node(int height){
  25. this->height = height;
  26. }
  27. Node(Key_t key, Mapped_t obj, int height){
  28. value = std::make_pair(key, obj);
  29. this->height = height;
  30. }
  31. SkipList<Key_t, Mapped_t>::Node *next[height];
  32. int getHeight(){return height;}
  33. Key_t getKey(){return value.first;}
  34. Mapped_t getObj(){return value.second;}
  35. };
  36.  
  37. template <class Key_t, class Mapped_t>
  38. class SkipList{
  39. public:
  40. SkipList(int prob, int max){
  41. probOutOf100 = prob;
  42. maxHeight = max;
  43. head = new SkipList<Key_t, Mapped_t>::Node(maxHeight);
  44. tail = new SkipList<Key_t, Mapped_t>::Node(maxHeight);
  45. for(int i = 0; i < maxHeight; i++){
  46. head->next[i] = tail;
  47. }
  48. }
  49. ~SkipList(){
  50. delete head;
  51. delete tail;
  52. }
  53.  
  54. class Node{
  55. public:
  56. Node(int height){
  57. this->height = height;
  58. }
  59. Node(Key_t key, Mapped_t obj, int height){
  60. value = std::make_pair(key, obj);
  61. this->height = height;
  62. }
  63. SkipList<Key_t, Mapped_t>::Node *next[height];
  64. int getHeight(){return height;}
  65. Key_t getKey(){return value.first;}
  66. Mapped_t getObj(){return value.second;}
  67. private:
  68. std::pair<Key_t, Mapped_t> value;
  69. int height;
  70. };
  71.  
  72. Node *head;
  73. Node *tail;
  74. int probOutOf100;
  75. int maxHeight;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement