mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
since we are using smart pointers, an explicit destructor is not required
This commit is contained in:
parent
f970ce361c
commit
c15c962f02
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user