@Test public void iteratorTest () { final IntQueue q = new IntQueue(); for (int j = 0; j <= 6; j++) q.addLast(j); Iterator<Integer> iter = q.iterator(); for (int j = 0; j <= 6; j++) assertEquals(iter.next().intValue(), j); iter = q.iterator(); iter.next(); iter.remove(); assertValues(q, 1, 2, 3, 4, 5, 6); iter.next(); iter.remove(); assertValues(q, 2, 3, 4, 5, 6); iter.next(); iter.next(); iter.remove(); assertValues(q, 2, 4, 5, 6); iter.next(); iter.next(); iter.next(); iter.remove(); assertValues(q, 2, 4, 5); q.clear(); for (int j = 2; j >= 0; j--) q.addFirst(j); for (int j = 3; j <= 6; j++) q.addLast(j); iter = q.iterator(); for (int j = 0; j <= 6; j++) assertEquals(iter.next().intValue(), j); iter = q.iterator(); iter.next(); iter.remove(); assertValues(q, 1, 2, 3, 4, 5, 6); iter.next(); iter.remove(); assertValues(q, 2, 3, 4, 5, 6); iter.next(); iter.next(); iter.remove(); assertValues(q, 2, 4, 5, 6); iter.next(); iter.next(); iter.next(); iter.remove(); assertValues(q, 2, 4, 5); }
public Iterator<Integer> iterator () { if (iterable == null) iterable = new IntQueueIterable(this); return iterable.iterator(); }
IntQueue { public Iterator<Integer> iterator () { if (iterable == null) iterable = new IntQueueIterable(this); return iterable.iterator(); } }
IntQueue { public Iterator<Integer> iterator () { if (iterable == null) iterable = new IntQueueIterable(this); return iterable.iterator(); } IntQueue();  IntQueue(int initialSize); }
IntQueue { public Iterator<Integer> iterator () { if (iterable == null) iterable = new IntQueueIterable(this); return iterable.iterator(); } IntQueue();  IntQueue(int initialSize); void addLast(int object); void addFirst(int object); void ensureCapacity(int additional); int removeFirst(); int removeLast(); int indexOf(int value); boolean removeValue(int value); int removeIndex(int index); boolean notEmpty(); boolean isEmpty(); int first(); int last(); int get(int index); void clear(); Iterator<Integer> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); }
IntQueue { public Iterator<Integer> iterator () { if (iterable == null) iterable = new IntQueueIterable(this); return iterable.iterator(); } IntQueue();  IntQueue(int initialSize); void addLast(int object); void addFirst(int object); void ensureCapacity(int additional); int removeFirst(); int removeLast(); int indexOf(int value); boolean removeValue(int value); int removeIndex(int index); boolean notEmpty(); boolean isEmpty(); int first(); int last(); int get(int index); void clear(); Iterator<Integer> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); public int size; }