seq

package
v0.0.0-...-884f274 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package seq provides facilities for creating and managing sequences of data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func[I any] func() (I, bool)

Func wraps a function with the signature func(I,bool), implementing the Sequence[I] interface.

func (Func[I]) Next

func (f Func[I]) Next() (I, bool)

Next implements the Sequence[I] interface.

type IntsAscending

type IntsAscending[I ints] struct {
	Min, Max I
	// contains filtered or unexported fields
}

IntsAscending is a sequence of ascending integers in the range [Min,Max).

func (*IntsAscending[I]) Next

func (s *IntsAscending[I]) Next() (I, bool)

Next implements Sequence.

type IntsDescending

type IntsDescending[I ints] struct {
	Min, Max I
	// contains filtered or unexported fields
}

IntsDescending constructs a sequence of ascending integers in the range [min,max).

func (*IntsDescending[I]) Next

func (s *IntsDescending[I]) Next() (I, bool)

Next implements Sequence.

type Sequence

type Sequence[I any] interface {
	// Next returns the next item in the sequence. If the sequence is beginning,
	// including for the first time, Next returns restarted = true.
	Next() (next I, restarted bool)
}

A Sequence represents an ordered sequence of elements.

func RandomFilter

func RandomFilter[I any](inner Sequence[I], rng *rand.Rand, p float64) Sequence[I]

RandomFilter returns a sequence formed by randomly filtering inner, using randomness from rng, returning any individual element with probability p.

type Slice

type Slice[I any] struct {
	Elems []I
	// contains filtered or unexported fields
}

Slice is a sequence that pulls from a slice.

func (*Slice[I]) Next

func (s *Slice[I]) Next() (I, bool)

Next implements Sequence.

Jump to

Keyboard shortcuts

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