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