Registry / utility / mroth-weightedrand-v2

mroth-weightedrand-v2

JSON →
library2.1.0gogounverified

A performant data structure and algorithm for weighted random selection.

go get github.com/mroth/weightedrand/v2
INSTALL
IMPORT
SIG · MROTH-WEIGHTEDRAND
M
mroth-weightedrand-v2
utilitygov2.1.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/v2

Creates a weighted random picker and selects an item.

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

No known issues recorded.

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

No dependency data recorded yet.

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