Rearrange the elements of the subarray a[lo..hi] in random order.

@param a the array to shuffle.
@param hi the upper bound.
@param lo the lower bound.
768642
public static void shuffle(Object[] a, int lo, int hi) {
    if (lo < 0 || lo > hi || hi >= a.length) {
      throw new IndexOutOfBoundsException("Illegal subarray range");
    }
    for (int i = lo; i <= hi; i++) {
      int r = i + uniform(hi - i + 1); // between i and hi
      Object temp = a[i];
      a[i] = a[r];
      a[r] = temp;
    }
  }
583550
public static void shuffle(final Object[] array) {
    synchronized (array) {
      // asList uses the backing array as store,
      // therefore changes to the list are reflected by the array.
      Collections.shuffle(Arrays.asList(array), random);
    }
  }
1374046
public static void shuffleArray(int[] ar)
    {
        Random rnd = new Random();
        for (int i = ar.length - 1; i > 0; i--)
        {
            int index = rnd.nextInt(i + 1);
            // Simple swap
            int a = ar[index];
            ar[index] = ar[i];
            ar[i] = a;
        }
    }
824205
public static void Shuffle(double[] array, long seed) {
        Random random = new Random();
        if (seed != 0) random.setSeed(seed);

        for (int i = array.length - 1; i > 0; i--) {
            int index = random.nextInt(i + 1);
            double temp = array[index];
            array[index] = array[i];
            array[i] = temp;
        }
    }
1150632
public void setToInverseL( double a[] ) {
        // TODO reorder these operations to avoid cache misses
        
        // inverts the lower triangular system and saves the result
        // in the upper triangle to minimize cache misses
        for( int i =0; i < n; i++ ) {
            double el_ii = t[i*n+i];
            for( int j = 0; j <= i; j++ ) {
                double sum = (i==j) ? 1.0 : 0;
                for( int k=i-1; k >=j; k-- ) {
                    sum -= t[i*n+k]*a[j*n+k];
                }
                a[j*n+i] = sum / el_ii;
            }
        }
        // solve the system and handle the previous solution being in the upper triangle
        // takes advantage of symmetry
        for( int i=n-1; i>=0; i-- ) {
            double el_ii = t[i*n+i];

            for( int j = 0; j <= i; j++ ) {
                double sum = (i<j) ? 0 : a[j*n+i];
                for( int k=i+1;k<n;k++) {
                    sum -= t[k*n+i]*a[j*n+k];
                }
                a[i*n+j] = a[j*n+i] = sum / el_ii;
            }
        }
    }
1331980
public void shuffleColumnsAndThenRows(ArrayList<String> columns, ArrayList<String> rows) throws Exception {
		doubleValues.clear();

		for (String column : columns) { //shuffle all values in the column
			ArrayList<Integer> rowIndex = new ArrayList<Integer>();
			for (int i = 0; i < rows.size(); i++) {
				rowIndex.add(i);
			}
			Collections.shuffle(rowIndex);
			for (int i = 0; i < rows.size(); i++) {
				String row = rows.get(i);
				int randomIndex = rowIndex.get(i);
				String destinationRow = rows.get(randomIndex);


				String temp = this.getCell(destinationRow, column);
				String value = this.getCell(row, column);
				this.addCell(destinationRow, column, value);
				this.addCell(row, column, temp);
			}
		}

		for (String row : rows) {
			ArrayList<Integer> columnIndex = new ArrayList<Integer>();
			for (int i = 0; i < columns.size(); i++) {
				columnIndex.add(i);
			}
			Collections.shuffle(columnIndex);
			for (int i = 0; i < columns.size(); i++) {
				String column = columns.get(i);

				int randomIndex = columnIndex.get(i);
				String destinationCol = columns.get(randomIndex);


				String temp = this.getCell(row, destinationCol);
				String value = this.getCell(row, column);
				this.addCell(row, destinationCol, value);
				this.addCell(row, column, temp);
			}
		}


	}
808458
public static void swap(char[] charArray, int index1, int index2) {
        TrivialSwap.swap(charArray, index1, charArray, index2);
    }
1225207
public static void shuffle(final int[] arr, final Random rng) {
    // Fisher-Yates shuffle
    for (int i = arr.length; i > 1; i--) {
      // swap i-1 and a random spot
      final int a = i - 1;
      final int b = rng.nextInt(i);

      final int tmp = arr[b];
      arr[b] = arr[a];
      arr[a] = tmp;
    }
  }
