jdk/src/java.base/share/classes/java/util/Queue.java
author chegar
Tue, 07 Apr 2015 10:33:08 +0100
changeset 29816 43ad6bf3975b
parent 25859 3317bb8137f4
child 32991 b27c76b82713
permissions -rw-r--r--
8076442: Cannot fully read BitSet.stream() if bit Integer.MAX_VALUE is set Reviewed-by: alanb, henryjen
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * This file is available under and governed by the GNU General Public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * License version 2 only, as published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * However, the following notice accompanied the original version of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * file:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * Written by Doug Lea with assistance from members of JCP JSR-166
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * Expert Group and released to the public domain, as explained at
9242
ef138d47df58 7034657: Update Creative Commons license URL in legal notices
dl
parents: 5506
diff changeset
    33
 * http://creativecommons.org/publicdomain/zero/1.0/
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
package java.util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * A collection designed for holding elements prior to processing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * Besides basic {@link java.util.Collection Collection} operations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * queues provide additional insertion, extraction, and inspection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * operations.  Each of these methods exists in two forms: one throws
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * an exception if the operation fails, the other returns a special
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    44
 * value (either {@code null} or {@code false}, depending on the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * operation).  The latter form of the insert operation is designed
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    46
 * specifically for use with capacity-restricted {@code Queue}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * implementations; in most implementations, insert operations cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <table BORDER CELLPADDING=3 CELLSPACING=1>
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    51
 * <caption>Summary of Queue methods</caption>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *    <td></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *    <td ALIGN=CENTER><em>Throws exception</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *    <td ALIGN=CENTER><em>Returns special value</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *    <td><b>Insert</b></td>
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    59
 *    <td>{@link Queue#add add(e)}</td>
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    60
 *    <td>{@link Queue#offer offer(e)}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *    <td><b>Remove</b></td>
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    64
 *    <td>{@link Queue#remove remove()}</td>
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    65
 *    <td>{@link Queue#poll poll()}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *    <td><b>Examine</b></td>
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    69
 *    <td>{@link Queue#element element()}</td>
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    70
 *    <td>{@link Queue#peek peek()}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>Queues typically, but do not necessarily, order elements in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * FIFO (first-in-first-out) manner.  Among the exceptions are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * priority queues, which order elements according to a supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * comparator, or the elements' natural ordering, and LIFO queues (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * stacks) which order the elements LIFO (last-in-first-out).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * Whatever the ordering used, the <em>head</em> of the queue is that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * element which would be removed by a call to {@link #remove() } or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * {@link #poll()}.  In a FIFO queue, all new elements are inserted at
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    82
 * the <em>tail</em> of the queue. Other kinds of queues may use
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    83
 * different placement rules.  Every {@code Queue} implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * must specify its ordering properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p>The {@link #offer offer} method inserts an element if possible,
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    87
 * otherwise returning {@code false}.  This differs from the {@link
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * java.util.Collection#add Collection.add} method, which can fail to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * add an element only by throwing an unchecked exception.  The
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    90
 * {@code offer} method is designed for use when failure is a normal,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * rather than exceptional occurrence, for example, in fixed-capacity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * (or &quot;bounded&quot;) queues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * <p>The {@link #remove()} and {@link #poll()} methods remove and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * return the head of the queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * Exactly which element is removed from the queue is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * function of the queue's ordering policy, which differs from
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    98
 * implementation to implementation. The {@code remove()} and
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    99
 * {@code poll()} methods differ only in their behavior when the
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   100
 * queue is empty: the {@code remove()} method throws an exception,
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   101
 * while the {@code poll()} method returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * <p>The {@link #element()} and {@link #peek()} methods return, but do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * not remove, the head of the queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   106
 * <p>The {@code Queue} interface does not define the <i>blocking queue
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * methods</i>, which are common in concurrent programming.  These methods,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * which wait for elements to appear or for space to become available, are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * defined in the {@link java.util.concurrent.BlockingQueue} interface, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * extends this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   112
 * <p>{@code Queue} implementations generally do not allow insertion
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   113
 * of {@code null} elements, although some implementations, such as
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   114
 * {@link LinkedList}, do not prohibit insertion of {@code null}.
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   115
 * Even in the implementations that permit it, {@code null} should
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   116
 * not be inserted into a {@code Queue}, as {@code null} is also
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   117
 * used as a special return value by the {@code poll} method to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * indicate that the queue contains no elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   120
 * <p>{@code Queue} implementations generally do not define
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   121
 * element-based versions of methods {@code equals} and
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   122
 * {@code hashCode} but instead inherit the identity based versions
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   123
 * from class {@code Object}, because element-based equality is not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * always well-defined for queues with the same elements but different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * ordering properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * <p>This interface is a member of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * Java Collections Framework</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * @see java.util.Collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * @see LinkedList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * @see PriorityQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * @see java.util.concurrent.LinkedBlockingQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * @see java.util.concurrent.BlockingQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * @see java.util.concurrent.ArrayBlockingQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * @see java.util.concurrent.LinkedBlockingQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * @see java.util.concurrent.PriorityBlockingQueue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * @author Doug Lea
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * @param <E> the type of elements held in this collection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
public interface Queue<E> extends Collection<E> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Inserts the specified element into this queue if it is possible to do so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * immediately without violating capacity restrictions, returning
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   148
     * {@code true} upon success and throwing an {@code IllegalStateException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * if no space is currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param e the element to add
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   152
     * @return {@code true} (as specified by {@link Collection#add})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @throws IllegalStateException if the element cannot be added at this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *         time due to capacity restrictions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @throws NullPointerException if the specified element is null and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *         this queue does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @throws IllegalArgumentException if some property of this element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    boolean add(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * Inserts the specified element into this queue if it is possible to do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * so immediately without violating capacity restrictions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * When using a capacity-restricted queue, this method is generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * preferable to {@link #add}, which can fail to insert an element only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * by throwing an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @param e the element to add
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   172
     * @return {@code true} if the element was added to this queue, else
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   173
     *         {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @throws NullPointerException if the specified element is null and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *         this queue does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @throws IllegalArgumentException if some property of this element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    boolean offer(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Retrieves and removes the head of this queue.  This method differs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * from {@link #poll poll} only in that it throws an exception if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * queue is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @return the head of this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @throws NoSuchElementException if this queue is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    E remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Retrieves and removes the head of this queue,
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   195
     * or returns {@code null} if this queue is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   197
     * @return the head of this queue, or {@code null} if this queue is empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    E poll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * Retrieves, but does not remove, the head of this queue.  This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * differs from {@link #peek peek} only in that it throws an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * if this queue is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return the head of this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @throws NoSuchElementException if this queue is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    E element();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Retrieves, but does not remove, the head of this queue,
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   213
     * or returns {@code null} if this queue is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   215
     * @return the head of this queue, or {@code null} if this queue is empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    E peek();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
}