public List < Integer > reindex ( List < Coordinate > coords ) { List < Integer > result = new ArrayList <> ( ) ; for ( Coordinate coord : coords ) { Coordinate sub = swap . get ( coord ) ; Coordinate use = ( sub == null ) ? coord : sub ; Integer idx = indexMap . get ( use ) ; // index into unionCoords if ( idx == null ) { throw new IllegalStateException ( ) ; } result . add ( idx ) ; } return result ; }
redo the variables against the shared coordinates