ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/ArrayDeque.java
(Generate patch)

Comparing jsr166/src/main/java/util/ArrayDeque.java (file contents):
Revision 1.54 by dl, Wed Mar 27 23:09:34 2013 UTC vs.
Revision 1.58 by jsr166, Sun Nov 23 17:44:51 2014 UTC

# Line 7 | Line 7 | package java.util;
7   import java.io.Serializable;
8   import java.util.function.Consumer;
9   import java.util.stream.Stream;
10 import java.util.stream.Streams;
10  
11   /**
12   * Resizable-array implementation of the {@link Deque} interface.  Array
# Line 316 | Line 315 | public class ArrayDeque<E> extends Abstr
315       * @return {@code true} if the deque contained the specified element
316       */
317      public boolean removeFirstOccurrence(Object o) {
318 <        if (o == null)
319 <            return false;
320 <        int mask = elements.length - 1;
321 <        int i = head;
322 <        Object x;
323 <        while ( (x = elements[i]) != null) {
324 <            if (o.equals(x)) {
325 <                delete(i);
326 <                return true;
318 >        if (o != null) {
319 >            int mask = elements.length - 1;
320 >            int i = head;
321 >            Object x;
322 >            while ( (x = elements[i]) != null) {
323 >                if (o.equals(x)) {
324 >                    delete(i);
325 >                    return true;
326 >                }
327 >                i = (i + 1) & mask;
328              }
329            i = (i + 1) & mask;
329          }
330          return false;
331      }
# Line 659 | Line 658 | public class ArrayDeque<E> extends Abstr
658       * @return {@code true} if this deque contains the specified element
659       */
660      public boolean contains(Object o) {
661 <        if (o == null)
662 <            return false;
663 <        int mask = elements.length - 1;
664 <        int i = head;
665 <        Object x;
666 <        while ( (x = elements[i]) != null) {
667 <            if (o.equals(x))
668 <                return true;
669 <            i = (i + 1) & mask;
661 >        if (o != null) {
662 >            int mask = elements.length - 1;
663 >            int i = head;
664 >            Object x;
665 >            while ( (x = elements[i]) != null) {
666 >                if (o.equals(x))
667 >                    return true;
668 >                i = (i + 1) & mask;
669 >            }
670          }
671          return false;
672      }
# Line 811 | Line 810 | public class ArrayDeque<E> extends Abstr
810      /**
811       * Saves this deque to a stream (that is, serializes it).
812       *
813 +     * @param s the stream
814 +     * @throws java.io.IOException if an I/O error occurs
815       * @serialData The current size ({@code int}) of the deque,
816       * followed by all of its elements (each an object reference) in
817       * first-to-last order.
# Line 830 | Line 831 | public class ArrayDeque<E> extends Abstr
831  
832      /**
833       * Reconstitutes this deque from a stream (that is, deserializes it).
834 +     * @param s the stream
835 +     * @throws ClassNotFoundException if the class of a serialized object
836 +     *         could not be found
837 +     * @throws java.io.IOException if an I/O error occurs
838       */
839      private void readObject(java.io.ObjectInputStream s)
840              throws java.io.IOException, ClassNotFoundException {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines