private T remove(int index) {
if (index < 0 || index > size)
return null;
Node cur = head;
for (int j = 0; j < index && cur.next != null; j++) {
cur = cur.next;
}
Node r = cur;
// Node storeAddressOfPreviousPointer = cur.prev; // save the address of the previous node from this current
// Node storeAddressOfNextPointer = cur.next; // save the address of the next node from this current
// storeAddressOfNextPointer.prev = storeAddressOfPreviousPointer;
// storeAddressOfPreviousPointer.next = storeAddressOfNextPointer;
cur.next.prev = cur.prev;
cur.prev.next = cur.next;
size--;
modCount++;
return r.data;
}Ivan Zelenkov
28 уровень
Помогите пожалуйста с методом remove в двусвязном списке? Правильно ли что строки с 10 по 13 равны тем что с 15 по 16? И правильно ли вообще реализован метод, как вы бы его улучшили?
Новый
Комментарии
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
У этой страницы еще нет ни одного комментария