jdk/src/java.base/share/classes/java/util/Queue.java
author jjg
Wed, 23 Aug 2017 10:58:11 -0700
changeset 46900 e92e67ed12b4
parent 45937 646816090183
permissions -rw-r--r--
8186466: Fix accessibility and other minor issues in java.base Reviewed-by: mchung, naoto, martin
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.
45937
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    40
 * Besides basic {@link Collection} operations, queues provide
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    41
 * additional insertion, extraction, and inspection operations.
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    42
 * Each of these methods exists in two forms: one throws an exception
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    43
 * if the operation fails, the other returns a special value (either
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    44
 * {@code null} or {@code false}, depending on the operation).  The
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    45
 * latter form of the insert operation is designed specifically for
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    46
 * use with capacity-restricted {@code Queue} implementations; in most
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    47
 * implementations, insert operations cannot fail.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    49
 * <table class="striped">
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
    50
 * <caption>Summary of Queue methods</caption>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    51
 *  <thead>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *    <td></td>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    54
 *    <th scope="col" style="font-weight:normal; font-style:italic">Throws exception</th>
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    55
 *    <th scope="col" style="font-weight:normal; font-style:italic">Returns special value</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *  </tr>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    57
 *  </thead>
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    58
 *  <tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *  <tr>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    60
 *    <th scope="row">Insert</th>
45937
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    61
 *    <td>{@link #add(Object) add(e)}</td>
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    62
 *    <td>{@link #offer(Object) offer(e)}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *  <tr>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    65
 *    <th scope="row">Remove</th>
45937
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    66
 *    <td>{@link #remove() remove()}</td>
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    67
 *    <td>{@link #poll() poll()}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *  <tr>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    70
 *    <th scope="row">Examine</th>
45937
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    71
 *    <td>{@link #element() element()}</td>
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    72
 *    <td>{@link #peek() peek()}</td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *  </tr>
46900
e92e67ed12b4 8186466: Fix accessibility and other minor issues in java.base
jjg
parents: 45937
diff changeset
    74
 *  </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>Queues typically, but do not necessarily, order elements in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * FIFO (first-in-first-out) manner.  Among the exceptions are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * priority queues, which order elements according to a supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * comparator, or the elements' natural ordering, and LIFO queues (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * stacks) which order the elements LIFO (last-in-first-out).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * Whatever the ordering used, the <em>head</em> of the queue is that
45937
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
    83
 * element which would be removed by a call to {@link #remove()} or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * {@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
    85
 * 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
    86
 * different placement rules.  Every {@code Queue} implementation
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * must specify its ordering properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * <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
    90
 * otherwise returning {@code false}.  This differs from the {@link
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * java.util.Collection#add Collection.add} method, which can fail to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * 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
    93
 * {@code offer} method is designed for use when failure is a normal,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * rather than exceptional occurrence, for example, in fixed-capacity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * (or &quot;bounded&quot;) queues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * <p>The {@link #remove()} and {@link #poll()} methods remove and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * return the head of the queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * Exactly which element is removed from the queue is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * 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
   101
 * implementation to implementation. The {@code remove()} and
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   102
 * {@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
   103
 * 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
   104
 * while the {@code poll()} method returns {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * <p>The {@link #element()} and {@link #peek()} methods return, but do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * not remove, the head of the queue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   109
 * <p>The {@code Queue} interface does not define the <i>blocking queue
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * methods</i>, which are common in concurrent programming.  These methods,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * which wait for elements to appear or for space to become available, are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * defined in the {@link java.util.concurrent.BlockingQueue} interface, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * extends this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   115
 * <p>{@code Queue} implementations generally do not allow insertion
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   116
 * of {@code null} elements, although some implementations, such as
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   117
 * {@link LinkedList}, do not prohibit insertion of {@code null}.
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   118
 * 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
   119
 * 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
   120
 * used as a special return value by the {@code poll} method to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * indicate that the queue contains no elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   123
 * <p>{@code Queue} implementations generally do not define
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   124
 * element-based versions of methods {@code equals} and
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   125
 * {@code hashCode} but instead inherit the identity based versions
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   126
 * from class {@code Object}, because element-based equality is not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * always well-defined for queues with the same elements but different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * ordering properties.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * <p>This interface is a member of the
44743
f0bbd698c486 8177789: fix collections framework links to point to java.util package doc
smarks
parents: 39725
diff changeset
   131
 * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * Java Collections Framework</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * @author Doug Lea
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   136
 * @param <E> the type of elements held in this queue
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
public interface Queue<E> extends Collection<E> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Inserts the specified element into this queue if it is possible to do so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * immediately without violating capacity restrictions, returning
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   142
     * {@code true} upon success and throwing an {@code IllegalStateException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * if no space is currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @param e the element to add
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   146
     * @return {@code true} (as specified by {@link Collection#add})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @throws IllegalStateException if the element cannot be added at this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *         time due to capacity restrictions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @throws NullPointerException if the specified element is null and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *         this queue does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @throws IllegalArgumentException if some property of this element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    boolean add(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Inserts the specified element into this queue if it is possible to do
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * so immediately without violating capacity restrictions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * When using a capacity-restricted queue, this method is generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * preferable to {@link #add}, which can fail to insert an element only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * by throwing an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @param e the element to add
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   166
     * @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
   167
     *         {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @throws NullPointerException if the specified element is null and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *         this queue does not permit null elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @throws IllegalArgumentException if some property of this element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *         prevents it from being added to this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    boolean offer(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Retrieves and removes the head of this queue.  This method differs
45937
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
   179
     * from {@link #poll() poll()} only in that it throws an exception if
646816090183 8178409: Miscellaneous changes imported from jsr166 CVS 2017-07
dl
parents: 45124
diff changeset
   180
     * this queue is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @return the head of this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @throws NoSuchElementException if this queue is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    E remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Retrieves and removes the head of this queue,
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   189
     * or returns {@code null} if this queue is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   191
     * @return the head of this queue, or {@code null} if this queue is empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    E poll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Retrieves, but does not remove, the head of this queue.  This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * differs from {@link #peek peek} only in that it throws an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * if this queue is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @return the head of this queue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @throws NoSuchElementException if this queue is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    E element();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * 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
   207
     * or returns {@code null} if this queue is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
19187
5aa85bc92303 8022087: Fix doclint issues in j.u.Deque & Queue
chegar
parents: 9242
diff changeset
   209
     * @return the head of this queue, or {@code null} if this queue is empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    E peek();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
}