Class RandomWeightedSet<A>

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<A,Double>
com.pixelmonmod.pixelmon.api.util.RandomWeightedSet<A>
Type Parameters:
A - The type
All Implemented Interfaces:
Serializable, Cloneable, Map<A,Double>

public class RandomWeightedSet<A> extends HashMap<A,Double>
A set of items that have weighted and can be randomly selected from according to said weightings
See Also:
  • Field Details

    • treeMap

      protected final transient NavigableMap<Double,A> treeMap
    • totalWeight

      protected transient double totalWeight
  • Constructor Details

    • RandomWeightedSet

      public RandomWeightedSet()
    • RandomWeightedSet

      public RandomWeightedSet(A a, double weight)
  • Method Details

    • add

      public RandomWeightedSet<A> add(A a, double weight)
    • clear

      public void clear()
      Specified by:
      clear in interface Map<A,Double>
      Overrides:
      clear in class HashMap<A,Double>
    • getRandom

      public A getRandom()
    • getTotalWeight

      public double getTotalWeight()
    • codec

      public static <B> com.mojang.serialization.Codec<RandomWeightedSet<B>> codec(com.mojang.serialization.Codec<B> codec)