private int [ ] reIndexIndices ( SortableVertex [ ] sortVertices , int [ ] indices ) { // Create temporary lookup-array, O(n) int [ ] indexLUT = new int [ sortVertices . length ] ; int [ ] newIndices = new int [ indices . length ] ; for ( int i = 0 ; i < sortVertices . length ; ++ i ) { indexLUT [ sortVertices [ i ] . originalIndex ] = i ; } // Convert old indices to new indices, O(n) for ( int i = 0 ; i < indices . length ; ++ i ) { newIndices [ i ] = indexLUT [ indices [ i ] ] ; } return newIndices ; }
Re - index all indices based on the sorted vertices .