This commit is contained in:
enqidu
2020-07-07 19:59:54 +04:00
parent 1df1e1eabc
commit 662841bac7

View File

@@ -18,7 +18,7 @@ using std::endl;
#define PROBABILITY 0.5 ///< current probability for "coin toss"
/*
/**
* Node structure [Key][Node*, Node*...]
*/
struct Node {
@@ -30,7 +30,7 @@ struct Node {
Node(int key, int level, void* value);
};
/*
/**
* Creates node with provided key, level and value
*/
Node::Node(int key, int level, void* value) {
@@ -42,7 +42,7 @@ Node::Node(int key, int level, void* value) {
}
}
/*
/**
* SkipList class
*/
class SkipList {
@@ -59,7 +59,7 @@ public:
};
/*
/**
* Skeep List constructor
*/
SkipList::SkipList() {
@@ -68,7 +68,9 @@ SkipList::SkipList() {
header = new Node(-1, MAX_LEVEL, nullptr);
}
/**
* Destructor for skiplist class
*/
SkipList::~SkipList(){
for(int i=0; i <= level; i++) {
Node *node = header->forward[i];
@@ -83,7 +85,7 @@ SkipList::~SkipList(){
}
/*
/**
* Returns random level for skip list;
*/
int SkipList::randomLevel() {
@@ -94,7 +96,7 @@ int SkipList::randomLevel() {
/*
/**
* Inserts elements with given key and value;
* It's level is computed by randomLevel() function.
*/
@@ -135,7 +137,7 @@ void SkipList::insertElement(int key, void* value) {
}
}
/*
/**
* Delete document by key
*/
void SkipList::deleteElement(int key)
@@ -168,7 +170,7 @@ void SkipList::deleteElement(int key)
}
/*
/**
* Searching element in skip list structure
*/
void* SkipList::searchElement(int key) {
@@ -206,7 +208,7 @@ void SkipList::displayList() {
}
/*
/**
* Main function:
* Creates and inserts random 2^[number of levels] elements into the skip lists and than displays it
*/