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.86 by jsr166, Sun Oct 23 22:30:20 2016 UTC vs.
Revision 1.87 by jsr166, Sun Oct 23 23:38:09 2016 UTC

# Line 317 | Line 317 | public class ArrayDeque<E> extends Abstr
317       * @throws NullPointerException if the specified collection or any
318       *         of its elements are null
319       */
320    @Override
320      public boolean addAll(Collection<? extends E> c) {
321 +        final int s = size, needed = c.size() - (elements.length - s);
322 +        if (needed > 0)
323 +            grow(needed);
324 +        c.forEach((e) -> addLast(e));
325          // checkInvariants();
326 <        Object[] a, elements;
324 <        int newcomers, capacity, s = size;
325 <        if ((newcomers = (a = c.toArray()).length) == 0)
326 <            return false;
327 <        while ((capacity = (elements = this.elements).length) - s < newcomers)
328 <            grow(newcomers - (capacity - s));
329 <        int i = add(head, s, capacity);
330 <        for (Object x : a) {
331 <            Objects.requireNonNull(x);
332 <            elements[i] = x;
333 <            i = inc(i, capacity);
334 <            size++;
335 <        }
336 <        return true;
326 >        return size > s;
327      }
328  
329      /**
# Line 855 | Line 845 | public class ArrayDeque<E> extends Abstr
845          }
846      }
847  
858    @Override
848      public void forEach(Consumer<? super E> action) {
849          // checkInvariants();
850          Objects.requireNonNull(action);
# Line 885 | Line 874 | public class ArrayDeque<E> extends Abstr
874      /**
875       * @throws NullPointerException {@inheritDoc}
876       */
888    @Override
877      public boolean removeIf(Predicate<? super E> filter) {
878          Objects.requireNonNull(filter);
879          return bulkRemove(filter);
# Line 894 | Line 882 | public class ArrayDeque<E> extends Abstr
882      /**
883       * @throws NullPointerException {@inheritDoc}
884       */
897    @Override
885      public boolean removeAll(Collection<?> c) {
886          Objects.requireNonNull(c);
887          return bulkRemove(e -> c.contains(e));
# Line 903 | Line 890 | public class ArrayDeque<E> extends Abstr
890      /**
891       * @throws NullPointerException {@inheritDoc}
892       */
906    @Override
893      public boolean retainAll(Collection<?> c) {
894          Objects.requireNonNull(c);
895          return bulkRemove(e -> !c.contains(e));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines