E
- 元素类型public class WeightListRandom<E> extends Object implements Serializable
Constructor and Description |
---|
WeightListRandom()
构造
|
WeightListRandom(int poolSize)
构造
|
Modifier and Type | Method and Description |
---|---|
void |
add(E e,
double weight)
添加元素
|
boolean |
isEmpty()
判断随机池是否为空
|
E |
next()
随机出一个元素
|
E |
randomByWeight(double weight)
按照给定的总权重随机出一个元素
|
boolean |
remove(E e)
移除元素
|
public WeightListRandom()
public WeightListRandom(int poolSize)
poolSize
- 容量public void add(E e, double weight)
e
- 元素weight
- 权重public boolean remove(E e)
e
- 元素public E next()
public E randomByWeight(double weight)
weight
- 总权重public boolean isEmpty()
Copyright © 2024. All rights reserved.