Kstars

SkipListElement.cpp
1/*
2 File: SkipListElement.C
3 Author: Bruno Grossniklaus, 13.11.97
4 Version: 1.0
5 History:
6 13.11.97; Gro; Version 1.0
7*/
8
9#include <iostream> // cout
10
11#include "SkipListElement.h"
12
13////////////////////////////////////////////////////////////////////////////////
14SkipListElement::SkipListElement(long level, Key key, Value value) : myLevel(level), myKey(key), myValue(value)
15{
16 for (int i = 0; i < SKIPLIST_MAXLEVEL; i++)
17 myNext[i] = nullptr;
18}
19
20////////////////////////////////////////////////////////////////////////////////
21SkipListElement *SkipListElement::getElement(long level)
22{
23 if (level > myLevel)
24 {
25 std::cerr << "Error in :"
26 << "SkipListElement::getElement() level:";
27 std::cerr << level << ", my level:" << myLevel << ", max level: " << SKIPLIST_MAXLEVEL << std::endl;
28 return (this);
29 }
30 else
31 {
32 return (myNext[level]);
33 }
34}
35
36////////////////////////////////////////////////////////////////////////////////
37void SkipListElement::setElement(long level, SkipListElement *element)
38{
39 if (level > myLevel)
40 {
41 std::cerr << "Error in :"
42 << "SkipListElement::setElement() level:";
43 std::cerr << level << ", my level:" << myLevel << ", max level: " << SKIPLIST_MAXLEVEL << std::endl;
44 }
45 else
46 {
47 myNext[level] = element;
48 }
49}
Interface for skip list elements See William Pugh's paper: Skip Lists: A Probabilistic Alternative to...
QStringView level(QStringView ifopt)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:51:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.