@Test public void iteratorTest () { final CharQueue q = new CharQueue(); for (int j = 0; j <= 6; j++) q.addLast((char) j); Iterator<Character> iter = q.iterator(); for (int j = 0; j <= 6; j++) assertEquals(iter.next().charValue(), 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((char) j); for (int j = 3; j <= 6; j++) q.addLast((char) j); iter = q.iterator(); for (int j = 0; j <= 6; j++) assertEquals(iter.next().charValue(), 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<Character> iterator () { if (iterable == null) iterable = new CharQueueIterable(this); return iterable.iterator(); }
CharQueue { public Iterator<Character> iterator () { if (iterable == null) iterable = new CharQueueIterable(this); return iterable.iterator(); } }
CharQueue { public Iterator<Character> iterator () { if (iterable == null) iterable = new CharQueueIterable(this); return iterable.iterator(); } CharQueue();  CharQueue(int initialSize); }
CharQueue { public Iterator<Character> iterator () { if (iterable == null) iterable = new CharQueueIterable(this); return iterable.iterator(); } CharQueue();  CharQueue(int initialSize); void addLast(char object); void addFirst(char object); void ensureCapacity(int additional); char removeFirst(); char removeLast(); int indexOf(char value); boolean removeValue(char value); char removeIndex(int index); boolean notEmpty(); boolean isEmpty(); char first(); char last(); char get(int index); void clear(); Iterator<Character> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); }
CharQueue { public Iterator<Character> iterator () { if (iterable == null) iterable = new CharQueueIterable(this); return iterable.iterator(); } CharQueue();  CharQueue(int initialSize); void addLast(char object); void addFirst(char object); void ensureCapacity(int additional); char removeFirst(); char removeLast(); int indexOf(char value); boolean removeValue(char value); char removeIndex(int index); boolean notEmpty(); boolean isEmpty(); char first(); char last(); char get(int index); void clear(); Iterator<Character> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); public int size; }