Tezzeret  1
Tezzeret
SkipListGen.hpp
1 #ifndef GM_SKIP_LISTS_HPP_
2 #define GM_SKIP_LISTS_HPP_
3 
4 #include <geotypes.hpp>
5 
6 namespace Geometrics
7 {
9  { public:
10  RandomHeight(int maxLvl, float prob);
11  ~RandomHeight() {}
12  int newLevel(void);
13  private:
14  int maxLevel;
15  float probability;
16  };
17  /* End of File */
18 
19 
21  {
22  public:
23  /****************************************************/
24  /* if iValueSize is non-zero, the construction will */
25  /* allocation memory and copy the value, else */
26  /* will just use the pointer. */
27  /****************************************************/
28  SkipNodeGeneric ( int iKeySize,
29  u8* pu8Key,
30  int iValueSize,
31  u8* pu8Value,
32  int iHeight);
34  SkipNodeGeneric (int iHeight);
35  ~SkipNodeGeneric();
36  u8* getKey(void);
37  u8* getValue(void);
38  int getHeight(void);
39  SkipNodeGeneric** m_forwardNodes;
40  private:
41  int nodeHeight;
42  u8* m_pu8Key;
43  u8* m_pu8Value;
44 
45  };
46 
47  typedef int (*SkipListKeyCompareFunction)(u8* pu8Key1, u8* pu8Key2);
48 
50  {
51  public:
52  SkipListGeneric (float fProbability,
53  int iMaxHeight,
54  u8 *iMaxKey,
55  int iKeySize,
56  int iValueSize,
57  SkipListKeyCompareFunction compareFxn );
58  ~SkipListGeneric();
59 
60  bool insert (u8* newKey, u8* newValue);
61  bool insertWithoutCopy (u8* newKey, u8* newValue);
62  bool remove (u8* puKey);
63  bool forget (u8* puKey);
64 
65  u8* retrieve (u8* puKey);
66  u8* previousTo (u8* puKey, u8** foundKey);
67  u8* following (u8* puKey, u8** foundKey);
68  u8* first (u8** foundKey);
69  int size ();
70  private:
71  bool insertInternal (u8* puKey, u8* puValue, bool makeCopy);
72  SkipNodeGeneric *m_head;
73  SkipNodeGeneric *m_psngTail;
74  float probability;
75  int maxHeight,
76  curHeight,
77  m_iKeySize,
78  m_iValueSize;
79  SkipListKeyCompareFunction m_compareFxn;
80  RandomHeight* randGen;
81  };
82 };
83 
84 #endif
Definition: SkipListGen.hpp:9
Definition: SkipListGen.hpp:50
Definition: SkipListGen.hpp:21
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47