private int partitionItems ( int left , int right , int pivot , double [ ] origin ) { double pivotDistance = distance ( origin , items [ pivot ] ) ; listSwap ( items , pivot , right - 1 ) ; listSwap ( indexes , pivot , right - 1 ) ; int storeIndex = left ; for ( int i = left ; i < right - 1 ; i ++ ) { if ( distance ( origin , items [ i ] ) <= pivotDistance ) { listSwap ( items , i , storeIndex ) ; listSwap ( indexes , i , storeIndex ) ; storeIndex ++ ; } } listSwap ( items , storeIndex , right - 1 ) ; listSwap ( indexes , storeIndex , right - 1 ) ; return storeIndex ; }
Partition the points based on their distance to origin around the selected pivot .