Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecQueue ¶
type ExecQueue struct {
// contains filtered or unexported fields
}
ExecQueue implements a queue that executes function calls in a single thread, in the same order as they have been queued.
func NewExecQueue ¶
NewExecQueue creates a new execution Queue.
func (*ExecQueue) CanQueue ¶
CanQueue returns true if more function calls can be added to the execution Queue.
type WeightedRandomSelect ¶
type WeightedRandomSelect struct {
// contains filtered or unexported fields
}
WeightedRandomSelect is capable of weighted random selection from a set of items
func NewWeightedRandomSelect ¶
func NewWeightedRandomSelect() *WeightedRandomSelect
NewWeightedRandomSelect returns a new WeightedRandomSelect structure
func (*WeightedRandomSelect) Choose ¶
func (w *WeightedRandomSelect) Choose() wrsItem
Choose randomly selects an item from the set, with a chance proportional to its current weight. If the weight of the chosen element has been decreased since the last stored value, returns it with a newWeight/oldWeight chance, otherwise just updates its weight and selects another one
func (*WeightedRandomSelect) Remove ¶
func (w *WeightedRandomSelect) Remove(item wrsItem)
Remove removes an item from the set
func (*WeightedRandomSelect) Update ¶
func (w *WeightedRandomSelect) Update(item wrsItem)
Update updates an item's weight, adds it if it was non-existent or removes it if the new weight is zero. Note that explicitly updating decreasing weights is not necessary.