jdk/src/java.base/share/classes/java/util/concurrent/BlockingDeque.java
author dl
Fri, 03 Mar 2017 10:45:38 -0800
changeset 44039 058585425bb7
parent 32991 b27c76b82713
child 44743 f0bbd698c486
permissions -rw-r--r--
8173909: Miscellaneous changes imported from jsr166 CVS 2017-03 Reviewed-by: martin, psandoz
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.concurrent;
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    37
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    38
import java.util.Deque;
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    39
import java.util.Iterator;
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
    40
import java.util.NoSuchElementException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * A {@link Deque} that additionally supports blocking operations that wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * for the deque to become non-empty when retrieving an element, and wait for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * space to become available in the deque when storing an element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
    47
 * <p>{@code BlockingDeque} methods come in four forms, with different ways
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * of handling operations that cannot be satisfied immediately, but may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * satisfied at some point in the future:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * one throws an exception, the second returns a special value (either
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
    51
 * {@code null} or {@code false}, depending on the operation), the third
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * blocks the current thread indefinitely until the operation can succeed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * and the fourth blocks for only a given maximum time limit before giving
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * up.  These methods are summarized in the following table:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <table BORDER CELLPADDING=3 CELLSPACING=1>
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
    57
 * <caption>Summary of BlockingDeque methods</caption>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *    <td ALIGN=CENTER COLSPAN = 5> <b>First Element (Head)</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *    <td></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *    <td ALIGN=CENTER><em>Throws exception</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *    <td ALIGN=CENTER><em>Special value</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *    <td ALIGN=CENTER><em>Blocks</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *    <td ALIGN=CENTER><em>Times out</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *    <td><b>Insert</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *    <td>{@link #addFirst addFirst(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *    <td>{@link #offerFirst(Object) offerFirst(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *    <td>{@link #putFirst putFirst(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *    <td>{@link #offerFirst(Object, long, TimeUnit) offerFirst(e, time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *    <td><b>Remove</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *    <td>{@link #removeFirst removeFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *    <td>{@link #pollFirst pollFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *    <td>{@link #takeFirst takeFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *    <td>{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *    <td><b>Examine</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *    <td>{@link #getFirst getFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *    <td>{@link #peekFirst peekFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *    <td><em>not applicable</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *    <td><em>not applicable</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *    <td ALIGN=CENTER COLSPAN = 5> <b>Last Element (Tail)</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *    <td></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *    <td ALIGN=CENTER><em>Throws exception</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *    <td ALIGN=CENTER><em>Special value</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *    <td ALIGN=CENTER><em>Blocks</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *    <td ALIGN=CENTER><em>Times out</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *    <td><b>Insert</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *    <td>{@link #addLast addLast(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *    <td>{@link #offerLast(Object) offerLast(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *    <td>{@link #putLast putLast(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 *    <td>{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *    <td><b>Remove</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *    <td>{@link #removeLast() removeLast()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *    <td>{@link #pollLast() pollLast()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *    <td>{@link #takeLast takeLast()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *    <td>{@link #pollLast(long, TimeUnit) pollLast(time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *    <td><b>Examine</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *    <td>{@link #getLast getLast()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *    <td>{@link #peekLast peekLast()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 *    <td><em>not applicable</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 *    <td><em>not applicable</em></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   122
 * <p>Like any {@link BlockingQueue}, a {@code BlockingDeque} is thread safe,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * does not permit null elements, and may (or may not) be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * capacity-constrained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   126
 * <p>A {@code BlockingDeque} implementation may be used directly as a FIFO
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   127
 * {@code BlockingQueue}. The methods inherited from the
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   128
 * {@code BlockingQueue} interface are precisely equivalent to
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   129
 * {@code BlockingDeque} methods as indicated in the following table:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * <table BORDER CELLPADDING=3 CELLSPACING=1>
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   132
 * <caption>Comparison of BlockingQueue and BlockingDeque methods</caption>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *  <tr>
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   134
 *    <td ALIGN=CENTER> <b>{@code BlockingQueue} Method</b></td>
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   135
 *    <td ALIGN=CENTER> <b>Equivalent {@code BlockingDeque} Method</b></td>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 *    <td ALIGN=CENTER COLSPAN = 2> <b>Insert</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 *    <td>{@link #add(Object) add(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 *    <td>{@link #addLast(Object) addLast(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *    <td>{@link #offer(Object) offer(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *    <td>{@link #offerLast(Object) offerLast(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 *    <td>{@link #put(Object) put(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *    <td>{@link #putLast(Object) putLast(e)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *    <td>{@link #offer(Object, long, TimeUnit) offer(e, time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 *    <td>{@link #offerLast(Object, long, TimeUnit) offerLast(e, time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 *    <td ALIGN=CENTER COLSPAN = 2> <b>Remove</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *    <td>{@link #remove() remove()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *    <td>{@link #removeFirst() removeFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *    <td>{@link #poll() poll()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 *    <td>{@link #pollFirst() pollFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *    <td>{@link #take() take()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 *    <td>{@link #takeFirst() takeFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 *    <td>{@link #poll(long, TimeUnit) poll(time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 *    <td>{@link #pollFirst(long, TimeUnit) pollFirst(time, unit)}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 *    <td ALIGN=CENTER COLSPAN = 2> <b>Examine</b></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 *    <td>{@link #element() element()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 *    <td>{@link #getFirst() getFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 *  <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 *    <td>{@link #peek() peek()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 *    <td>{@link #peekFirst() peekFirst()}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 *  </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * <p>Memory consistency effects: As with other concurrent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * collections, actions in a thread prior to placing an object into a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * {@code BlockingDeque}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 * actions subsequent to the access or removal of that element from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 * the {@code BlockingDeque} in another thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
 * <p>This interface is a member of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
 * <a href="{@docRoot}/../technotes/guides/collections/index.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
 * Java Collections Framework</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * @author Doug Lea
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   201
 * @param <E> the type of elements held in this deque
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
public interface BlockingDeque<E> extends BlockingQueue<E>, Deque<E> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * We have "diamond" multiple interface inheritance here, and that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * introduces ambiguities.  Methods might end up with different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * specs depending on the branch chosen by javadoc.  Thus a lot of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * methods specs here are copied from superinterfaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Inserts the specified element at the front of this deque if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * possible to do so immediately without violating capacity restrictions,
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   214
     * throwing an {@code IllegalStateException} if no space is currently
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * available.  When using a capacity-restricted deque, it is generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * preferable to use {@link #offerFirst(Object) offerFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @throws IllegalStateException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @throws ClassCastException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    void addFirst(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Inserts the specified element at the end of this deque if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * possible to do so immediately without violating capacity restrictions,
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   229
     * throwing an {@code IllegalStateException} if no space is currently
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * available.  When using a capacity-restricted deque, it is generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * preferable to use {@link #offerLast(Object) offerLast}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @throws IllegalStateException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @throws ClassCastException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    void addLast(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * Inserts the specified element at the front of this deque if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * possible to do so immediately without violating capacity restrictions,
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   244
     * returning {@code true} upon success and {@code false} if no space is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * When using a capacity-restricted deque, this method is generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * preferable to the {@link #addFirst(Object) addFirst} method, which can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * fail to insert an element only by throwing an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @throws ClassCastException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    boolean offerFirst(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * Inserts the specified element at the end of this deque if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * possible to do so immediately without violating capacity restrictions,
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   260
     * returning {@code true} upon success and {@code false} if no space is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * currently available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * When using a capacity-restricted deque, this method is generally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * preferable to the {@link #addLast(Object) addLast} method, which can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * fail to insert an element only by throwing an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @throws ClassCastException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    boolean offerLast(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Inserts the specified element at the front of this deque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * waiting if necessary for space to become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    void putFirst(E e) throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Inserts the specified element at the end of this deque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * waiting if necessary for space to become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    void putLast(E e) throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Inserts the specified element at the front of this deque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * waiting up to the specified wait time if necessary for space to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @param timeout how long to wait before giving up, in units of
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   308
     *        {@code unit}
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   309
     * @param unit a {@code TimeUnit} determining how to interpret the
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   310
     *        {@code timeout} parameter
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   311
     * @return {@code true} if successful, or {@code false} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *         the specified waiting time elapses before space is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    boolean offerFirst(E e, long timeout, TimeUnit unit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * Inserts the specified element at the end of this deque,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * waiting up to the specified wait time if necessary for space to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @param timeout how long to wait before giving up, in units of
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   330
     *        {@code unit}
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   331
     * @param unit a {@code TimeUnit} determining how to interpret the
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   332
     *        {@code timeout} parameter
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   333
     * @return {@code true} if successful, or {@code false} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *         the specified waiting time elapses before space is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    boolean offerLast(E e, long timeout, TimeUnit unit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * Retrieves and removes the first element of this deque, waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * if necessary until an element becomes available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @return the head of this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    E takeFirst() throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Retrieves and removes the last element of this deque, waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * if necessary until an element becomes available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @return the tail of this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    E takeLast() throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Retrieves and removes the first element of this deque, waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * up to the specified wait time if necessary for an element to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @param timeout how long to wait before giving up, in units of
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   369
     *        {@code unit}
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   370
     * @param unit a {@code TimeUnit} determining how to interpret the
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   371
     *        {@code timeout} parameter
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   372
     * @return the head of this deque, or {@code null} if the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     *         waiting time elapses before an element is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    E pollFirst(long timeout, TimeUnit unit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * Retrieves and removes the last element of this deque, waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * up to the specified wait time if necessary for an element to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @param timeout how long to wait before giving up, in units of
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   385
     *        {@code unit}
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   386
     * @param unit a {@code TimeUnit} determining how to interpret the
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   387
     *        {@code timeout} parameter
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   388
     * @return the tail of this deque, or {@code null} if the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *         waiting time elapses before an element is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    E pollLast(long timeout, TimeUnit unit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * Removes the first occurrence of the specified element from this deque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * If the deque does not contain the element, it is unchanged.
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   398
     * More formally, removes the first element {@code e} such that
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   399
     * {@code o.equals(e)} (if such an element exists).
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   400
     * Returns {@code true} if this deque contained the specified element
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * (or equivalently, if this deque changed as a result of the call).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @param o element to be removed from this deque, if present
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   404
     * @return {@code true} if an element was removed as a result of this call
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @throws ClassCastException if the class of the specified element
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   406
     *         is incompatible with this deque
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   407
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   408
     * @throws NullPointerException if the specified element is null
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   409
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    boolean removeFirstOccurrence(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * Removes the last occurrence of the specified element from this deque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * If the deque does not contain the element, it is unchanged.
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   416
     * More formally, removes the last element {@code e} such that
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   417
     * {@code o.equals(e)} (if such an element exists).
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   418
     * Returns {@code true} if this deque contained the specified element
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * (or equivalently, if this deque changed as a result of the call).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @param o element to be removed from this deque, if present
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   422
     * @return {@code true} if an element was removed as a result of this call
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @throws ClassCastException if the class of the specified element
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   424
     *         is incompatible with this deque
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   425
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   426
     * @throws NullPointerException if the specified element is null
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   427
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    boolean removeLastOccurrence(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    // *** BlockingQueue methods ***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * Inserts the specified element into the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * (in other words, at the tail of this deque) if it is possible to do so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * immediately without violating capacity restrictions, returning
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   437
     * {@code true} upon success and throwing an
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   438
     * {@code IllegalStateException} if no space is currently available.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * When using a capacity-restricted deque, it is generally preferable to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * use {@link #offer(Object) offer}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * <p>This method is equivalent to {@link #addLast(Object) addLast}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @throws IllegalStateException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    boolean add(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * Inserts the specified element into the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * (in other words, at the tail of this deque) if it is possible to do so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * immediately without violating capacity restrictions, returning
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   458
     * {@code true} upon success and {@code false} if no space is currently
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * available.  When using a capacity-restricted deque, this method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * generally preferable to the {@link #add} method, which can fail to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * insert an element only by throwing an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * <p>This method is equivalent to {@link #offerLast(Object) offerLast}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    boolean offer(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * Inserts the specified element into the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * (in other words, at the tail of this deque), waiting if necessary for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * space to become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * <p>This method is equivalent to {@link #putLast(Object) putLast}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @param e the element to add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @throws InterruptedException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    void put(E e) throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * Inserts the specified element into the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * (in other words, at the tail of this deque), waiting up to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * specified wait time if necessary for space to become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * <p>This method is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * {@link #offerLast(Object,long,TimeUnit) offerLast}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @param e the element to add
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   500
     * @return {@code true} if the element was added to this deque, else
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   501
     *         {@code false}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @throws InterruptedException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @throws ClassCastException if the class of the specified element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *         prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @throws IllegalArgumentException if some property of the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     *         element prevents it from being added to this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    boolean offer(E e, long timeout, TimeUnit unit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * Retrieves and removes the head of the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * (in other words, the first element of this deque).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * This method differs from {@link #poll poll} only in that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * throws an exception if this deque is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * <p>This method is equivalent to {@link #removeFirst() removeFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @return the head of the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @throws NoSuchElementException if this deque is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    E remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * Retrieves and removes the head of the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * (in other words, the first element of this deque), or returns
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   528
     * {@code null} if this deque is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * <p>This method is equivalent to {@link #pollFirst()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   532
     * @return the head of this deque, or {@code null} if this deque is empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    E poll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * Retrieves and removes the head of the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * (in other words, the first element of this deque), waiting if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * necessary until an element becomes available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * <p>This method is equivalent to {@link #takeFirst() takeFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * @return the head of this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    E take() throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * Retrieves and removes the head of the queue represented by this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * (in other words, the first element of this deque), waiting up to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * specified wait time if necessary for an element to become available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * <p>This method is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * {@link #pollFirst(long,TimeUnit) pollFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   556
     * @return the head of this deque, or {@code null} if the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *         specified waiting time elapses before an element is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @throws InterruptedException if interrupted while waiting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    E poll(long timeout, TimeUnit unit)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        throws InterruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * Retrieves, but does not remove, the head of the queue represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * this deque (in other words, the first element of this deque).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * This method differs from {@link #peek peek} only in that it throws an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * exception if this deque is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * <p>This method is equivalent to {@link #getFirst() getFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * @return the head of this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @throws NoSuchElementException if this deque is empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    E element();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * Retrieves, but does not remove, the head of the queue represented by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * this deque (in other words, the first element of this deque), or
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   579
     * returns {@code null} if this deque is empty.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * <p>This method is equivalent to {@link #peekFirst() peekFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   583
     * @return the head of this deque, or {@code null} if this deque is empty
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    E peek();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * Removes the first occurrence of the specified element from this deque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * If the deque does not contain the element, it is unchanged.
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   590
     * More formally, removes the first element {@code e} such that
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   591
     * {@code o.equals(e)} (if such an element exists).
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   592
     * Returns {@code true} if this deque contained the specified element
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * (or equivalently, if this deque changed as a result of the call).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * <p>This method is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * {@link #removeFirstOccurrence(Object) removeFirstOccurrence}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @param o element to be removed from this deque, if present
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   599
     * @return {@code true} if this deque changed as a result of the call
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @throws ClassCastException if the class of the specified element
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   601
     *         is incompatible with this deque
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   602
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   603
     * @throws NullPointerException if the specified element is null
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   604
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    boolean remove(Object o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    /**
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   609
     * Returns {@code true} if this deque contains the specified element.
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   610
     * More formally, returns {@code true} if and only if this deque contains
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   611
     * at least one element {@code e} such that {@code o.equals(e)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * @param o object to be checked for containment in this deque
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   614
     * @return {@code true} if this deque contains the specified element
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @throws ClassCastException if the class of the specified element
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   616
     *         is incompatible with this deque
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   617
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
9504
a61398ab96e0 7038501: Clarify meaning of "(optional)" in javadoc
dl
parents: 9242
diff changeset
   618
     * @throws NullPointerException if the specified element is null
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   619
     * (<a href="{@docRoot}/java/util/Collection.html#optional-restrictions">optional</a>)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   621
    boolean contains(Object o);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * Returns the number of elements in this deque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * @return the number of elements in this deque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     */
32991
b27c76b82713 8134853: Bulk integration of java.util.concurrent classes
dl
parents: 25859
diff changeset
   628
    int size();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * Returns an iterator over the elements in this deque in proper sequence.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * The elements will be returned in order from first (head) to last (tail).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * @return an iterator over the elements in this deque in proper sequence
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    Iterator<E> iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    // *** Stack methods ***
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    /**
18767
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   641
     * Pushes an element onto the stack represented by this deque (in other
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   642
     * words, at the head of this deque) if it is possible to do so
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   643
     * immediately without violating capacity restrictions, throwing an
6214297bf27d 8011427: java.util.concurrent collection Spliterator implementations
psandoz
parents: 9504
diff changeset
   644
     * {@code IllegalStateException} if no space is currently available.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * <p>This method is equivalent to {@link #addFirst(Object) addFirst}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * @throws IllegalStateException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * @throws ClassCastException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @throws NullPointerException if the specified element is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * @throws IllegalArgumentException {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    void push(E e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
}