@Test public void indexOfTest () { final LongQueue q = new LongQueue(); for (int j = 0; j <= 6; j++) q.addLast(j); for (int j = 0; j <= 6; j++) assertEquals(q.indexOf(j), j); q.clear(); for (int j = 2; j >= 0; j--) q.addFirst(j); for (int j = 3; j <= 6; j++) q.addLast(j); for (int j = 0; j <= 6; j++) assertEquals(q.indexOf(j), j); }
public int indexOf (long value) { if (size == 0) return -1; long[] values = this.values; final int head = this.head, tail = this.tail; if (head < tail) { for (int i = head; i < tail; i++) if (values[i] == value) return i - head; } else { for (int i = head, n = values.length; i < n; i++) if (values[i] == value) return i - head; for (int i = 0; i < tail; i++) if (values[i] == value) return i + values.length - head; } return -1; }
LongQueue { public int indexOf (long value) { if (size == 0) return -1; long[] values = this.values; final int head = this.head, tail = this.tail; if (head < tail) { for (int i = head; i < tail; i++) if (values[i] == value) return i - head; } else { for (int i = head, n = values.length; i < n; i++) if (values[i] == value) return i - head; for (int i = 0; i < tail; i++) if (values[i] == value) return i + values.length - head; } return -1; } }
LongQueue { public int indexOf (long value) { if (size == 0) return -1; long[] values = this.values; final int head = this.head, tail = this.tail; if (head < tail) { for (int i = head; i < tail; i++) if (values[i] == value) return i - head; } else { for (int i = head, n = values.length; i < n; i++) if (values[i] == value) return i - head; for (int i = 0; i < tail; i++) if (values[i] == value) return i + values.length - head; } return -1; } LongQueue();  LongQueue(int initialSize); }
LongQueue { public int indexOf (long value) { if (size == 0) return -1; long[] values = this.values; final int head = this.head, tail = this.tail; if (head < tail) { for (int i = head; i < tail; i++) if (values[i] == value) return i - head; } else { for (int i = head, n = values.length; i < n; i++) if (values[i] == value) return i - head; for (int i = 0; i < tail; i++) if (values[i] == value) return i + values.length - head; } return -1; } 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 int indexOf (long value) { if (size == 0) return -1; long[] values = this.values; final int head = this.head, tail = this.tail; if (head < tail) { for (int i = head; i < tail; i++) if (values[i] == value) return i - head; } else { for (int i = head, n = values.length; i < n; i++) if (values[i] == value) return i - head; for (int i = 0; i < tail; i++) if (values[i] == value) return i + values.length - head; } return -1; } 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; }