751549
public static void scale(double[][] x, double lo, double hi) {
        int n = x.length;
        int p = x[0].length;

        double[] min = colMin(x);
        double[] max = colMax(x);

        for (int j = 0; j < p; j++) {
            double scale = max[j] - min[j];
            if (!Math.isZero(scale)) {
                for (int i = 0; i < n; i++) {
                    x[i][j] = (x[i][j] - min[j]) / scale;
                }
            } else {
                for (int i = 0; i < n; i++) {
                    x[i][j] = 0.5;
                }
            }
        }
    }
492059
public double nextDouble(double lo, double hi) {
        if (lo < 0) {
            if (nextInt(2) == 0)
                return -nextDouble(0, -lo);
            else
                return nextDouble(0, hi);
        } else {
            return (lo + (hi - lo) * nextDouble());
        }
    }
416641
public void sortReverse() {
    Arrays.sort(this.elements, 0, this.size);
    for (int i = 0; i < this.size / 2; i++) {
      long temp = this.elements[i];
      this.elements[i] = this.elements[this.size - i - 1];
      this.elements[this.size - i - 1] = temp;
    }
  }
365861
private void generatePermutations(
      ArrayList<HashMap<String, String[]>[]> result, int index,
      HashMap<String, String[]>[][] subResult) {
    int localIndex = index;
    HashMap<String, String[]>[] value = subResult[localIndex];
    if (localIndex == 0) {
      for (int i = 0; i < value.length; i++) {
        HashMap<String, String[]>[] resultItem = new HashMap[subResult.length];
        resultItem[localIndex] = value[i];
        result.add(resultItem);
      }
    } else {
      ArrayList<HashMap<String, String[]>[]> newResult = new ArrayList<>();
      for (int e = 0; e < result.size(); e++) {
        for (int i = 0; i < value.length; i++) {
          HashMap<String, String[]>[] resultItem = result.get(e);
          resultItem[localIndex] = value[i];
          newResult.add(resultItem);
        }
      }
      result.clear();
      result.addAll(newResult);
    }
    localIndex++;
    if (localIndex < subResult.length) {
      generatePermutations(result, localIndex, subResult);
    }
  }
913762
public void sort(int a[], int lo0, int hi0) throws Exception
  {

    int lo = lo0;
    int hi = hi0;

    // pause(lo, hi);
    if (lo >= hi)
    {
      return;
    }
    else if (lo == hi - 1)
    {

      /*
       *  sort a two element list by swapping if necessary
       */
      if (a[lo] > a[hi])
      {
        int T = a[lo];

        a[lo] = a[hi];
        a[hi] = T;
      }

      return;
    }

    /*
     *  Pick a pivot and move it out of the way
     */
    int pivot = a[(lo + hi) / 2];

    a[(lo + hi) / 2] = a[hi];
    a[hi] = pivot;

    while (lo < hi)
    {

      /*
       *  Search forward from a[lo] until an element is found that
       *  is greater than the pivot or lo >= hi
       */
      while (a[lo] <= pivot && lo < hi)
      {
        lo++;
      }

      /*
       *  Search backward from a[hi] until element is found that
       *  is less than the pivot, or lo >= hi
       */
      while (pivot <= a[hi] && lo < hi)
      {
        hi--;
      }

      /*
       *  Swap elements a[lo] and a[hi]
       */
      if (lo < hi)
      {
        int T = a[lo];

        a[lo] = a[hi];
        a[hi] = T;

        // pause();
      }

      // if (stopRequested) {
      //    return;
      // }
    }

    /*
     *  Put the median in the "center" of the list
     */
    a[hi0] = a[hi];
    a[hi] = pivot;

    /*
     *  Recursive calls, elements a[lo0] to a[lo-1] are less than or
     *  equal to pivot, elements a[hi+1] to a[hi0] are greater than
     *  pivot.
     */
    sort(a, lo0, lo - 1);
    sort(a, hi + 1, hi0);
  }
59025
@Override
    public ListT<W,T> shuffle(final Random random) {

        return (ListT<W,T>) FoldableTransformerSeq.super.shuffle(random);
    }
148395
public static void shuffle( byte []array , int offset , int length , Random rand ) {
		for (int i = 0; i < length; i++) {
			int src = rand.nextInt(length-i);
			byte tmp = array[offset+src+i];
			array[offset+src+i]=array[offset+i];
			array[offset+i] = tmp;
		}
	}
444663
private void swap(int i, int j) {
        int t = pq[i];
        pq[i] = pq[j];
        pq[j] = t;
        qp[pq[i]] = i;
        qp[pq[j]] = j;
    }
447642
public static <T extends Comparable<? super T>> void rsort (T[] a)
    {
        rsort(a, 0, a.length - 1);
    }