< prev index next >

src/java.base/share/classes/java/util/Queue.java

Print this page




 111  * which wait for elements to appear or for space to become available, are
 112  * defined in the {@link java.util.concurrent.BlockingQueue} interface, which
 113  * extends this interface.
 114  *
 115  * <p>{@code Queue} implementations generally do not allow insertion
 116  * of {@code null} elements, although some implementations, such as
 117  * {@link LinkedList}, do not prohibit insertion of {@code null}.
 118  * Even in the implementations that permit it, {@code null} should
 119  * not be inserted into a {@code Queue}, as {@code null} is also
 120  * used as a special return value by the {@code poll} method to
 121  * indicate that the queue contains no elements.
 122  *
 123  * <p>{@code Queue} implementations generally do not define
 124  * element-based versions of methods {@code equals} and
 125  * {@code hashCode} but instead inherit the identity based versions
 126  * from class {@code Object}, because element-based equality is not
 127  * always well-defined for queues with the same elements but different
 128  * ordering properties.
 129  *
 130  * <p>This interface is a member of the
 131  * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
 132  * Java Collections Framework</a>.
 133  *
 134  * @since 1.5
 135  * @author Doug Lea
 136  * @param <E> the type of elements held in this queue
 137  */
 138 public interface Queue<E> extends Collection<E> {
 139     /**
 140      * Inserts the specified element into this queue if it is possible to do so
 141      * immediately without violating capacity restrictions, returning
 142      * {@code true} upon success and throwing an {@code IllegalStateException}
 143      * if no space is currently available.
 144      *
 145      * @param e the element to add
 146      * @return {@code true} (as specified by {@link Collection#add})
 147      * @throws IllegalStateException if the element cannot be added at this
 148      *         time due to capacity restrictions
 149      * @throws ClassCastException if the class of the specified element
 150      *         prevents it from being added to this queue
 151      * @throws NullPointerException if the specified element is null and




 111  * which wait for elements to appear or for space to become available, are
 112  * defined in the {@link java.util.concurrent.BlockingQueue} interface, which
 113  * extends this interface.
 114  *
 115  * <p>{@code Queue} implementations generally do not allow insertion
 116  * of {@code null} elements, although some implementations, such as
 117  * {@link LinkedList}, do not prohibit insertion of {@code null}.
 118  * Even in the implementations that permit it, {@code null} should
 119  * not be inserted into a {@code Queue}, as {@code null} is also
 120  * used as a special return value by the {@code poll} method to
 121  * indicate that the queue contains no elements.
 122  *
 123  * <p>{@code Queue} implementations generally do not define
 124  * element-based versions of methods {@code equals} and
 125  * {@code hashCode} but instead inherit the identity based versions
 126  * from class {@code Object}, because element-based equality is not
 127  * always well-defined for queues with the same elements but different
 128  * ordering properties.
 129  *
 130  * <p>This interface is a member of the
 131  * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
 132  * Java Collections Framework</a>.
 133  *
 134  * @since 1.5
 135  * @author Doug Lea
 136  * @param <E> the type of elements held in this queue
 137  */
 138 public interface Queue<E> extends Collection<E> {
 139     /**
 140      * Inserts the specified element into this queue if it is possible to do so
 141      * immediately without violating capacity restrictions, returning
 142      * {@code true} upon success and throwing an {@code IllegalStateException}
 143      * if no space is currently available.
 144      *
 145      * @param e the element to add
 146      * @return {@code true} (as specified by {@link Collection#add})
 147      * @throws IllegalStateException if the element cannot be added at this
 148      *         time due to capacity restrictions
 149      * @throws ClassCastException if the class of the specified element
 150      *         prevents it from being added to this queue
 151      * @throws NullPointerException if the specified element is null and


< prev index next >