Class RandomCollection<E>

java.lang.Object
dev.selena.luacore.utils.RandomCollection<E>
Type Parameters:
E - The reward of any type

public class RandomCollection<E> extends Object
Used for weighted random item/object generation For examples check the wiki
  • Constructor Details

    • RandomCollection

      public RandomCollection()
      Used to initialize the class using a new instance of random
    • RandomCollection

      public RandomCollection(Random random)
      Used to initialize the class using a fixed instance of random
      Parameters:
      random - The random instance you want to parse in
  • Method Details

    • add

      public RandomCollection<E> add(double weight, E result)
      Used for adding a weight
      Parameters:
      weight - The weight of the item added to the map
      result - The item itself
      Returns:
      This instance for further usage
    • getRandom

      public E getRandom()
      Gets a weighted random value
      Returns:
      The random value from the map