1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| private boolean delete(int i) {
checkInvariants(); final Object[] elements = this.elements; final int mask = elements.length - 1; final int h = head; final int t = tail;
final int frOnt= (i - h) & mask;
final int back = (t - i) & mask;
if (front >= ((t - h) & mask)) throw new ConcurrentModificationException();
if (front if (h <= i) { System.arraycopy(elements, h, elements, h + 1, front); } else { System.arraycopy(elements, 0, elements, 1, i); elements[0] = elements[mask]; System.arraycopy(elements, h, elements, h + 1, mask - h); } elements[h] = null; head = (h + 1) & mask; return false; } else { if (i System.arraycopy(elements, i + 1, elements, i, back); tail = t - 1; } else { System.arraycopy(elements, i + 1, elements, i, mask - i); elements[mask] = elements[0]; System.arraycopy(elements, 1, elements, 0, t); tail = (t - 1) & mask; } return true; }
|