3535package java .util ;
3636
3737import org .checkerframework .checker .index .qual .NonNegative ;
38+ import org .checkerframework .checker .index .qual .PolyGrowShrink ;
39+ import org .checkerframework .checker .index .qual .Shrinkable ;
3840import org .checkerframework .checker .lock .qual .GuardSatisfied ;
3941import org .checkerframework .checker .nonempty .qual .EnsuresNonEmpty ;
4042import org .checkerframework .checker .nonempty .qual .EnsuresNonEmptyIf ;
@@ -375,7 +377,7 @@ public boolean offerLast(E e) {
375377 /**
376378 * @throws NoSuchElementException {@inheritDoc}
377379 */
378- public E removeFirst (@ GuardSatisfied @ NonEmpty ArrayDeque <E > this ) {
380+ public E removeFirst (@ GuardSatisfied @ NonEmpty @ Shrinkable ArrayDeque <E > this ) {
379381 E e = pollFirst ();
380382 if (e == null )
381383 throw new NoSuchElementException ();
@@ -385,14 +387,14 @@ public E removeFirst(@GuardSatisfied @NonEmpty ArrayDeque<E> this) {
385387 /**
386388 * @throws NoSuchElementException {@inheritDoc}
387389 */
388- public E removeLast (@ GuardSatisfied @ NonEmpty ArrayDeque <E > this ) {
390+ public E removeLast (@ GuardSatisfied @ NonEmpty @ Shrinkable ArrayDeque <E > this ) {
389391 E e = pollLast ();
390392 if (e == null )
391393 throw new NoSuchElementException ();
392394 return e ;
393395 }
394396
395- public @ Nullable E pollFirst (@ GuardSatisfied ArrayDeque <E > this ) {
397+ public @ Nullable E pollFirst (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this ) {
396398 final Object [] es ;
397399 final int h ;
398400 E e = elementAt (es = elements , h = head );
@@ -403,7 +405,7 @@ public E removeLast(@GuardSatisfied @NonEmpty ArrayDeque<E> this) {
403405 return e ;
404406 }
405407
406- public @ Nullable E pollLast (@ GuardSatisfied ArrayDeque <E > this ) {
408+ public @ Nullable E pollLast (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this ) {
407409 final Object [] es ;
408410 final int t ;
409411 E e = elementAt (es = elements , t = dec (tail , es .length ));
@@ -456,7 +458,7 @@ public E getLast(@GuardSatisfied @NonEmpty ArrayDeque<E> this) {
456458 * @param o element to be removed from this deque, if present
457459 * @return {@code true} if the deque contained the specified element
458460 */
459- public boolean removeFirstOccurrence (@ GuardSatisfied ArrayDeque <E > this , @ Nullable Object o ) {
461+ public boolean removeFirstOccurrence (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this , @ GuardSatisfied @ Nullable @ UnknownSignedness Object o ) {
460462 if (o != null ) {
461463 final Object [] es = elements ;
462464 for (int i = head , end = tail , to = (i <= end ) ? end : es .length ;
@@ -484,7 +486,7 @@ public boolean removeFirstOccurrence(@GuardSatisfied ArrayDeque<E> this, @Nullab
484486 * @param o element to be removed from this deque, if present
485487 * @return {@code true} if the deque contained the specified element
486488 */
487- public boolean removeLastOccurrence (@ GuardSatisfied ArrayDeque <E > this , @ Nullable Object o ) {
489+ public boolean removeLastOccurrence (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this , @ GuardSatisfied @ Nullable @ UnknownSignedness Object o ) {
488490 if (o != null ) {
489491 final Object [] es = elements ;
490492 for (int i = tail , end = head , to = (i >= end ) ? end : 0 ;
@@ -541,7 +543,7 @@ public boolean offer(@GuardSatisfied ArrayDeque<E> this, E e) {
541543 * @return the head of the queue represented by this deque
542544 * @throws NoSuchElementException {@inheritDoc}
543545 */
544- public E remove (@ GuardSatisfied @ NonEmpty ArrayDeque <E > this ) {
546+ public E remove (@ GuardSatisfied @ NonEmpty @ Shrinkable ArrayDeque <E > this ) {
545547 return removeFirst ();
546548 }
547549
@@ -555,7 +557,7 @@ public E remove(@GuardSatisfied @NonEmpty ArrayDeque<E> this) {
555557 * @return the head of the queue represented by this deque, or
556558 * {@code null} if this deque is empty
557559 */
558- public @ Nullable E poll (@ GuardSatisfied ArrayDeque <E > this ) {
560+ public @ Nullable E poll (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this ) {
559561 return pollFirst ();
560562 }
561563
@@ -612,7 +614,7 @@ public void push(@GuardSatisfied ArrayDeque<E> this, E e) {
612614 * of the stack represented by this deque)
613615 * @throws NoSuchElementException {@inheritDoc}
614616 */
615- public E pop (@ GuardSatisfied @ NonEmpty ArrayDeque <E > this ) {
617+ public E pop (@ GuardSatisfied @ NonEmpty @ Shrinkable ArrayDeque <E > this ) {
616618 return removeFirst ();
617619 }
618620
@@ -694,11 +696,11 @@ public boolean isEmpty(@GuardSatisfied ArrayDeque<E> this) {
694696 * @return an iterator over the elements in this deque
695697 */
696698 @ SideEffectFree
697- public @ PolyNonEmpty Iterator <E > iterator (@ PolyNonEmpty ArrayDeque <E > this ) {
699+ public @ PolyGrowShrink @ PolyNonEmpty Iterator <E > iterator (@ PolyGrowShrink @ PolyNonEmpty ArrayDeque <E > this ) {
698700 return new DeqIterator ();
699701 }
700702
701- public @ PolyNonEmpty Iterator <E > descendingIterator (@ PolyNonEmpty ArrayDeque <E > this ) {
703+ public @ PolyGrowShrink @ PolyNonEmpty Iterator <E > descendingIterator (@ PolyGrowShrink @ PolyNonEmpty ArrayDeque <E > this ) {
702704 return new DescendingIterator ();
703705 }
704706
@@ -927,23 +929,23 @@ public void forEach(Consumer<? super E> action) {
927929 /**
928930 * @throws NullPointerException {@inheritDoc}
929931 */
930- public boolean removeIf (Predicate <? super E > filter ) {
932+ public boolean removeIf (@ Shrinkable ArrayDeque < E > this , Predicate <? super E > filter ) {
931933 Objects .requireNonNull (filter );
932934 return bulkRemove (filter );
933935 }
934936
935937 /**
936938 * @throws NullPointerException {@inheritDoc}
937939 */
938- public boolean removeAll (Collection <? extends @ UnknownSignedness Object > c ) {
940+ public boolean removeAll (@ Shrinkable ArrayDeque < E > this , Collection <? extends @ UnknownSignedness Object > c ) {
939941 Objects .requireNonNull (c );
940942 return bulkRemove (e -> c .contains (e ));
941943 }
942944
943945 /**
944946 * @throws NullPointerException {@inheritDoc}
945947 */
946- public boolean retainAll (Collection <? extends @ UnknownSignedness Object > c ) {
948+ public boolean retainAll (@ GuardSatisfied @ Shrinkable ArrayDeque < E > this , Collection <? extends @ UnknownSignedness Object > c ) {
947949 Objects .requireNonNull (c );
948950 return bulkRemove (e -> !c .contains (e ));
949951 }
@@ -1059,15 +1061,15 @@ public boolean contains(@GuardSatisfied ArrayDeque<E> this, @GuardSatisfied @Nul
10591061 * @param o element to be removed from this deque, if present
10601062 * @return {@code true} if this deque contained the specified element
10611063 */
1062- public boolean remove (@ GuardSatisfied ArrayDeque <E > this , @ GuardSatisfied @ Nullable @ UnknownSignedness Object o ) {
1064+ public boolean remove (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this , @ GuardSatisfied @ Nullable @ UnknownSignedness Object o ) {
10631065 return removeFirstOccurrence (o );
10641066 }
10651067
10661068 /**
10671069 * Removes all of the elements from this deque.
10681070 * The deque will be empty after this call returns.
10691071 */
1070- public void clear (@ GuardSatisfied ArrayDeque <E > this ) {
1072+ public void clear (@ GuardSatisfied @ Shrinkable ArrayDeque <E > this ) {
10711073 circularClear (elements , head , tail );
10721074 head = tail = 0 ;
10731075 }
0 commit comments