Fix SkipList remove operation (#3160)

This commit is contained in:
Artem Boiarshinov
2022-06-22 16:56:35 +03:00
committed by GitHub
parent e59568bc5e
commit d14a5d1eed
2 changed files with 19 additions and 3 deletions

View File

@ -117,7 +117,9 @@ public class SkipList<E extends Comparable<E>> {
}
for (int i = 0; i <= layer; i++) {
current.previous(i).setNext(i, current.next(i));
current.next(i).setPrevious(i, current.previous(i));
if (current.next(i) != null) {
current.next(i).setPrevious(i, current.previous(i));
}
}
size--;
}