-
Notifications
You must be signed in to change notification settings - Fork 51.2k
Open
Description
@Override
public void delete(Key key) {
if (first == null)
return;
if (first.key.equals(key))
first = first.next;
Node pre = first, cur = first.next;
while (cur != null) {
if (cur.key.equals(key)) {
pre.next = cur.next;
return;
}
pre = pre.next;
cur = cur.next;
}
}
应该改成
@Override
public void delete(Key key) {
if (first == null)
return;
if (first.key.equals(key)) {
first = first.next;
return;
}
Node pre = first, cur = first.next;
while (cur != null) {
if (cur.key.equals(key)) {
pre.next = cur.next;
return;
}
pre = pre.next;
cur = cur.next;
}
}
Metadata
Metadata
Assignees
Labels
No labels