rx

package module
v0.0.0-...-6deb74b Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 3 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Count

func Count[T any](it Iter[T]) (int, error)

func Drain

func Drain[T any](it Iter[T]) error

func Fold

func Fold[T, S any](it Iter[T], fn func(S, T) (S, error), sum S) (S, error)

func ForEach

func ForEach[T any](it Iter[T], fn func(T) error) error

func ForEachN

func ForEachN[T any](it Iter[T], fn func(T, int) error) error

func Slice

func Slice[T any](it Iter[T]) ([]T, error)

func SortKeys

func SortKeys[K constraints.Ordered, V any](a, b Pair[K, V]) bool

func SortKeysDesc

func SortKeysDesc[K constraints.Ordered, V any](a, b Pair[K, V]) bool

func SortValues

func SortValues[K comparable, V constraints.Ordered](a, b Pair[K, V]) bool

func SortValuesDesc

func SortValuesDesc[K comparable, V constraints.Ordered](a, b Pair[K, V]) bool

func Sum

func Sum[N Number](it Iter[N]) (N, error)

func ToMap

func ToMap[K comparable, V any](it Iter[Pair[K, V]]) (map[K]V, error)

func UseSlice

func UseSlice[T any](it Iter[T], fn func(s []T) error) error

Types

type Done

type Done bool

func (Done) Done

func (d Done) Done() bool

type Doner

type Doner interface{ Done() bool }

type Forever

type Forever struct{}

func (Forever) Done

func (f Forever) Done() bool

type Iter

type Iter[T any] interface {
	Next() bool
	Value() T
	Close() error
}

func Any

func Any[T any](it Iter[T]) Iter[any]

func Counter

func Counter[N Number](start, step N) Iter[N]

func Distinct

func Distinct[T comparable](it Iter[T]) Iter[T]

func DistinctFunc

func DistinctFunc[T any](it Iter[T], fn func(T, T) bool) Iter[T]

func Error

func Error[T any](err error) Iter[T]

func Filter

func Filter[T any](it Iter[T], fn func(T) bool) Iter[T]

func FuncIter

func FuncIter[T any, S Doner](fn func(S) ([]T, S, error)) Iter[T]

func Log

func Log[T any](it Iter[T], prefix string) Iter[T]

func Map

func Map[T1, T2 any](it Iter[T1], fn func(T1) T2) Iter[T2]

func MapErr

func MapErr[T1, T2 any](it Iter[T1], fn func(T1) (T2, error)) Iter[T2]

func Partition

func Partition[T any](it Iter[T], fn func([]T) ([]T, [][]T)) Iter[[]T]

func PartitionAll

func PartitionAll[T any](it Iter[T], n int) Iter[[]T]

func PartitionLoops

func PartitionLoops[T comparable](it Iter[T]) Iter[[]T]

func Pluck

func Pluck[K, V any](it Iter[V], keyFn func(V) K) Iter[Pair[K, V]]

func PluckErr

func PluckErr[K, V any](it Iter[V], keyFn func(V) (K, error)) Iter[Pair[K, V]]

func Random

func Random[N constraints.Integer](min, max N) Iter[N]

func Range

func Range[N Number](start, step N, count int) Iter[N]

func SelectKeys

func SelectKeys[K comparable, V any](m map[K]V, keys Iter[K]) Iter[V]

func Skip

func Skip[T any](it Iter[T], n int) Iter[T]

func SliceIter

func SliceIter[T any](data ...T) Iter[T]

func Take

func Take[T any](it Iter[T], n int) Iter[T]

func Transform

func Transform[T1, T2 any](it Iter[T1], fn func(T1) ([]T2, Done, error)) Iter[T2]

func Unfold

func Unfold[T any, S Doner](s S, fn func(S) ([]T, S, error)) Iter[T]

func UnfoldLens

func UnfoldLens[T any, S Doner](l Lens[S], fn func(S) ([]T, S, error)) Iter[T]

func Unique

func Unique[T comparable](it Iter[T]) Iter[T]

func UniqueFunc

func UniqueFunc[T any, K comparable](it Iter[T], fn func(T) K) Iter[T]

func WithClose

func WithClose[T any](it Iter[T], fn func() error) Iter[T]

type Lens

type Lens[T any] interface {
	Get() (T, error)
	Set(T) error
}

type Maybe

type Maybe[T any] struct {
	// contains filtered or unexported fields
}

func First

func First[T any](it Iter[T]) (Maybe[T], error)

func Just

func Just[T any](v T) Maybe[T]

func None

func None[T any]() Maybe[T]

func (Maybe[_]) Ok

func (m Maybe[_]) Ok() bool

func (Maybe[T]) Value

func (m Maybe[T]) Value() T

type Number

type Number interface {
	constraints.Integer | constraints.Float | constraints.Complex
}

type Pair

type Pair[K, V any] struct {
	// contains filtered or unexported fields
}

func NewPair

func NewPair[K, V any](key K, value V) Pair[K, V]

func Pairs

func Pairs[K comparable, V any](m map[K]V) []Pair[K, V]

func (Pair[K, _]) Key

func (p Pair[K, _]) Key() K

func (Pair[_, V]) Value

func (p Pair[_, V]) Value() V

type Slicer

type Slicer[T any] interface {
	Slice() []T
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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