Registry / utility / mroth-weightedrand

mroth-weightedrand

JSON →
library1.0.0gogounverified

Package weightedrand provides a performant data structure for weighted random selection from a list of elements.

go get github.com/mroth/weightedrand
INSTALL
IMPORT
SIG · MROTH-WEIGHTEDRAND
M
mroth-weightedrand
utilitygov1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

weightedrand
github.com/mroth/weightedrand

Creates a weighted chooser and picks a random item.

package main import ( "fmt" "github.com/mroth/weightedrand" ) func main() { choices := []weightedrand.Choice{ {Item: "A", Weight: 5}, {Item: "B", Weight: 1}, } picker, _ := weightedrand.NewChooser(choices...) result := picker.Pick().(string) fmt.Println(result) }
Debug
Known issues

No known issues recorded.

Upgrade
Version history
1.0.0latest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
mroth-weightedrand — go get mroth-weightedrand · libregistry