From ea57ad29cd350a265be297a49bc8c65c8dfcc825 Mon Sep 17 00:00:00 2001 From: enqidu Date: Tue, 7 Jul 2020 19:55:47 +0400 Subject: [PATCH] improve --- data_structures/skip_list.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/data_structures/skip_list.cpp b/data_structures/skip_list.cpp index 5881f5d27..eb8e5cd87 100644 --- a/data_structures/skip_list.cpp +++ b/data_structures/skip_list.cpp @@ -23,26 +23,28 @@ using std::endl; */ struct Node { int key; - /* pointer of value */ + //pointer of value void* value; - /*Forward Array*/ + //Forward Array vector forward; Node(int key, int level, void* value); }; /** - * Creates node with provided key, level and value; + * Creates node with provided key, level and value */ Node::Node(int key, int level, void* value) { this->key = key; - /*Initialization of forward vector*/ + //Initialization of forward vector for (int i = 0; i < (level+1); i++){ forward.push_back(nullptr); } } -// Class for Skip list +/** + * SkipList class +*/ class SkipList { int level; Node *header; @@ -57,12 +59,12 @@ public: }; -/**\ - * Skeep List constructor; +/** + * Skeep List constructor */ SkipList::SkipList() { level = 0; - /* Header initialization*/ + // Header initialization header = new Node(-1, MAX_LEVEL, nullptr); } @@ -117,7 +119,7 @@ void SkipList::insertElement(int key, void* value) { if(rlevel > level) { for(int i=level+1;i