--- jsr166/src/jsr166x/ArrayDeque.java 2012/12/29 23:55:19 1.10 +++ jsr166/src/jsr166x/ArrayDeque.java 2015/01/18 20:17:33 1.13 @@ -4,6 +4,7 @@ */ package jsr166x; // XXX This belongs in java.util!!! XXX + import java.util.*; // XXX This import goes away XXX import java.io.*; @@ -16,14 +17,14 @@ import java.io.*; * {@link Stack} when used as a stack, and faster than {@link LinkedList} * when used as a queue. * - *

Most ArrayDeque operations run in amortized constant time. + *

Most {@code ArrayDeque} operations run in amortized constant time. * Exceptions include {@link #remove(Object) remove}, {@link * #removeFirstOccurrence removeFirstOccurrence}, {@link #removeLastOccurrence * removeLastOccurrence}, {@link #contains contains }, {@link #iterator * iterator.remove()}, and the bulk operations, all of which run in linear * time. * - *

The iterators returned by this class's iterator method are + *

The iterators returned by this class's {@code iterator} method are * fail-fast: If the deque is modified at any time after the iterator * is created, in any way except through the iterator's own remove method, the * iterator will generally throw a {@link ConcurrentModificationException}. @@ -34,7 +35,7 @@ import java.io.*; *

Note that the fail-fast behavior of an iterator cannot be guaranteed * as it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators - * throw ConcurrentModificationException on a best-effort basis. + * throw {@code ConcurrentModificationException} on a best-effort basis. * Therefore, it would be wrong to write a program that depended on this * exception for its correctness: the fail-fast behavior of iterators * should be used only to detect bugs. @@ -188,7 +189,7 @@ public class ArrayDeque extends Abstr * Inserts the specified element to the front this deque. * * @param e the element to insert - * @throws NullPointerException if e is null + * @throws NullPointerException if {@code e} is null */ public void addFirst(E e) { if (e == null) @@ -204,7 +205,7 @@ public class ArrayDeque extends Abstr * {@link #push}. * * @param e the element to insert - * @throws NullPointerException if e is null + * @throws NullPointerException if {@code e} is null */ public void addLast(E e) { if (e == null) @@ -216,9 +217,9 @@ public class ArrayDeque extends Abstr /** * Retrieves and removes the first element of this deque, or - * null if this deque is empty. + * {@code null} if this deque is empty. * - * @return the first element of this deque, or null if + * @return the first element of this deque, or {@code null} if * this deque is empty */ public E pollFirst() { @@ -233,9 +234,9 @@ public class ArrayDeque extends Abstr /** * Retrieves and removes the last element of this deque, or - * null if this deque is empty. + * {@code null} if this deque is empty. * - * @return the last element of this deque, or null if + * @return the last element of this deque, or {@code null} if * this deque is empty */ public E pollLast() { @@ -252,8 +253,8 @@ public class ArrayDeque extends Abstr * Inserts the specified element to the front this deque. * * @param e the element to insert - * @return true (as per the spec for {@link Deque#offerFirst}) - * @throws NullPointerException if e is null + * @return {@code true} (as per the spec for {@link Deque#offerFirst}) + * @throws NullPointerException if {@code e} is null */ public boolean offerFirst(E e) { addFirst(e); @@ -264,8 +265,8 @@ public class ArrayDeque extends Abstr * Inserts the specified element to the end this deque. * * @param e the element to insert - * @return true (as per the spec for {@link Deque#offerLast}) - * @throws NullPointerException if e is null + * @return {@code true} (as per the spec for {@link Deque#offerLast}) + * @throws NullPointerException if {@code e} is null */ public boolean offerLast(E e) { addLast(e); @@ -274,7 +275,7 @@ public class ArrayDeque extends Abstr /** * Retrieves and removes the first element of this deque. This method - * differs from the pollFirst method in that it throws an + * differs from the {@code pollFirst} method in that it throws an * exception if this deque is empty. * * @return the first element of this deque @@ -289,7 +290,7 @@ public class ArrayDeque extends Abstr /** * Retrieves and removes the last element of this deque. This method - * differs from the pollLast method in that it throws an + * differs from the {@code pollLast} method in that it throws an * exception if this deque is empty. * * @return the last element of this deque @@ -304,9 +305,9 @@ public class ArrayDeque extends Abstr /** * Retrieves, but does not remove, the first element of this deque, - * returning null if this deque is empty. + * returning {@code null} if this deque is empty. * - * @return the first element of this deque, or null if + * @return the first element of this deque, or {@code null} if * this deque is empty */ public E peekFirst() { @@ -315,9 +316,9 @@ public class ArrayDeque extends Abstr /** * Retrieves, but does not remove, the last element of this deque, - * returning null if this deque is empty. + * returning {@code null} if this deque is empty. * - * @return the last element of this deque, or null if this deque + * @return the last element of this deque, or {@code null} if this deque * is empty */ public E peekLast() { @@ -326,7 +327,7 @@ public class ArrayDeque extends Abstr /** * Retrieves, but does not remove, the first element of this - * deque. This method differs from the peek method only + * deque. This method differs from the {@code peek} method only * in that it throws an exception if this deque is empty. * * @return the first element of this deque @@ -341,7 +342,7 @@ public class ArrayDeque extends Abstr /** * Retrieves, but does not remove, the last element of this - * deque. This method differs from the peek method only + * deque. This method differs from the {@code peek} method only * in that it throws an exception if this deque is empty. * * @return the last element of this deque @@ -360,7 +361,7 @@ public class ArrayDeque extends Abstr * does not contain the element, it is unchanged. * * @param e element to be removed from this deque, if present - * @return true if the deque contained the specified element + * @return {@code true} if the deque contained the specified element */ public boolean removeFirstOccurrence(Object e) { if (e == null) @@ -384,7 +385,7 @@ public class ArrayDeque extends Abstr * does not contain the element, it is unchanged. * * @param e element to be removed from this deque, if present - * @return true if the deque contained the specified element + * @return {@code true} if the deque contained the specified element */ public boolean removeLastOccurrence(Object e) { if (e == null) @@ -410,8 +411,8 @@ public class ArrayDeque extends Abstr *

This method is equivalent to {@link #offerLast}. * * @param e the element to insert - * @return true (as per the spec for {@link Queue#offer}) - * @throws NullPointerException if e is null + * @return {@code true} (as per the spec for {@link Queue#offer}) + * @throws NullPointerException if {@code e} is null */ public boolean offer(E e) { return offerLast(e); @@ -423,8 +424,8 @@ public class ArrayDeque extends Abstr *

This method is equivalent to {@link #addLast}. * * @param e the element to insert - * @return true (as per the spec for {@link Collection#add}) - * @throws NullPointerException if e is null + * @return {@code true} (as per the spec for {@link Collection#add}) + * @throws NullPointerException if {@code e} is null */ public boolean add(E e) { addLast(e); @@ -433,13 +434,13 @@ public class ArrayDeque extends Abstr /** * Retrieves and removes the head of the queue represented by - * this deque, or null if this deque is empty. In other words, - * retrieves and removes the first element of this deque, or null + * this deque, or {@code null} if this deque is empty. In other words, + * retrieves and removes the first element of this deque, or {@code null} * if this deque is empty. * *

This method is equivalent to {@link #pollFirst}. * - * @return the first element of this deque, or null if + * @return the first element of this deque, or {@code null} if * this deque is empty */ public E poll() { @@ -448,7 +449,7 @@ public class ArrayDeque extends Abstr /** * Retrieves and removes the head of the queue represented by this deque. - * This method differs from the poll method in that it throws an + * This method differs from the {@code poll} method in that it throws an * exception if this deque is empty. * *

This method is equivalent to {@link #removeFirst}. @@ -462,12 +463,12 @@ public class ArrayDeque extends Abstr /** * Retrieves, but does not remove, the head of the queue represented by - * this deque, returning null if this deque is empty. + * this deque, returning {@code null} if this deque is empty. * - *

This method is equivalent to {@link #peekFirst} + *

This method is equivalent to {@link #peekFirst}. * * @return the head of the queue represented by this deque, or - * null if this deque is empty + * {@code null} if this deque is empty */ public E peek() { return peekFirst(); @@ -475,10 +476,10 @@ public class ArrayDeque extends Abstr /** * Retrieves, but does not remove, the head of the queue represented by - * this deque. This method differs from the peek method only in + * this deque. This method differs from the {@code peek} method only in * that it throws an exception if this deque is empty. * - *

This method is equivalent to {@link #getFirst} + *

This method is equivalent to {@link #getFirst}. * * @return the head of the queue represented by this deque * @throws NoSuchElementException if this deque is empty @@ -496,7 +497,7 @@ public class ArrayDeque extends Abstr *

This method is equivalent to {@link #addFirst}. * * @param e the element to push - * @throws NullPointerException if e is null + * @throws NullPointerException if {@code e} is null */ public void push(E e) { addFirst(e); @@ -555,9 +556,9 @@ public class ArrayDeque extends Abstr } /** - * Returns true if this collection contains no elements. + * Returns {@code true} if this collection contains no elements. * - * @return true if this collection contains no elements + * @return {@code true} if this collection contains no elements */ public boolean isEmpty() { return head == tail; @@ -569,7 +570,7 @@ public class ArrayDeque extends Abstr * order that elements would be dequeued (via successive calls to * {@link #remove} or popped (via successive calls to {@link #pop}). * - * @return an Iterator over the elements in this deque + * @return an {@code Iterator} over the elements in this deque */ public Iterator iterator() { return new DeqIterator(); @@ -621,13 +622,13 @@ public class ArrayDeque extends Abstr } /** - * Returns true if this deque contains the specified - * element. More formally, returns true if and only if this - * deque contains at least one element e such that - * e.equals(o). + * Returns {@code true} if this deque contains the specified + * element. More formally, returns {@code true} if and only if this + * deque contains at least one element {@code e} such that + * {@code e.equals(o)}. * * @param o object to be checked for containment in this deque - * @return true if this deque contains the specified element + * @return {@code true} if this deque contains the specified element */ public boolean contains(Object o) { if (o == null) @@ -648,7 +649,7 @@ public class ArrayDeque extends Abstr * This method is equivalent to {@link #removeFirstOccurrence}. * * @param e element to be removed from this deque, if present - * @return true if this deque contained the specified element + * @return {@code true} if this deque contained the specified element */ public boolean remove(Object e) { return removeFirstOccurrence(e); @@ -691,7 +692,7 @@ public class ArrayDeque extends Abstr * *

If the deque fits in the specified array with room to spare (i.e., * the array has more elements than the deque), the element in the array - * immediately following the end of the collection is set to null. + * immediately following the end of the collection is set to {@code null}. * * @param a the array into which the elements of the deque are to * be stored, if it is big enough; otherwise, a new array of the @@ -739,7 +740,7 @@ public class ArrayDeque extends Abstr /** * Serializes this deque. * - * @serialData The current size (int) of the deque, + * @serialData The current size ({@code int}) of the deque, * followed by all of its elements (each an object reference) in * first-to-last order. */