lottery

package
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lottery

type Lottery[T comparable] struct {
	// contains filtered or unexported fields
}

func NewLottery

func NewLottery[T comparable]() *Lottery[T]

NewLottery create a new lottery pool

func (*Lottery[T]) AddItem

func (l *Lottery[T]) AddItem(ID T, weight int)

AddItem add an item for Lottery draw

func (*Lottery[T]) Draw

func (l *Lottery[T]) Draw(random ...Roller) T

Draw draw a lottery

func (*Lottery[T]) Len

func (l *Lottery[T]) Len() int

Len get amount of items

func (*Lottery[T]) Weight

func (l *Lottery[T]) Weight() int

Weight get total weight of items

type Roller

type Roller func(int) int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL