weightediterator

package module
v0.0.0-...-c211bc6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 6 Imported by: 0

README

Weighted iterator of iterators

Weighted Iterator of iterators (pseudorandom, converging to its full length) + configuration format for managers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Iterators []IteratorConfig `konaf:"iterators"`
}

func LoadFromBytes

func LoadFromBytes(rawConfig []byte) (Config, error)

func LoadFromFile

func LoadFromFile(filePath string) (Config, error)

func (Config) Validate

func (c Config) Validate() error

type Iterator

type Iterator interface {
	HasNext() bool
	Next() int
	GetWeight() int
}

type IteratorConfig

type IteratorConfig struct {
	Weight   int
	Sequence []int
}

func (IteratorConfig) Validate

func (ic IteratorConfig) Validate() error

type WeightedIterator

type WeightedIterator struct {
	// contains filtered or unexported fields
}

func NewWeightedIterator

func NewWeightedIterator(config []IteratorConfig) *WeightedIterator

NewWeightedIterator returns the weighted iterator of iterators.

func (*WeightedIterator) HasNext

func (rg *WeightedIterator) HasNext() bool

HasNext returns true if the next element exists. HasNext is not thread-safe.

func (*WeightedIterator) Next

func (rg *WeightedIterator) Next() int

Next returns the next element. Next is not thread-safe.

Jump to

Keyboard shortcuts

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