@Test public void testAdd() { list.add("c"); list.add("d"); list.add(0, "a"); list.add(1, "b"); list.add(4, "e"); list.add(5, "f"); assertEquals(list, GlazedListsTests.stringToList("abcdef")); }
@Override public void add(int index, T element) { growIfNecessary(); int indexToAdd = toCircularIndex(index); int distToHead = distanceToHead(indexToAdd); int distToTail = distanceToTail(indexToAdd); if (distToTail <= distToHead) { int tail = tail(); shift(indexToAdd, tail, 1); values[indexToAdd] = element; } else { shift(head, indexToAdd, -1); values[modIndex(indexToAdd - 1)] = element; head = modIndex(head - 1); } size++; }
CircularArrayList extends AbstractList<T> { @Override public void add(int index, T element) { growIfNecessary(); int indexToAdd = toCircularIndex(index); int distToHead = distanceToHead(indexToAdd); int distToTail = distanceToTail(indexToAdd); if (distToTail <= distToHead) { int tail = tail(); shift(indexToAdd, tail, 1); values[indexToAdd] = element; } else { shift(head, indexToAdd, -1); values[modIndex(indexToAdd - 1)] = element; head = modIndex(head - 1); } size++; } }
CircularArrayList extends AbstractList<T> { @Override public void add(int index, T element) { growIfNecessary(); int indexToAdd = toCircularIndex(index); int distToHead = distanceToHead(indexToAdd); int distToTail = distanceToTail(indexToAdd); if (distToTail <= distToHead) { int tail = tail(); shift(indexToAdd, tail, 1); values[indexToAdd] = element; } else { shift(head, indexToAdd, -1); values[modIndex(indexToAdd - 1)] = element; head = modIndex(head - 1); } size++; }  }
CircularArrayList extends AbstractList<T> { @Override public void add(int index, T element) { growIfNecessary(); int indexToAdd = toCircularIndex(index); int distToHead = distanceToHead(indexToAdd); int distToTail = distanceToTail(indexToAdd); if (distToTail <= distToHead) { int tail = tail(); shift(indexToAdd, tail, 1); values[indexToAdd] = element; } else { shift(head, indexToAdd, -1); values[modIndex(indexToAdd - 1)] = element; head = modIndex(head - 1); } size++; }  @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 void add(int index, T element) { growIfNecessary(); int indexToAdd = toCircularIndex(index); int distToHead = distanceToHead(indexToAdd); int distToTail = distanceToTail(indexToAdd); if (distToTail <= distToHead) { int tail = tail(); shift(indexToAdd, tail, 1); values[indexToAdd] = element; } else { shift(head, indexToAdd, -1); values[modIndex(indexToAdd - 1)] = element; head = modIndex(head - 1); } size++; }  @Override T get(int index); @Override void add(int index, T element); @Override T remove(int index); @Override int size();  }