@Test public void testRemove() { list.addAll(GlazedListsTests.stringToList("abcdef")); list.remove(2); list.remove(3); assertEquals(list, GlazedListsTests.stringToList("abdf")); list.remove(0); list.remove(0); assertEquals(list, GlazedListsTests.stringToList("df")); list.remove(1); list.remove(0); assertEquals(list, GlazedListsTests.stringToList("")); }
@Override public T remove(int index) { int indexToRemove = toCircularIndex(index); int distToHead = distanceToHead(indexToRemove); int distToTail = distanceToTail(indexToRemove); T removed = get(index); if (distToTail < distToHead) { int tail = tail(); shift(indexToRemove + 1, tail, -1); values[modIndex(tail - 1)] = null; } else { shift(head, indexToRemove, 1); values[head] = null; head = modIndex(head + 1); } size--; return removed; }
CircularArrayList extends AbstractList<T> { @Override public T remove(int index) { int indexToRemove = toCircularIndex(index); int distToHead = distanceToHead(indexToRemove); int distToTail = distanceToTail(indexToRemove); T removed = get(index); if (distToTail < distToHead) { int tail = tail(); shift(indexToRemove + 1, tail, -1); values[modIndex(tail - 1)] = null; } else { shift(head, indexToRemove, 1); values[head] = null; head = modIndex(head + 1); } size--; return removed; } }
CircularArrayList extends AbstractList<T> { @Override public T remove(int index) { int indexToRemove = toCircularIndex(index); int distToHead = distanceToHead(indexToRemove); int distToTail = distanceToTail(indexToRemove); T removed = get(index); if (distToTail < distToHead) { int tail = tail(); shift(indexToRemove + 1, tail, -1); values[modIndex(tail - 1)] = null; } else { shift(head, indexToRemove, 1); values[head] = null; head = modIndex(head + 1); } size--; return removed; }  }
CircularArrayList extends AbstractList<T> { @Override public T remove(int index) { int indexToRemove = toCircularIndex(index); int distToHead = distanceToHead(indexToRemove); int distToTail = distanceToTail(indexToRemove); T removed = get(index); if (distToTail < distToHead) { int tail = tail(); shift(indexToRemove + 1, tail, -1); values[modIndex(tail - 1)] = null; } else { shift(head, indexToRemove, 1); values[head] = null; head = modIndex(head + 1); } size--; return removed; }  @Override T get(int index); @Override void add(int index, T element); @Override T remove(int index); @Override int size(); }
CircularArrayList extends AbstractList<T> { @Override public T remove(int index) { int indexToRemove = toCircularIndex(index); int distToHead = distanceToHead(indexToRemove); int distToTail = distanceToTail(indexToRemove); T removed = get(index); if (distToTail < distToHead) { int tail = tail(); shift(indexToRemove + 1, tail, -1); values[modIndex(tail - 1)] = null; } else { shift(head, indexToRemove, 1); values[head] = null; head = modIndex(head + 1); } size--; return removed; }  @Override T get(int index); @Override void add(int index, T element); @Override T remove(int index); @Override int size();  }