guava/src/com/google/common/collect/TopKSelector.java
private int partition(int left, int right, int pivotIndex) {
    T pivotValue = buffer[pivotIndex];
    buffer[pivotIndex] = buffer[right];

    int pivotNewIndex = left;
    for (int i = left; i < right; i++) {
      if (comparator.compare(buffer[i], pivotValue) < 0) {
        swap(pivotNewIndex, i);
        pivotNewIndex++;
      }
    }
    buffer[right] = buffer[pivotNewIndex];
    buffer[pivotNewIndex] = pivotValue;
    return pivotNewIndex;
  }
private int partition(int left, int right, int pivotIndex) {
    T pivotValue = buffer[pivotIndex];
    buffer[pivotIndex] = buffer[right];

    int pivotNewIndex = left;
    for (int i = left; i < right; i++) {
      if (comparator.compare(buffer[i], pivotValue) < 0) {
        swap(pivotNewIndex, i);
        pivotNewIndex++;
      }
    }
    buffer[right] = buffer[pivotNewIndex];
    buffer[pivotNewIndex] = pivotValue;
    return pivotNewIndex;
  }
private int partition ( int left , int right , int pivotIndex ) { T pivotValue = buffer [ pivotIndex ] ; buffer [ pivotIndex ] = buffer [ right ] ; int pivotNewIndex = left ; for ( int i = left ; i < right ; i ++ ) { if ( comparator . compare ( buffer [ i ] , pivotValue ) < 0 ) { swap ( pivotNewIndex , i ) ; pivotNewIndex ++ ; } } buffer [ right ] = buffer [ pivotNewIndex ] ; buffer [ pivotNewIndex ] = pivotValue ; return pivotNewIndex ; }
Partitions the contents of buffer in the range [left, right] around the pivot element
previously stored in buffer[pivotValue]. Returns the new index of the pivot element,
pivotNewIndex, so that everything in [left, pivotNewIndex] is ≤ pivotValue and everything in
(pivotNewIndex, right] is greater than pivotValue.
Partitions the contents of buffer in the range [ left right ] around the pivot element previously stored in buffer [ pivotValue ] . Returns the new index of the pivot element pivotNewIndex so that everything in [ left pivotNewIndex ] is ≤ pivotValue and everything in ( pivotNewIndex right ] is greater than pivotValue .