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];
164 while(rand() > RAND_MAX/2) h++;
169 if(newheight > m_realheight) {
170 m_realheight = newheight;
172 if (newStart ==
nullptr) {
178 for(
int i = newheight; i-- >
m_height;) {
179 m_start[i] =
nullptr;
181 m_height = newheight;
199 bool valid()
const {
return el !=
nullptr; }
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.
int empty() const
Returns true if the skiplist contains no elements.
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)].
SkiplistIterator(const typename Skiplist< X >::Element *e)
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.
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.
SkiplistIterator< X > & operator=(const SkiplistIterator< X > &it)
Assignment operator.