File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -391,12 +391,13 @@ E set(int index, E element) // 替换指定位置的元素
391391
392392LinkedList 可以作为FIFO 的队列,使用如下方法:
393393```java
394- add(e)
395- offer(e)
396- remove()
397- poll()
398- element()
399- peek()
394+ // Queue
395+ boolean add(e) // add比offer的区别在于add时如果capacity超了,会报错,而offer不会
396+ boolean offer(e)
397+ E remove() // 返回队列的第一个元素,并且删除,如果队列为空,报NoSuchElementException
398+ E poll() // 返回队列的第一个元素,并且删除,如果队列为空,返回null
399+ E element() // 返回队列的第一个元素,不删除,如果队列为空,报NoSuchElementException
400+ E peek() // 返回队列的第一个元素,不删除,如果队列为空,返回null
400401```
401402
402403LinkedList 也可以作为FILO 的栈,使用如下方法:
@@ -740,8 +741,29 @@ TreeSet实现了NavigableSet接口,因此其支持集合的导航方法,如l
740741```
741742
742743### Queue 接口源码解析
744+
745+ `源码分析`
746+ ```java
747+ public interface Queue <E> extends Collection<E > {
748+ boolean add (e ) // add比offer的区别在于add时如果capacity超了,会报错,而offer不会
749+ boolean offer (e )
750+ E remove () // 返回队列的第一个元素,并且删除,如果队列为空,报NoSuchElementException
751+ E poll () // 返回队列的第一个元素,并且删除,如果队列为空,返回null
752+ E element () // 返回队列的第一个元素,不删除,如果队列为空,报NoSuchElementException
753+ E peek () // 返回队列的第一个元素,不删除,如果队列为空,返回null
754+ }
755+ ```
756+
743757### Deque 接口源码解析
758+
759+ `总结`
760+ ```
761+ 双向队列,继承自Queue 接口,同时提供了丰富的操作队列的方法,具体可参考LinkedList 源码分析
762+ ```
763+
744764##### LinkedList 使用
765+ Go to here [LinkedList源码解析和使用](#LinkedList源码解析和使用)
766+
745767## Map集合下常用实现类详解
746768#### AbstractMap接口源码解析
747769##### HashMap源码解析和使用
You can’t perform that action at this time.
0 commit comments