java有没有天才_帮忙做下啊,JAVA天才进来下

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

this.element = element;

this.next = next;

this.previous = previous;

}

}

private Entry addBefore(E e, Entry entry) {

Entry newEntry = new Entry(e, entry, entry.previous);

newEntry.previous.next = newEntry;

newEntry.next.previous = newEntry;

size++;

modCount++;

return newEntry;

}

private E remove(Entry e) {

if (e == header)

throw new NoSuchElementException();

E result = e.element;

e.previous.next = e.next;

e.next.previous = e.previous;

e.next = e.previous = null;

e.element = null;

size--;

modCount++;

return result;

}

/**

* @since 1.6

*/

public Iterator descendingIterator() {

return new DescendingIterator();

}

/** Adapter to provide descending iterators via ListItr.previous */

private class DescendingIterator implements Iterator {

final ListItr itr = new ListItr(size());

public boolean hasNext() {

return itr.hasPrevious();

}

public E next() {

return itr.previous();

}

public void remove() {

itr.remove();

}

}

/**

* Returns a shallow copy of this LinkedList. (The elements

* themselves are not cloned.)

*

* @return a shallow copy of this LinkedList instance

*/

public Object clone() {

LinkedList clone = null;

try {

clone = (LinkedList) super.clone();

} catch (CloneNotSupportedException e) {

throw new InternalError();

}

// Put clone into "virgin" state

clone.header = new Entry(null, null, null);

clone.header.next = clone.header.previous = clone.header;

clone.size = 0;

clone.modCount = 0;

// Initialize clone with our elements

for (Entry e = header.next; e != header; e = e.next)

clone.add(e.element);

return clone;

}

/**

* Returns an array containing all of the elements in this list

* in proper sequence (from first to last element).

*

The returned array will be "safe" in that no references to it are

* maintained by this list. (In other words, this method must allocate

* a new array). The caller is thus free to modify the returned array.

*

This method acts as bridge between array-based and collection-based

* APIs.

*

* @return an array containing all of the elements in this list

* in proper sequence

*/

public Object[] toArray() {

Object[] result = new Object[size];

int i = 0;

for (Entry e = header.next; e != header; e = e.next)

result[i++] = e.element;

return result;

}

/**

* Returns an array containing all of the elements in this list in

* proper sequence (from first to last element); the runtime type of

* the returned array is that of the specified array. If the list fits

* in the specified array, it is returned therein. Otherwise, a new

* array is allocated with the runtime type of the specified array and

* the size of this list.

*

If the list fits in the specified array with room to spare (i.e.,

* the array has more elements than the list), the element in the array

* immediately following the end of the list is set to null.

* (This is useful in determining the length of the list only if

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值