private Deque < MutablePair < DeltaType , Object > > combineDeltas ( LinkedList < MutablePair < DeltaType , Object > > deltas ) { if ( deltas . size ( ) < 2 ) { return deltas ; } int size = deltas . size ( ) ; MutablePair < DeltaType , Object > d1 = deltas . peekLast ( ) ; MutablePair < DeltaType , Object > d2 = deltas . get ( size - 2 ) ; MutablePair < DeltaType , Object > out = isDuplicate ( d1 , d2 ) ; if ( out != null ) { Deque < MutablePair < DeltaType , Object > > newDeltas = new LinkedList <> ( ) ; newDeltas . addAll ( deltas . subList ( 0 , size - 2 ) ) ; newDeltas . add ( out ) ; return newDeltas ; } return deltas ; }
order . This will combine the most recent two deltas if they are the same .