79 srand((
unsigned int)time(
nullptr));
96 if( cur[h] && *(cur[h]->
entry) < *item )
99 return cur[0] && *(cur[0]->
entry) == *item;
115 if( cur[h] && *(cur[h]->
entry) < *item )
143 item = item->
next[0];
167 while(rand() > RAND_MAX/2) h++;
172 if(newheight > m_realheight) {
173 m_realheight = newheight;
175 if (newStart ==
nullptr) {
181 for(
int i = newheight; i-- >
m_height;) {
182 m_start[i] =
nullptr;
184 m_height = newheight;
202 bool valid()
const {
return el !=
nullptr; }
217 return el == other.
el;
void add(X item)
Adds the item item into the skiplist [O'(log n)].
Declaration of memory manager for allocating small pieces of memory.
Forward-Iterator for Skiplists.
SkiplistIterator< X > & operator++()
Move the iterator one item forward (prefix notation)
bool isElement(X item) const
Returns true if the item item is contained in the skiplist [O'(log n)].
bool operator==(const SkiplistIterator< X > other) const
SkiplistIterator(const typename Skiplist< X >::Element *e)
bool operator!=(const SkiplistIterator< X > other) const
Internal structure to hold the items and internal forward pointers of the skiplist.
const SkiplistIterator< X > begin() const
returns an (forward) iterator for the skiplist
int size() const
Returns the current size of the skiplist, i.e., the number of elements.
bool empty() const
Returns true if the skiplist contains no elements.
SkiplistIterator< X > operator++(int)
Move the iterator one item forward (prefix notation)
void clear(bool killData=false)
Clears the current skiplist.
Skiplist()
Construct an initially empty skiplist.
Element(const X &item, int height)
#define OGDF_NEW_DELETE
Makes the class use OGDF's memory allocator.
const Skiplist< X >::Element * el
const X & operator*() const
Returns the item to which the iterator points.
Basic declarations, included by all source files.
The namespace for all OGDF objects.
bool operator==(const Tuple2< E1, E2 > &t1, const Tuple2< E1, E2 > &t2)
Equality operator for 2-tuples.
const SkiplistIterator< X > end() const
returns an invalid iterator