@Test public void getTest () { final LongQueue q = new LongQueue(7); for (int i = 0; i < 5; i++) { for (int j = 0; j < 4; j++) { q.addLast(j); } assertEquals("get(0) is not equal to peek (" + i + ")", q.get(0), q.first()); assertEquals("get(size-1) is not equal to peekLast (" + i + ")", q.get(q.size - 1), q.last()); for (int j = 0; j < 4; j++) { assertEquals(q.get(j), j); } for (int j = 0; j < 4 - 1; j++) { q.removeFirst(); assertEquals("get(0) is not equal to peek (" + i + ")", q.get(0), q.first()); } q.removeFirst(); assert q.size == 0; try { q.get(0); fail("get() on empty queue did not throw"); } catch (IndexOutOfBoundsException ignore) { } } }
public long get (int index) { if (index < 0) throw new IndexOutOfBoundsException("index can't be < 0: " + index); if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); final long[] values = this.values; int i = head + index; if (i >= values.length) { i -= values.length; } return values[i]; }
LongQueue { public long get (int index) { if (index < 0) throw new IndexOutOfBoundsException("index can't be < 0: " + index); if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); final long[] values = this.values; int i = head + index; if (i >= values.length) { i -= values.length; } return values[i]; } }
LongQueue { public long get (int index) { if (index < 0) throw new IndexOutOfBoundsException("index can't be < 0: " + index); if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); final long[] values = this.values; int i = head + index; if (i >= values.length) { i -= values.length; } return values[i]; } LongQueue();  LongQueue(int initialSize); }
LongQueue { public long get (int index) { if (index < 0) throw new IndexOutOfBoundsException("index can't be < 0: " + index); if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); final long[] values = this.values; int i = head + index; if (i >= values.length) { i -= values.length; } return values[i]; } LongQueue();  LongQueue(int initialSize); void addLast(long object); void addFirst(long object); void ensureCapacity(int additional); long removeFirst(); long removeLast(); int indexOf(long value); boolean removeValue(long value); long removeIndex(int index); boolean notEmpty(); boolean isEmpty(); long first(); long last(); long get(int index); void clear(); Iterator<Long> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); }
LongQueue { public long get (int index) { if (index < 0) throw new IndexOutOfBoundsException("index can't be < 0: " + index); if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); final long[] values = this.values; int i = head + index; if (i >= values.length) { i -= values.length; } return values[i]; } LongQueue();  LongQueue(int initialSize); void addLast(long object); void addFirst(long object); void ensureCapacity(int additional); long removeFirst(); long removeLast(); int indexOf(long value); boolean removeValue(long value); long removeIndex(int index); boolean notEmpty(); boolean isEmpty(); long first(); long last(); long get(int index); void clear(); Iterator<Long> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); public int size; }