Package megamek.common.util.weightedMaps
Class WeightedIntMap<T>
java.lang.Object
java.util.AbstractMap<Integer,T>
java.util.TreeMap<Integer,T>
megamek.common.util.weightedMaps.AbstractWeightedMap<Integer,T>
megamek.common.util.weightedMaps.WeightedIntMap<T>
- Type Parameters:
T- The values in the table
- All Implemented Interfaces:
Serializable,Cloneable,Map<Integer,,T> NavigableMap<Integer,,T> SequencedMap<Integer,,T> SortedMap<Integer,T>
Constructs a table of values each with an int 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
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
-
WeightedIntMap
public WeightedIntMap()
-
-
Method Details
-
add
- Specified by:
addin classAbstractWeightedMap<Integer,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<Integer,T> - Returns:
- a random item from the weighted map, or null if it is empty
-