/** * Return the index of the last (counting from tail) element equal to * <code>e1</code>. The index points to the {@link #buffer} array. * * @param e1 * The element to look for. * @return Returns the index of the first element equal to <code>e1</code> or * <code>-1</code> if not found. */ public int lastBufferIndexOf(int e1) { final int bufLen = buffer.length; final int last = oneLeft(head, bufLen); for (int i = oneLeft(tail, bufLen); i != last; i = oneLeft(i, bufLen)) { if (((buffer[i]) == ( e1))) return i; } return -1; }
/** * {@inheritDoc} */ @Override public int getLast() { assert size() > 0 : "The deque is empty."; return buffer[oneLeft(tail, buffer.length)]; }
@Override protected IntCursor fetch() { if (remaining == 0) return done(); remaining--; cursor.value = buffer[cursor.index = oneLeft(cursor.index, buffer.length)]; return cursor; } }
/** * {@inheritDoc} */ @Override public int removeLast() { assert size() > 0 : "The deque is empty."; tail = oneLeft(tail, buffer.length); final int result = buffer[tail]; buffer[tail] = 0; return result; }
/** * Applies <code>procedure</code> to a slice of the deque, * <code>toIndex</code>, exclusive, down to <code>fromIndex</code>, inclusive. */ private void descendingForEach(IntProcedure procedure, int fromIndex, final int toIndex) { if (fromIndex == toIndex) return; final int[] buffer = this.buffer; int i = toIndex; do { i = oneLeft(i, buffer.length); procedure.apply(buffer[i]); } while (i != fromIndex); }
/** * Applies <code>predicate</code> to a slice of the deque, * <code>toIndex</code>, exclusive, down to <code>fromIndex</code>, inclusive * or until the predicate returns <code>false</code>. */ private void descendingForEach(IntPredicate predicate, int fromIndex, final int toIndex) { if (fromIndex == toIndex) return; final int[] buffer = this.buffer; int i = toIndex; do { i = oneLeft(i, buffer.length); if (!predicate.apply(buffer[i])) { break; } } while (i != fromIndex); }
public ValueIterator() { cursor = new IntCursor(); cursor.index = oneLeft(head, buffer.length); this.remaining = size(); }
this.tail = oneLeft(tail, bufLen);
/** * Return the index of the last (counting from tail) element equal to * <code>e1</code>. The index points to the {@link #buffer} array. * * @param e1 * The element to look for. * @return Returns the index of the first element equal to <code>e1</code> or * <code>-1</code> if not found. */ public int lastBufferIndexOf(int e1) { final int bufLen = buffer.length; final int last = oneLeft(head, bufLen); for (int i = oneLeft(tail, bufLen); i != last; i = oneLeft(i, bufLen)) { if (((buffer[i]) == ( e1))) return i; } return -1; }
/** * {@inheritDoc} */ @Override public int removeLast() { assert size() > 0 : "The deque is empty."; tail = oneLeft(tail, buffer.length); final int result = buffer[tail]; buffer[tail] = 0; return result; }
@Override protected IntCursor fetch() { if (remaining == 0) return done(); remaining--; cursor.value = buffer[cursor.index = oneLeft(cursor.index, buffer.length)]; return cursor; } }
/** * {@inheritDoc} */ @Override public int getLast() { assert size() > 0 : "The deque is empty."; return buffer[oneLeft(tail, buffer.length)]; }
/** * Applies <code>procedure</code> to a slice of the deque, * <code>toIndex</code>, exclusive, down to <code>fromIndex</code>, inclusive. */ private void descendingForEach(IntProcedure procedure, int fromIndex, final int toIndex) { if (fromIndex == toIndex) return; final int[] buffer = this.buffer; int i = toIndex; do { i = oneLeft(i, buffer.length); procedure.apply(buffer[i]); } while (i != fromIndex); }
/** * Applies <code>predicate</code> to a slice of the deque, * <code>toIndex</code>, exclusive, down to <code>fromIndex</code>, inclusive * or until the predicate returns <code>false</code>. */ private void descendingForEach(IntPredicate predicate, int fromIndex, final int toIndex) { if (fromIndex == toIndex) return; final int[] buffer = this.buffer; int i = toIndex; do { i = oneLeft(i, buffer.length); if (!predicate.apply(buffer[i])) { break; } } while (i != fromIndex); }
public ValueIterator() { cursor = new IntCursor(); cursor.index = oneLeft(head, buffer.length); this.remaining = size(); }
this.tail = oneLeft(tail, bufLen);