Class WeightedDoubleMap<T>

Type Parameters:
T - The values in the table
All Implemented Interfaces:
Serializable, Cloneable, Map<Double,T>, NavigableMap<Double,T>, SequencedMap<Double,T>, SortedMap<Double,T>

public class WeightedDoubleMap<T> extends AbstractWeightedMap<Double,T>
Constructs a table of values each with a double weight that makes them more or less likely to be selected at random
See Also:
  • Constructor Details

    • WeightedDoubleMap

      public WeightedDoubleMap()
  • Method Details

    • add

      @Nullable public T add(Double weight, T value)
      Specified by:
      add in class AbstractWeightedMap<Double,T>
      Parameters:
      weight - the weight to put the item at
      value - the value of the item
      Returns:
      the return value of TreeMap#Put, or null if the value is not added to the map
    • randomItem

      @Nullable public T randomItem()
      Specified by:
      randomItem in class AbstractWeightedMap<Double,T>
      Returns:
      a random item from the weighted map, or null if it is empty
    • randomOptionalItem

      @Deprecated(since="0.51.0", forRemoval=true) public Optional<T> randomOptionalItem(T[] except)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      an optional random item from the weighted map, or Optional empty if it is empty
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4, T t5, double w5)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4, T t5, double w5, T t6, double w6)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4, T t5, double w5, T t6, double w6, T t7, double w7)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4, T t5, double w5, T t6, double w6, T t7, double w7, T t8, double w8)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4, T t5, double w5, T t6, double w6, T t7, double w7, T t8, double w8, T t9, double w9)
    • of

      public static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4, T t5, double w5, T t6, double w6, T t7, double w7, T t8, double w8, T t9, double w9, T t10, double w10)