Package megamek.common.util.weightedMaps
Class WeightedDoubleMap<T>
java.lang.Object
java.util.AbstractMap<Double,T>
java.util.TreeMap<Double,T>
megamek.common.util.weightedMaps.AbstractWeightedMap<Double,T>
megamek.common.util.weightedMaps.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>
Constructs a table of values each with a double weight that makes them more or less likely to be selected at random
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> WeightedDoubleMap<T> of(T t1, double w1) static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2) static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3) static <T> WeightedDoubleMap<T> of(T t1, double w1, T t2, double w2, T t3, double w3, T t4, double w4) 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) 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) 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) 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) 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) 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) randomOptionalItem(T[] except) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class megamek.common.util.weightedMaps.AbstractWeightedMap
randomItem, randomOptionalItemMethods inherited from class java.util.TreeMap
ceilingEntry, ceilingKey, clear, clone, comparator, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, merge, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, putFirst, putIfAbsent, putLast, remove, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, valuesMethods inherited from class java.util.AbstractMap
equals, hashCode, isEmpty, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.NavigableMap
reversedMethods inherited from interface java.util.SequencedMap
sequencedEntrySet, sequencedKeySet, sequencedValues
-
Constructor Details
-
WeightedDoubleMap
public WeightedDoubleMap()
-
-
Method Details
-
add
- Specified by:
addin classAbstractWeightedMap<Double,T> - Parameters:
weight- the weight to put the item atvalue- the value of the item- Returns:
- the return value of TreeMap#Put, or null if the value is not added to the map
-
randomItem
- Specified by:
randomItemin classAbstractWeightedMap<Double,T> - Returns:
- a random item from the weighted map, or null if it is empty
-
randomOptionalItem
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
-
of
-
of
-
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)
-