Documentation ¶
Overview ¶
Package giter provides the abstraction of map, slice or channel types into iterators for common processing
Usually we can use gslice for slices, gmap for maps and gchan for channels.
In most scenarios, we DO NOT need to use the giter package directly
Index ¶
- func AllFromSeq[T any](seq Seq[T], f func(T) bool) bool
- func AnyFromSeq[T any](seq Seq[T], f func(T) bool) bool
- func At[T any](seq Seq[T], index int) optional.O[T]
- func AvgByFromSeq[V any, T constraints.Number](seq Seq[V], f func(V) T) float64
- func AvgFromSeq[T constraints.Number](seq Seq[T]) float64
- func Contains[T comparable](seq Seq[T], in T) bool
- func ContainsAll[T comparable](seq Seq[T], in []T) bool
- func ContainsAny[T comparable](seq Seq[T], in []T) bool
- func ContainsBy[T any](seq Seq[T], f func(T) bool) bool
- func Count[T any](seq Seq[T]) int
- func Find[T any](seq Seq[T], f func(T) bool) (val T, found bool)
- func FindO[T any](seq Seq[T], f func(T) bool) optional.O[T]
- func ForEach[T any](seq Seq[T], f func(T) bool)
- func ForEachIdx[T any](seq Seq[T], f func(idx int, v T) bool)
- func Head[T any](seq Seq[T]) (v T, hasOne bool)
- func HeadO[T any](seq Seq[T]) optional.O[T]
- func Join[T ~string](seq Seq[T], sep T) T
- func Max[T constraints.Ordered](seq Seq[T]) (r optional.O[T])
- func MaxBy[T constraints.Ordered](seq Seq[T], less func(T, T) bool) (r optional.O[T])
- func Min[T constraints.Ordered](seq Seq[T]) (r optional.O[T])
- func MinBy[T constraints.Ordered](seq Seq[T], less func(T, T) bool) (r optional.O[T])
- func PullOut[T any](seq Seq[T], n int) (out []T)
- func ToSlice[T any](seq Seq[T]) (out []T)
- type Seq
- func Concat[T any](seqs ...Seq[T]) Seq[T]
- func Filter[T any](seq Seq[T], f func(T) bool) Seq[T]
- func FromSlice[T any](in []T) Seq[T]
- func FromSliceReverse[T any, Slice ~[]T](in Slice) Seq[T]
- func FromSliceShuffle[T any](in []T) Seq[T]
- func Limit[T any](seq Seq[T], n int) Seq[T]
- func Repeat[T any](seq Seq[T], count int) Seq[T]
- func Replace[T comparable](seq Seq[T], from, to T, n int) Seq[T]
- func ReplaceAll[T comparable](seq Seq[T], from, to T) Seq[T]
- func Reverse[T any](seq Seq[T]) Seq[T]
- func Skip[T any](seq Seq[T], n int) Seq[T]
- type Seq2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllFromSeq ¶
AllFromSeq return true if all elements from seq satisfy the condition evaluated by f.
func AnyFromSeq ¶
AnyFromSeq return true if any elements from seq satisfy the condition evaluated by f.
func AvgByFromSeq ¶
func AvgByFromSeq[V any, T constraints.Number](seq Seq[V], f func(V) T) float64
AvgByFromSeq return the average value of all elements from seq, evaluated by f.
func AvgFromSeq ¶
func AvgFromSeq[T constraints.Number](seq Seq[T]) float64
AvgFromSeq return the average value of all elements from seq.
func Contains ¶
func Contains[T comparable](seq Seq[T], in T) bool
Contains return true if v is in seq.
func ContainsAll ¶
func ContainsAll[T comparable](seq Seq[T], in []T) bool
ContainsAll return true if all elements from seq is in vs.
func ContainsAny ¶
func ContainsAny[T comparable](seq Seq[T], in []T) bool
ContainsAny return true if any element from seq is in vs.
func ContainsBy ¶
ContainsBy return true if any element from seq satisfies the condition evaluated by f.
func Find ¶
Find return the first element from seq that satisfies the condition evaluated by f with a boolean representing whether it exists.
func ForEachIdx ¶
ForEachIdx execute f for each element in seq with its index.
func Head ¶
Head return the first element from seq with a boolean representing whether it is at least one element in seq.
func Max ¶
func Max[T constraints.Ordered](seq Seq[T]) (r optional.O[T])
Max returns the maximum element in seq.
func Min ¶
func Min[T constraints.Ordered](seq Seq[T]) (r optional.O[T])
Min return the minimum element in seq.
Types ¶
type Seq ¶
Seq is a sequence of elements provided by an iterator-like function. We made an Alias Seq to iter.Seq for providing a compatible interface in lower go versions.
func FromSliceReverse ¶ added in v0.1.4
func FromSliceShuffle ¶ added in v0.1.5
FromSliceShuffle return a seq that shuffle the elements in the input slice.
func Replace ¶ added in v0.1.4
func Replace[T comparable](seq Seq[T], from, to T, n int) Seq[T]
Replace return a seq that replace from -> to
func ReplaceAll ¶ added in v0.1.4
func ReplaceAll[T comparable](seq Seq[T], from, to T) Seq[T]
ReplaceAll return a seq that replace all from -> to