Tezzeret  1
Tezzeret
SkipLists.hpp
1 /*
2  * GmRingBuffer.hpp
3  *
4  * Created on: Jul 23, 2016
5  * Author: rcram
6  */
7 
8 #ifndef GM_SKIP_LISTS_HPP_
9 #define GM_SKIP_LISTS_HPP_
10 
11 namespace Geometrics
12 {
13  class RandomHeight
14  { public:
15  RandomHeight(int maxLvl, float prob);
16  ~RandomHeight() {}
17  int newLevel(void);
18  private:
19  int maxLevel;
20  float probability;
21  };
22  /* End of File */
23 
24 
25  struct Product
26  {
27  float cost;
28  int quantity;
29  int location;
30  };
31  typedef Product productData;
32  template <class Key, class Obj>
33  class SkipList;
34  template <class Key, class Obj>
35  class SkipNode
36  {
37  public:
38  SkipNode(Key*, Obj*, int);
39  SkipNode(int);
40  ~SkipNode();
41  Key* getKey(void);
42  Obj* getObj(void);
43  int getHgt(void);
44  SkipNode** fwdNodes;
45  private:
46  int nodeHeight;
47  Key* key;
48  Obj* obj;
49  };
50 
51  template <class Key, class Obj>
52  class SkipList
53  {
54  public:
55  SkipList(float,int,Key*);
56  ~SkipList();
57  bool insert(Key*, Obj*);
58  bool remove(Key*);
59  Obj* retrieve(Key*);
60  // void dump(ofstream&);
61  private:
62  SkipNode<Key,Obj>* head;
63  SkipNode<Key,Obj>* tail;
64  float probability;
65  int maxHeight;
66  int curHeight;
67  RandomHeight* randGen;
68  };
69 };
70 #endif
Definition: SkipListGen.hpp:9
Definition: SkipLists.hpp:53
Definition: SkipLists.hpp:36
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47
Definition: SkipLists.hpp:26