java - JDK里为什么LinkedList实现了Deque,而ArrayList却没实现?
伊谢尔伦
伊谢尔伦 2017-04-17 11:41:37
0
1
965

可以看到LinkedList implements Deque, 而ArrayList却没有。
另外还有一个ArrayDeque类。

为什么不让List接口继承Deque呢?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
伊谢尔伦

Deque inherits from Queue. In fact, just think that List does not inherit from Queue. It is true that List can easily use remove(Object o) to implement Queue's remove(), but it is generally not designed this way because their meanings are different. Whether to use List to implement Queue is left to the specific class to decide. The answer for LinkedList is yes, and for ArrayList it is no.

As for why ArrayList did not implement Queue, this is because ArrayList itself is just a List covered in Array skin. It is not recommended to insert new data from the top, otherwise the efficiency will be extremely poor. .

ArrayDeque is a textbook deque implementation, and its existence is not controversial.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template