public class WeightRandomMap<T> extends TreeMap<Double,T> implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
WeightRandomMap.WeightObject<T>
带有权重的对象包装
|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
WeightRandomMap() |
WeightRandomMap(Collection<WeightRandomMap.WeightObject<T>> weights) |
WeightRandomMap(Map<T,Double> weights) |
| Modifier and Type | Method and Description |
|---|---|
static <T> WeightRandomMap<T> |
create() |
T |
next()
下一个随机对象
|
T |
put(Double weight,
T value) |
void |
put(T o,
double weight)
增加对象
|
void |
put(WeightRandomMap.WeightObject<T> o)
增加对象权重
|
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, putAll, remove, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, valuesequals, hashCode, isEmpty, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, removepublic WeightRandomMap()
public WeightRandomMap(Collection<WeightRandomMap.WeightObject<T>> weights)
public static <T> WeightRandomMap<T> create()
public void put(T o, double weight)
o - 对象weight - 权重public void put(WeightRandomMap.WeightObject<T> o)
o - 权重对象public T next()
Copyright © 2025. All rights reserved.