Class RandomizeHelper

java.lang.Object
org.javarosa.xform.parse.RandomizeHelper

public final class RandomizeHelper
extends Object
This class contains all the code needed to implement the xform randomize() function.
  • Constructor Details

  • Method Details

    • shuffle

      public static <T> List<T> shuffle​(List<T> elements)
      This method will return a new list with the same elements, randomly reordered. Every call to this method will produce a different random seed, which will potentially produce a different ordering each time.
      Type Parameters:
      T - Type of the elements in the list
      Parameters:
      elements - List of elements of type T to be shuffled
      Returns:
      a new List with the same input elements reordered
    • shuffle

      public static <T> List<T> shuffle​(List<T> elements, Long seed)
      This method will return a new list with the same elements, randomly reordered. Given the same seed, calls to this method will produce exactly the same output.
      Type Parameters:
      T - Type of the elements in the list
      Parameters:
      elements - List of elements of type T to be shuffled
      seed - Long seed for the Random number generator
      Returns:
      a new List with the same input elements reordered