A randomized skiplist. More...
#include <ogdf/basic/Skiplist.h>
Classes | |
class | Element |
Internal structure to hold the items and internal forward pointers of the skiplist. More... | |
Public Member Functions | |
Skiplist () | |
Construct an initially empty skiplist. More... | |
~Skiplist () | |
void | add (X item) |
Adds the item item into the skiplist [O'(log n)]. More... | |
const SkiplistIterator< X > | begin () const |
returns an (forward) iterator for the skiplist More... | |
void | clear (bool killData=false) |
Clears the current skiplist. More... | |
bool | empty () const |
Returns true if the skiplist contains no elements. More... | |
const SkiplistIterator< X > | end () const |
returns an invalid iterator More... | |
bool | isElement (X item) const |
Returns true if the item item is contained in the skiplist [O'(log n)]. More... | |
int | size () const |
Returns the current size of the skiplist, i.e., the number of elements. More... | |
Private Member Functions | |
void | grow (int newheight) |
int | random_height () |
Private Attributes | |
int | m_height |
int | m_lSize |
int | m_realheight |
Element ** | m_start |
Friends | |
class | Element |
class | SkiplistIterator< X > |
A randomized skiplist.
The elements height is computed using the traditional coin-flip method, using a 50-50 chance to stop growing. The given running times of the methods below are therefore only expected running times.
Definition at line 54 of file Skiplist.h.
|
inline |
Construct an initially empty skiplist.
Definition at line 78 of file Skiplist.h.
|
inline |
Definition at line 86 of file Skiplist.h.
|
inline |
Adds the item item
into the skiplist [O'(log n)].
Definition at line 105 of file Skiplist.h.
|
inline |
returns an (forward) iterator for the skiplist
Definition at line 158 of file Skiplist.h.
|
inline |
Clears the current skiplist.
If killData
is true, the items of the Skiplist (which are stored as pointers) are automatically deleted.
Definition at line 142 of file Skiplist.h.
|
inline |
Returns true if the skiplist contains no elements.
Definition at line 135 of file Skiplist.h.
|
inline |
returns an invalid iterator
Definition at line 161 of file Skiplist.h.
|
inlineprivate |
Definition at line 177 of file Skiplist.h.
|
inline |
Returns true if the item item
is contained in the skiplist [O'(log n)].
Definition at line 92 of file Skiplist.h.
|
inlineprivate |
Definition at line 169 of file Skiplist.h.
|
inline |
Returns the current size of the skiplist, i.e., the number of elements.
Definition at line 132 of file Skiplist.h.
|
friend |
Definition at line 56 of file Skiplist.h.
|
friend |
Definition at line 55 of file Skiplist.h.
|
private |
Definition at line 166 of file Skiplist.h.
|
private |
Definition at line 164 of file Skiplist.h.
|
private |
Definition at line 167 of file Skiplist.h.
|
private |
Definition at line 165 of file Skiplist.h.