Java Utililty Methods ArrayList Shuffle

List of utility methods to do ArrayList Shuffle

  1. HOME
  2. Java
  3. A
  4. ArrayList Shuffle

Description

The list of methods to do ArrayList Shuffle are organized into topic(s).

Method

ArrayList shuffle(ArrayList l)
shuffle
long seed = System.nanoTime();
Collections.shuffle(l, new Random(seed));
return l;
ArrayList shuffle(ArrayList population, int sample)
shuffle
ArrayList<T> newList = new ArrayList<T>();
ArrayList<T> ret = new ArrayList<T>();
newList.addAll(population);
Collections.shuffle(newList);
ret.addAll(newList);
for (int i = sample; i < ret.size(); i++) {
 ret.remove(i);
 i--;
...

AltStyle によって変換されたページ (->オリジナル) /