ListUtils { public static <Item> SparseBooleanArray getInsertions(@Nullable List<? extends Item> oldList, @NonNull List<? extends Item> newList){ SparseBooleanArray list = new SparseBooleanArray(); if(oldList != null) { int size = newList.size(); for (int newIndex = 0; newIndex < size; newIndex++) { Item itemFromNewList = newList.get(newIndex); if (oldList.indexOf(itemFromNewList) == NOT_PRESENT) { list.put(newIndex, true); } } } return list; }  static SparseBooleanArray getInsertions(@Nullable List<? extends Item> oldList, @NonNull List<? extends Item> newList); static SparseBooleanArray getDeletions(@Nullable List<? extends Item> oldList, @NonNull List<? extends Item> newList); static SparseIntArray getReorderings(List<? extends Item> oldList, List<? extends Item> newList);  }
@Test public void testSingleInsert() { SparseBooleanArray insertions = ListUtils.getInsertions(list05, list06); assertThat(insertions.size(), is(1)); assertThat(insertions.get(6), is(true)); }
@Test public void testSingleInsertHead() { SparseBooleanArray insertions = ListUtils.getInsertions(list15, list05); assertThat(insertions.size(), is(1)); assertThat(insertions.get(0), is(true)); }
@Test public void testMultiInsert() { SparseBooleanArray insertions = ListUtils.getInsertions(list15, list06); assertThat(insertions.size(), is(2)); assertThat(insertions.get(6), is(true)); assertThat(insertions.get(0), is(true)); }