Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Range ¶
Range returns a specific slice for range iteration on another slice.
batch, entities := 100, entity.Fetch() // []entity.Model for step, end := range sequence.Range(len(entities), batch) { service.Process(entities[batch*step:end]) }
func Simple ¶
func Simple(size int) []struct{}
Simple returns an empty slice with the specified size.
for range Simple(5) { // do something five times }
Read the https://dave.cheney.net/2014/03/25/the-empty-struct and the https://github.com/bradfitz/iter.
Types ¶
type Reducer ¶
type Reducer interface { // Average returns an average value of the sequence. Average() float64 // Length returns the sequence length. Length() int // Maximum returns a maximum value of the sequence. Maximum() int // Median returns a median value of the sequence. Median() float64 // Minimum returns a minimum value of the sequence. Minimum() int // Sum returns a sum of the sequence. Sum() int }
Reducer defines behavior of a generic reducer above a numeric sequence.
func ReduceInts ¶
ReduceInts wraps sequence of integers to perform aggregate operations above it.
ticket, err := semaphore.Acquire(ctx, sequence.ReduceInts(places...).Sum()) if err != nil { ... } defer semaphore.Release(ticket)
Click to show internal directories.
Click to hide internal directories.