【发布时间】:2015-09-29 04:17:00
【问题描述】:
我的跳过列表的删除方法正在无限循环中!我遵循了这个网站上的伪代码http://www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Map/skip-list-impl.html。除了删除之外,其他方法似乎工作正常。这是我的代码:
public void delete(String k) {
SkipListEntry p = findEntry(k);
if (p.key != k) {
return; // Not found, don't remove
}
while (p != null) {
//need to delete the entry from each list using the "up" or "down" links
p.left.right = p.right;
p.right.left = p.left;
}
}
这是我的完整代码http://pastebin.com/StJRzixN
谢谢
【问题讨论】:
-
您永远不会在循环中更新
p。你认为p != null会如何改变价值?
标签: java skip-lists