Java Array Shuffle shuffle(String str, Random randObj)

Here you can find the source of shuffle(String str, Random randObj)

Description

Single nucleotide shuffle

License

Open Source License

Parameter

Parameter Description
str a parameter
randObj a parameter

Declaration

public static String shuffle(String str, Random randObj) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    /**/*w w w.ja v  a2 s  . c  o m*/
     * Single nucleotide shuffle
     * @param str
     * @param randObj
     * @return
     */
    public static String shuffle(String str, Random randObj) {
        if (str.length() <= 1)
            return str;

        int split = str.length() / 2;

        String temp1 = shuffle(str.substring(0, split), randObj);
        String temp2 = shuffle(str.substring(split), randObj);

        if (randObj.nextDouble() > 0.5)
            return temp1 + temp2;
        else
            return temp2 + temp1;
    }
}

Related

  1. shuffle(Object[] a, Random r)
  2. shuffle(Object[] array)
  3. shuffle(Object[] objs, Random random, int start, int len)
  4. shuffle(Random rand, O[] array)
  5. shuffle(short... a)
  6. shuffle(T[] a, int from, int to, Random rnd)
  7. shuffle(T[] array)
  8. shuffle(T[] array)
  9. shuffle(T[] array)