mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 14:34:05 +08:00
Fix SkipList remove operation (#3160)
This commit is contained in:

committed by
GitHub

parent
e59568bc5e
commit
d14a5d1eed
@ -42,12 +42,26 @@ class SkipListTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void remove() {
|
||||
void removeFromHead() {
|
||||
SkipList<String> skipList = createSkipList();
|
||||
String mostLeftElement = skipList.get(0);
|
||||
int initialSize = skipList.size();
|
||||
print(skipList);
|
||||
|
||||
skipList.remove("a");
|
||||
skipList.remove(mostLeftElement);
|
||||
|
||||
print(skipList);
|
||||
assertEquals(initialSize - 1, skipList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void removeFromTail() {
|
||||
SkipList<String> skipList = createSkipList();
|
||||
String mostRightValue = skipList.get(skipList.size() - 1);
|
||||
int initialSize = skipList.size();
|
||||
print(skipList);
|
||||
|
||||
skipList.remove(mostRightValue);
|
||||
|
||||
print(skipList);
|
||||
assertEquals(initialSize - 1, skipList.size());
|
||||
|
Reference in New Issue
Block a user