ListUtils { public static <Item> SparseBooleanArray getDeletions(@Nullable List<? extends Item> oldList, @NonNull List<? extends Item> newList) { SparseBooleanArray list = new SparseBooleanArray(); if(oldList != null) { int size = oldList.size(); for (int oldIndex = 0; oldIndex < size; oldIndex++) { Item itemFromOldList = oldList.get(oldIndex); if (newList.indexOf(itemFromOldList) == NOT_PRESENT) { list.put(oldIndex, 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 testSingleDeletion() { SparseBooleanArray deletions = ListUtils.getDeletions(list06, list05); assertThat(deletions.size(), is(1)); assertThat(deletions.get(6), is(true)); }
@Test public void testSingleDeletionHead() { SparseBooleanArray deletions = ListUtils.getDeletions(list05, list15); assertThat(deletions.size(), is(1)); assertThat(deletions.get(0), is(true)); }
@Test public void testMultiDelete() { SparseBooleanArray deletions = ListUtils.getDeletions(list06, list15); assertThat(deletions.size(), is(2)); assertThat(deletions.get(6), is(true)); assertThat(deletions.get(0), is(true)); }