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. | |
~Skiplist () | |
void | add (X item) |
Adds the item item into the skiplist [O'(log n)]. | |
const SkiplistIterator< X > | begin () const |
returns an (forward) iterator for the skiplist | |
void | clear (bool killData=false) |
Clears the current skiplist. | |
bool | empty () const |
Returns true if the skiplist contains no elements. | |
const SkiplistIterator< X > | end () const |
returns an invalid iterator | |
bool | isElement (X item) const |
Returns true if the item item is contained in the skiplist [O'(log n)]. | |
int | size () const |
Returns the current size of the skiplist, i.e., the number of elements. | |
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 52 of file Skiplist.h.
|
inline |
Construct an initially empty skiplist.
Definition at line 76 of file Skiplist.h.
|
inline |
Definition at line 84 of file Skiplist.h.
|
inline |
Adds the item item
into the skiplist [O'(log n)].
Definition at line 103 of file Skiplist.h.
|
inline |
returns an (forward) iterator for the skiplist
Definition at line 156 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 140 of file Skiplist.h.
|
inline |
Returns true if the skiplist contains no elements.
Definition at line 133 of file Skiplist.h.
|
inline |
returns an invalid iterator
Definition at line 159 of file Skiplist.h.
|
inlineprivate |
Definition at line 175 of file Skiplist.h.
|
inline |
Returns true if the item item
is contained in the skiplist [O'(log n)].
Definition at line 90 of file Skiplist.h.
|
inlineprivate |
Definition at line 167 of file Skiplist.h.
|
inline |
Returns the current size of the skiplist, i.e., the number of elements.
Definition at line 130 of file Skiplist.h.
|
friend |
Definition at line 1 of file Skiplist.h.
|
private |
Definition at line 164 of file Skiplist.h.
|
private |
Definition at line 162 of file Skiplist.h.
|
private |
Definition at line 165 of file Skiplist.h.
|
private |
Definition at line 163 of file Skiplist.h.