From dcdebae395ae9edbf40461b8a1cd31659ad20526 Mon Sep 17 00:00:00 2001 From: enqidu Date: Tue, 7 Jul 2020 17:24:13 +0400 Subject: [PATCH] skip-list documentation-polish --- data_structures/skip_list.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/data_structures/skip_list.cpp b/data_structures/skip_list.cpp index d2ba820f4..782486632 100644 --- a/data_structures/skip_list.cpp +++ b/data_structures/skip_list.cpp @@ -54,7 +54,10 @@ public: void deleteElement(int); void* searchElement(int); void displayList(); + ~SkipList(); }; + + SkipList::SkipList() { level = 0; @@ -63,6 +66,18 @@ SkipList::SkipList() { } +SkipList::~SkipList(){ + delete header; + for(int i=0; i <= level; i++) { + Node *node = header->forward[i]; + Node* temp; + while(node != NULL) { + temp = node; + node = node->forward[i]; + delete temp; + } + } +} /**