@Test public void removeLastTest() { CharQueue queue = new CharQueue(); queue.addLast((char) 1); queue.addLast((char) 2); queue.addLast((char) 3); queue.addLast((char) 4); assertEquals(4, queue.size); assertEquals(3, queue.indexOf((char) 4)); assertEquals((char) 4, queue.removeLast()); assertEquals(3, queue.size); assertEquals(2, queue.indexOf((char) 3)); assertEquals((char) 3, queue.removeLast()); assertEquals(2, queue.size); assertEquals(1, queue.indexOf((char) 2)); assertEquals((char) 2, queue.removeLast()); assertEquals(1, queue.size); assertEquals(0, queue.indexOf((char) 1)); assertEquals((char) 1, queue.removeLast()); assertEquals(0, queue.size); }
public char removeLast () { if (size == 0) { throw new NoSuchElementException("Queue is empty."); } final char[] values = this.values; int tail = this.tail; tail--; if (tail == -1) { tail = values.length - 1; } final char result = values[tail]; this.tail = tail; size--; return result; }
CharQueue { public char removeLast () { if (size == 0) { throw new NoSuchElementException("Queue is empty."); } final char[] values = this.values; int tail = this.tail; tail--; if (tail == -1) { tail = values.length - 1; } final char result = values[tail]; this.tail = tail; size--; return result; } }
CharQueue { public char removeLast () { if (size == 0) { throw new NoSuchElementException("Queue is empty."); } final char[] values = this.values; int tail = this.tail; tail--; if (tail == -1) { tail = values.length - 1; } final char result = values[tail]; this.tail = tail; size--; return result; } CharQueue();  CharQueue(int initialSize); }
CharQueue { public char removeLast () { if (size == 0) { throw new NoSuchElementException("Queue is empty."); } final char[] values = this.values; int tail = this.tail; tail--; if (tail == -1) { tail = values.length - 1; } final char result = values[tail]; this.tail = tail; size--; return result; } 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 char removeLast () { if (size == 0) { throw new NoSuchElementException("Queue is empty."); } final char[] values = this.values; int tail = this.tail; tail--; if (tail == -1) { tail = values.length - 1; } final char result = values[tail]; this.tail = tail; size--; return result; } 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; }