since we are using smart pointers, an explicit destructor is not required

This commit is contained in:
Krishna Vedala 2020-07-12 17:04:09 -04:00
parent f970ce361c
commit c15c962f02
No known key found for this signature in database
GPG Key ID: BA19ACF8FC8792F7

View File

@ -67,22 +67,6 @@ class SkipList {
header = std::shared_ptr<Node>(new Node(-1, MAX_LEVEL));
}
/**
* Destructor for skiplist class
*/
~SkipList() {
for (int i = 0; i <= level; i++) {
std::shared_ptr<Node> node = header->forward[i];
std::shared_ptr<Node> temp;
while (node != nullptr) {
temp = node;
node = node->forward[i];
temp.reset();
}
}
header.reset();
}
/**
* Returns random level of the skip list.
* Every higher level is 2 times less likely.