SortedList { public int add(T item) { throwIfMerging(); return add(item, true); } SortedList(Class<T> klass, Callback<T> callback);  SortedList(Class<T> klass, Callback<T> callback, int initialCapacity); int size(); int add(T item); void addAll(T[] items, boolean mayModifyInput); void addAll(T... items); void addAll(Collection<T> items); void beginBatchedUpdates(); void endBatchedUpdates(); boolean remove(T item); T removeItemAt(int index); void updateItemAt(int index, T item); void recalculatePositionOfItemAt(int index); T get(int index); int indexOf(T item); void clear(); static final int INVALID_POSITION; }
@Test public void testAdd() { Item item = new Item(); assertEquals(insert(item), 0); assertEquals(size(), 1); assertTrue(mAdditions.contains(new Pair(0, 1))); Item item2 = new Item(); item2.cmpField = item.cmpField + 1; assertEquals(insert(item2), 1); assertEquals(size(), 2); assertTrue(mAdditions.contains(new Pair(1, 1))); Item item3 = new Item(); item3.cmpField = item.cmpField - 1; mAdditions.clear(); assertEquals(insert(item3), 0); assertEquals(size(), 3); assertTrue(mAdditions.contains(new Pair(0, 1))); }