/** * Release internal buffers of this deque and reallocate with the default * buffer. */ public void release() { this.head = tail = 0; buffer = IntArrayList.EMPTY_ARRAY; ensureBufferSpace(0); }
/** * Ensure this container can hold at least the given number of elements * without resizing its buffers. * * @param expectedElements * The total number of elements, inclusive. */ @Override public void ensureCapacity(int expectedElements) { ensureBufferSpace(expectedElements - size()); }
/** * Vararg-signature method for adding elements at the front of this deque. * * <p><b>This method is handy, but costly if used in tight loops (anonymous * array passing)</b></p> * * @param elements The elements to add. */ /* */ public final void addFirst(int... elements) { ensureBufferSpace(elements.length); for (int k : elements) { addFirst(k); } }
/** * Vararg-signature method for adding elements at the end of this deque. * * <p> * <b>This method is handy, but costly if used in tight loops (anonymous array * passing)</b> * </p> * * @param elements The elements to iterate over. */ /* */ public final void addLast(int... elements) { ensureBufferSpace(1); for (int k : elements) { addLast(k); } }
/** * {@inheritDoc} */ @Override public void addFirst(int e1) { int h = oneLeft(head, buffer.length); if (h == tail) { ensureBufferSpace(1); h = oneLeft(head, buffer.length); } buffer[head = h] = e1; }
/** * {@inheritDoc} */ @Override public void addLast(int e1) { int t = oneRight(tail, buffer.length); if (head == t) { ensureBufferSpace(1); t = oneRight(tail, buffer.length); } buffer[tail] = e1; tail = t; }
/** * Inserts all elements from the given container to the front of this deque. * * @param container The container to iterate over. * * @return Returns the number of elements actually added as a result of this * call. */ public int addFirst(IntContainer container) { int size = container.size(); ensureBufferSpace(size); for (IntCursor cursor : container) { addFirst(cursor.value); } return size; }
/** * Inserts all elements from the given container to the end of this deque. * * @param container The container to iterate over. * * @return Returns the number of elements actually added as a result of this * call. */ public int addLast(IntContainer container) { int size = container.size(); ensureBufferSpace(size); for (IntCursor cursor : container) { addLast(cursor.value); } return size; }
/** * Release internal buffers of this deque and reallocate with the default * buffer. */ public void release() { this.head = tail = 0; buffer = IntArrayList.EMPTY_ARRAY; ensureBufferSpace(0); }
/** * Ensure this container can hold at least the given number of elements * without resizing its buffers. * * @param expectedElements * The total number of elements, inclusive. */ @Override public void ensureCapacity(int expectedElements) { ensureBufferSpace(expectedElements - size()); }
/** * Vararg-signature method for adding elements at the front of this deque. * * <p><b>This method is handy, but costly if used in tight loops (anonymous * array passing)</b></p> * * @param elements The elements to add. */ /* */ public final void addFirst(int... elements) { ensureBufferSpace(elements.length); for (int k : elements) { addFirst(k); } }
/** * Vararg-signature method for adding elements at the end of this deque. * * <p> * <b>This method is handy, but costly if used in tight loops (anonymous array * passing)</b> * </p> * * @param elements The elements to iterate over. */ /* */ public final void addLast(int... elements) { ensureBufferSpace(1); for (int k : elements) { addLast(k); } }
/** * {@inheritDoc} */ @Override public void addFirst(int e1) { int h = oneLeft(head, buffer.length); if (h == tail) { ensureBufferSpace(1); h = oneLeft(head, buffer.length); } buffer[head = h] = e1; }
/** * {@inheritDoc} */ @Override public void addLast(int e1) { int t = oneRight(tail, buffer.length); if (head == t) { ensureBufferSpace(1); t = oneRight(tail, buffer.length); } buffer[tail] = e1; tail = t; }
/** * Inserts all elements from the given container to the end of this deque. * * @param container The container to iterate over. * * @return Returns the number of elements actually added as a result of this * call. */ public int addLast(IntContainer container) { int size = container.size(); ensureBufferSpace(size); for (IntCursor cursor : container) { addLast(cursor.value); } return size; }
/** * Inserts all elements from the given container to the front of this deque. * * @param container The container to iterate over. * * @return Returns the number of elements actually added as a result of this * call. */ public int addFirst(IntContainer container) { int size = container.size(); ensureBufferSpace(size); for (IntCursor cursor : container) { addFirst(cursor.value); } return size; }