Contents
Class WeightedMap<T>
java.lang.Object
com.hypixel.hytale.builtin.hytalegenerator.WeightedMap<T>
Facilitates picking random values based on weights. The elements' weight
proportional to the sum of all weights determines its chance to be picked.
This implementation makes use of the Object::equals(...) and Object::hash() methods.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.WeightedMap(int initialCapacity) Initial expected capacity of the map, not maximum size.WeightedMap(WeightedMap<T> other) Creates a new map that clones over the state and contents of the other provided. -
Method Summary
-
Constructor Details
-
WeightedMap
Creates a new map that clones over the state and contents of the other provided.- Parameters:
other- map to clone from
-
WeightedMap
public WeightedMap()Default constructor. -
WeightedMap
public WeightedMap(int initialCapacity) Initial expected capacity of the map, not maximum size.
-
-
Method Details
-
add
Adds an element and it's weight. -
get
Gets the element's weight. -
pick
-
size
public int size()Size of the map. -
elements
-
isImmutable
public boolean isImmutable()Checks if the map is immutable. -
forEach
-
toString
-