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.24 by dl, Sat Sep 17 13:21:19 2005 UTC vs.
Revision 1.25 by jsr166, Sat Sep 17 17:22:17 2005 UTC

# Line 479 | Line 479 | public class ArrayDeque<E> extends Abstr
479          return removeFirst();
480      }
481  
482 +    private void checkInvariants() {
483 +        assert elements[tail] == null;
484 +        assert head == tail ? elements[head] == null :
485 +            (elements[head] != null &&
486 +             elements[(tail - 1) & (elements.length - 1)] != null);
487 +        assert elements[(head - 1) & (elements.length - 1)] == null;
488 +    }
489 +
490      /**
491       * Removes the element at the specified position in the elements array,
492       * adjusting head and tail as necessary.  This can result in motion of
# Line 490 | Line 498 | public class ArrayDeque<E> extends Abstr
498       * @return true if elements moved backwards
499       */
500      private boolean delete(int i) {
501 +        checkInvariants();
502          final E[] elements = this.elements;
503          final int mask = elements.length - 1;
504          final int h = head;
# Line 608 | Line 617 | public class ArrayDeque<E> extends Abstr
617          }
618      }
619  
611
620      private class DescendingIterator implements Iterator<E> {
621          /*
622           * This class is nearly a mirror-image of DeqIterator, using
# Line 829 | Line 837 | public class ArrayDeque<E> extends Abstr
837          // Read in all elements in the proper order.
838          for (int i = 0; i < size; i++)
839              elements[i] = (E)s.readObject();
832
840      }
841   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines