Class WeightedRandom

java.lang.Object
net.glowstone.util.WeightedRandom

public final class WeightedRandom extends Object
  • Constructor Details

    • WeightedRandom

      public WeightedRandom()
  • Method Details

    • getRandom

      public static <T extends WeightedRandom.Choice> T getRandom(Random random, Iterable<T> possibilities)
      Selects a random item from a weighted distribution.
      Type Parameters:
      T - the type of each of the possibilities
      Parameters:
      random - the PRNG to use
      possibilities - the distribution to sample from
      Returns:
      a random item