baku-toolkit/lib/src/main/java/io/v/baku/toolkit/bind/DerivedListDeltaAccumulator.java
/**
         * @param working the mutable ordered (intermediate) start state
         * @param goal    the ordered end state
         */
@param working the mutable ordered (intermediate) start state
@param goal    the ordered end state
@param working the mutable ordered ( intermediate ) start state @param goal the ordered end state
void processInsertions(final List<T> working, final ImmutableList<T> goal) {
            final List<T> insert = new ArrayList<>();
            for (int i = 0; i < goal.size(); i++) {
                final T item = goal.get(i);
                final int insertAt = i - insert.size();
                if (insertAt < working.size() && item.equals(working.get(insertAt))) {
                    processInsertions(working, insertAt, insert);
                    insert.clear();
                } else {
                    insert.add(item);
                }
            }
            if (!insert.isEmpty()) {
                final int count = insert.size(), index = goal.size() - count;
                steps.add(new DerivedListDeltaAccumulator<T>(ids, stepFactory.apply(goal)) {
                    @Override
                    public void notifyDeltas(RecyclerView.Adapter<?> rva) {
                        rva.notifyItemRangeInserted(index, count);
                    }
                });
            }
        }
void processInsertions ( final List < T > working , final ImmutableList < T > goal ) { final List < T > insert = new ArrayList < > ( ) ; for ( int i = 0 ; i < goal . size ( ) ; i ++ ) { final T item = goal . get ( i ) ; final int insertAt = i - insert . size ( ) ; if ( insertAt < working . size ( ) && item . equals ( working . get ( insertAt ) ) ) { processInsertions ( working , insertAt , insert ) ; insert . clear ( ) ; } else { insert . add ( item ) ; } } if ( ! insert . isEmpty ( ) ) { final int count = insert . size ( ) , index = goal . size ( ) - count ; steps . add ( new DerivedListDeltaAccumulator < T > ( ids , stepFactory . apply ( goal ) ) { @ Override public void notifyDeltas ( RecyclerView . Adapter < ? > rva ) { rva . notifyItemRangeInserted ( index , count ) ; } } ) ; } }
@param working the mutable ordered (intermediate) start state
 @param goal    the ordered end state
@param working the mutable ordered ( intermediate ) start state @param goal the ordered end state
// Capture these ints so that we're not holding onto instances of the working lists // and opening us to errors if they're modified.