libUTL++
SkipListNode.h
1 #pragma once
2 
4 
5 #include <libutl/MaxObject.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
28 
31 {
32  friend class SkipList;
33 
34 public:
36  Object*
37  get() const
38  {
39  return _object;
40  }
41 
43  void set(const Object* object, uint_t level, SkipListNode** update);
44 
46  void
47  set(const Object* object)
48  {
49  _object = const_cast<Object*>(object);
50  }
51 
53  bool
54  isHead() const
55  {
56  return (_prev == nullptr);
57  }
58 
60  bool
61  isTail() const
62  {
63  return (_next[0] == nullptr);
64  }
65 
68  next(uint_t idx = 0) const
69  {
70  return _next[idx];
71  }
72 
75  prev() const
76  {
77  return _prev;
78  }
79 
81  void
83  {
84  _next[i] = node;
85  }
86 
88  void
90  {
91  _prev = node;
92  }
93 
95  void remove(uint_t level, SkipListNode** update);
96 
97 private:
98  Object* _object;
99  SkipListNode* _prev;
100  SkipListNode* _next[1];
101 };
102 
104 
105 UTL_NS_END;
bool isTail() const
Determine whether self is the tail node.
Definition: SkipListNode.h:61
bool isHead() const
Determine whether self is the head node.
Definition: SkipListNode.h:54
void setPrev(SkipListNode *node)
Set the previous node.
Definition: SkipListNode.h:89
SkipList node.
Definition: SkipListNode.h:30
Skip list.
Definition: SkipList.h:51
SkipListNode * next(uint_t idx=0) const
Get the next node.
Definition: SkipListNode.h:68
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
void setNext(uint_t i, SkipListNode *node)
Set the next node.
Definition: SkipListNode.h:82
Root of UTL++ class hierarchy.
Definition: Object.h:52
SkipListNode * prev() const
Get the previous node.
Definition: SkipListNode.h:75