Java ?????LinkedList??????
???????????? ???????[ 2015/1/15 10:51:25 ] ????????Java LinkedList
public E remove(int index) {
checkElementIndex(index);
return unlink(node(index));
}
E unlink(Node<E> x) {
// assert x != null;
final E element = x.item;
final Node<E> next = x.next;
final Node<E> prev = x.prev;
if (prev == null) {
first = next;
} else {
prev.next = next;
x.prev = null;
}
if (next == null) {
last = prev;
} else {
next.prev = prev;
x.next = null;
}
x.item = null;
size--;
modCount++;
return element;
}
|
????????????????????????ж??????????λ???????????????unlink(Node)????????????????unlink()?????????????????????????????????????е???????????????????????y??????????????????????????????????????y?????????????next;????????????????????????????y?????????????????????y??????????????????????????β??????????????????????????????????????????????????y???????????????????y??????????????????null??????????????????
????f:peek()
????public E peek() {
????final Node<E> f = first;
????return (f == null) ? null : f.item;
????}
???????????????????????ж??????????????????????????
????g:element()
????public E element() {
????return getFirst();
????}
????public E getFirst() {
????final Node<E> f = first;
????if (f == null)
????throw new NoSuchElementException();
????return f.item;
????}
???????????????????
????h:poll()
????public E poll() {
????final Node<E> f = first;
????return (f == null) ? null : unlinkFirst(f);
????}
????private E unlinkFirst(Node<E> f) {
????// assert f == first && f != null;
????final E element = f.item;
????final Node<E> next = f.next;
????f.item = null;
????f.next = null; // help GC
????first = next;
????if (next == null)
????last = null;
????else
????next.prev = null;
????size--;
????modCount++;
????return element;
????}
????????????????????????????unlinkFirst(Node)?????????????????????????????????????????????????
????i:remove()
????public E remove() {
????return removeFirst();
????}
????public E removeFirst() {
????final Node<E> f = first;
????if (f == null)
????throw new NoSuchElementException();
????return unlinkFirst(f);
????}
??????poll()?????к?????????
????j:offer(E)
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11