79 |
|
* @see java.util.concurrent.PriorityBlockingQueue |
80 |
|
* @since 1.5 |
81 |
|
* @author Doug Lea |
82 |
+ |
* @param <E> the type of elements held in this collection |
83 |
|
*/ |
84 |
|
public interface Queue<E> extends Collection<E> { |
85 |
|
|
86 |
|
/** |
87 |
< |
* Inserts the specified element to this queue, if possible. When |
87 |
> |
* Inserts the specified element into this queue, if possible. When |
88 |
|
* using queues that may impose insertion restrictions (for |
89 |
|
* example capacity bounds), method <tt>offer</tt> is generally |
90 |
|
* preferable to method {@link Collection#add}, which can fail to |
97 |
|
boolean offer(E o); |
98 |
|
|
99 |
|
/** |
100 |
< |
* Retrieves and removes the head of this queue, if it is available. |
100 |
> |
* Retrieves and removes the head of this queue, or <tt>null</tt> |
101 |
> |
* if this queue is empty. |
102 |
|
* |
103 |
|
* @return the head of this queue, or <tt>null</tt> if this |
104 |
|
* queue is empty. |
106 |
|
E poll(); |
107 |
|
|
108 |
|
/** |
109 |
< |
* Retrieves and removes the head of this queue. |
110 |
< |
* This method differs |
111 |
< |
* from the <tt>poll</tt> method in that it throws an exception if this |
110 |
< |
* queue is empty. |
109 |
> |
* Retrieves and removes the head of this queue. This method |
110 |
> |
* differs from the <tt>poll</tt> method in that it throws an |
111 |
> |
* exception if this queue is empty. |
112 |
|
* |
113 |
|
* @return the head of this queue. |
114 |
|
* @throws NoSuchElementException if this queue is empty. |
116 |
|
E remove(); |
117 |
|
|
118 |
|
/** |
119 |
< |
* Retrieves, but does not remove, the head of this queue. |
120 |
< |
* This method differs from the <tt>poll</tt> |
120 |
< |
* method only in that this method does not remove the head element from |
121 |
< |
* this queue. |
119 |
> |
* Retrieves, but does not remove, the head of this queue, |
120 |
> |
* returning <tt>null</tt> if this queue is empty. |
121 |
|
* |
122 |
< |
* @return the head of this queue, or <tt>null</tt> if this queue is empty. |
122 |
> |
* @return the head of this queue, or <tt>null</tt> if this queue |
123 |
> |
* is empty. |
124 |
|
*/ |
125 |
|
E peek(); |
126 |
|
|