private static List < String > dedup ( List < String > encoded , Map < String , Integer > nameToLastIndex ) { boolean [ ] isLastInstance = new boolean [ encoded . size ( ) ] ; for ( int idx : nameToLastIndex . values ( ) ) { isLastInstance [ idx ] = true ; } List < String > dedupd = new ArrayList < String > ( nameToLastIndex . size ( ) ) ; for ( int i = 0 , n = encoded . size ( ) ; i < n ; i ++ ) { if ( isLastInstance [ i ] ) { dedupd . add ( encoded . get ( i ) ) ; } } return dedupd ; }
Deduplicate a list of encoded cookies by keeping only the last instance with a given name .