/** * {@inheritDoc} */ @Override public void clear() { if (!isEmpty()) { Arrays.fill(items, null); first = 0; last = 0; full = false; shrinkIfNeeded(); } }
@Override public void clear() { if (!isEmpty()) { Arrays.fill(items, null); first = 0; last = 0; full = false; shrinkIfNeeded(); } }
/** * {@inheritDoc} */ @Override public void clear() { if (!isEmpty()) { Arrays.fill(items, null); first = 0; last = 0; full = false; shrinkIfNeeded(); } }
@SuppressWarnings("unchecked") public E poll() { if (isEmpty()) { return null; } Object ret = items[first]; items[first] = null; decreaseSize(); if (first == last) { first = last = 0; } shrinkIfNeeded(); return (E) ret; }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public E poll() { if (isEmpty()) { return null; } Object ret = items[first]; items[first] = null; decreaseSize(); if (first == last) { first = last = 0; } shrinkIfNeeded(); return (E) ret; }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public E poll() { if (isEmpty()) { return null; } Object ret = items[first]; items[first] = null; decreaseSize(); if (first == last) { first = last = 0; } shrinkIfNeeded(); return (E) ret; }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public E remove(int idx) { if (idx == 0) { return poll(); } checkIndex(idx); int realIdx = getRealIndex(idx); Object removed = items[realIdx]; // Remove a room for the removed element. if (first < last) { System.arraycopy(items, first, items, first + 1, realIdx - first); } else { if (realIdx >= first) { System.arraycopy(items, first, items, first + 1, realIdx - first); } else { System.arraycopy(items, 0, items, 1, realIdx); items[0] = items[items.length - 1]; System.arraycopy(items, first, items, first + 1, items.length - first - 1); } } items[first] = null; decreaseSize(); shrinkIfNeeded(); return (E) removed; }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public E remove(int idx) { if (idx == 0) { return poll(); } checkIndex(idx); int realIdx = getRealIndex(idx); Object removed = items[realIdx]; // Remove a room for the removed element. if (first < last) { System.arraycopy(items, first, items, first + 1, realIdx - first); } else { if (realIdx >= first) { System.arraycopy(items, first, items, first + 1, realIdx - first); } else { System.arraycopy(items, 0, items, 1, realIdx); items[0] = items[items.length - 1]; System.arraycopy(items, first, items, first + 1, items.length - first - 1); } } items[first] = null; decreaseSize(); shrinkIfNeeded(); return (E) removed; }
@SuppressWarnings("unchecked") @Override public E remove(int idx) { if (idx == 0) { return poll(); } checkIndex(idx); int realIdx = getRealIndex(idx); Object removed = items[realIdx]; // Remove a room for the removed element. if (first < last) { System.arraycopy(items, first, items, first + 1, realIdx - first); } else { if (realIdx >= first) { System.arraycopy(items, first, items, first + 1, realIdx - first); } else { System.arraycopy(items, 0, items, 1, realIdx); items[0] = items[items.length - 1]; System.arraycopy(items, first, items, first + 1, items.length - first - 1); } } items[first] = null; decreaseSize(); shrinkIfNeeded(); return (E) removed; }