public static void randShuffleK(ArrayList<Integer> inds,int k,Random rand){
  for (int i=0; i < k; i++) {
    Collections.swap(inds,i,rand.nextInt(inds.size()));
  }
}

public static void randShuffleK ( ArrayList < Integer > inds , int k , Random rand ) { for ( int i = 0 ; i < k ; i ++ ) { Collections . swap ( inds , i , rand . nextInt ( inds . size ( ) ) ) ; } }
randomly shuffles k integers in a list . the first k elements are randomly swapped with other elements in the list . this method will alter the list passed to it , so situations where this would be undesirable should pass this method a copy .
