Java ?????LinkedList??????
???????????? ???????[ 2015/1/15 10:51:25 ] ????????Java LinkedList
public boolean offer(E e) {
return add(e);
}
public boolean offerFirst(E e) {
addFirst(e);
return true;
}
public boolean offerLast(E e) {
addLast(e);
return true;
}
public boolean add(E e) {
linkLast(e);
return true;
}
void linkLast(E e) {
final Node<E> l = last;
final Node<E> newNode = new Node<>(l?? e?? null);
last = newNode;
if (l == null)
first = newNode;
else
l.next = newNode;
size++;
modCount++;
}
private void linkFirst(E e) {
final Node<E> f = first;
final Node<E> newNode = new Node<>(null?? e?? f);
first = newNode;
if (f == null)
last = newNode;
else
f.prev = newNode;
size++;
modCount++;
}
|
????offer(E)???????????????β??offerFirst??E???????????????????offerLast??E?????????ú?offer(E)????????
????K??push(E)
????public void push(E e) {
????addFirst(e);
????}
????public void addFirst(E e) {
????linkFirst(e);
????}
????private void linkFirst(E e) {
????final Node<E> f = first;
????final Node<E> newNode = new Node<>(null?? e?? f);
????first = newNode;
????if (f == null)
????last = newNode;
????else
????f.prev = newNode;
????size++;
????modCount++;
????}
??????????????????????????
????l:pop()
??????
???·???
??????????????????
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