@Test public void insertInMiddle() { init("x", "y"); separatedList.add(1, new TextCell("a")); assertList("x, x+a, a, a+y, y"); }
@Override public void add(int index, Cell element) { if (index == 0) { if (!myBaseList.isEmpty()) { myBaseList.add(0, createSeparator(element, get(0))); } myBaseList.add(0, element); } else { myBaseList.add(index * 2 - 1, createSeparator(get(index - 1), element)); myBaseList.add(index * 2, element); if (index + 1 < size()) { myBaseList.set(index * 2 + 1, createSeparator(element, get(index + 1))); } } }
SeparatedCellList extends AbstractList<Cell> { @Override public void add(int index, Cell element) { if (index == 0) { if (!myBaseList.isEmpty()) { myBaseList.add(0, createSeparator(element, get(0))); } myBaseList.add(0, element); } else { myBaseList.add(index * 2 - 1, createSeparator(get(index - 1), element)); myBaseList.add(index * 2, element); if (index + 1 < size()) { myBaseList.set(index * 2 + 1, createSeparator(element, get(index + 1))); } } } }
SeparatedCellList extends AbstractList<Cell> { @Override public void add(int index, Cell element) { if (index == 0) { if (!myBaseList.isEmpty()) { myBaseList.add(0, createSeparator(element, get(0))); } myBaseList.add(0, element); } else { myBaseList.add(index * 2 - 1, createSeparator(get(index - 1), element)); myBaseList.add(index * 2, element); if (index + 1 < size()) { myBaseList.set(index * 2 + 1, createSeparator(element, get(index + 1))); } } } protected  SeparatedCellList(List<Cell> baseList); }
SeparatedCellList extends AbstractList<Cell> { @Override public void add(int index, Cell element) { if (index == 0) { if (!myBaseList.isEmpty()) { myBaseList.add(0, createSeparator(element, get(0))); } myBaseList.add(0, element); } else { myBaseList.add(index * 2 - 1, createSeparator(get(index - 1), element)); myBaseList.add(index * 2, element); if (index + 1 < size()) { myBaseList.set(index * 2 + 1, createSeparator(element, get(index + 1))); } } } protected  SeparatedCellList(List<Cell> baseList); @Override Cell get(int index); @Override int size(); @Override void add(int index, Cell element); @Override Cell remove(int index); @Override Cell set(int index, Cell element); }
SeparatedCellList extends AbstractList<Cell> { @Override public void add(int index, Cell element) { if (index == 0) { if (!myBaseList.isEmpty()) { myBaseList.add(0, createSeparator(element, get(0))); } myBaseList.add(0, element); } else { myBaseList.add(index * 2 - 1, createSeparator(get(index - 1), element)); myBaseList.add(index * 2, element); if (index + 1 < size()) { myBaseList.set(index * 2 + 1, createSeparator(element, get(index + 1))); } } } protected  SeparatedCellList(List<Cell> baseList); @Override Cell get(int index); @Override int size(); @Override void add(int index, Cell element); @Override Cell remove(int index); @Override Cell set(int index, Cell element);  }