Documentation
¶
Overview ¶
LINQ
Index ¶
- func Aggregate[S, T any](src Enumerator[S], seed T, fn func(acc T, v S) (T, error)) (T, error)
- func All[T any](src Enumerator[T], pred func(v T) (bool, error)) (bool, error)
- func Any[T any](src Enumerator[T], pred func(v T) (bool, error)) (bool, error)
- func Average[T Real](src Enumerator[T]) (float64, error)
- func AverageFunc[T any, U Real](src Enumerator[T], selector func(T) (U, error)) (float64, error)
- func Contains[T comparable](src Enumerator[T], val T) (bool, error)
- func ContainsFunc[T any](src Enumerator[T], val T, equals func(T, T) (bool, error)) (bool, error)
- func Count[T any](src Enumerator[T], pred func(T) (bool, error)) (int, error)
- func ElementAt[T any](src Enumerator[T], n int) (def T, err error)
- func ElementAtOrDefault[T any](src Enumerator[T], n int) (T, error)
- func First[T any](src Enumerator[T], pred func(T) (bool, error)) (def T, _ error)
- func FirstOrDefault[T any](src Enumerator[T], pred func(T) (bool, error), defaultValue T) (T, error)
- func ForEach[T any](e Enumerator[T], f func(T) error) error
- func Last[T any](src Enumerator[T], pred func(T) (bool, error)) (def T, _ error)
- func LastOrDefault[T any](src Enumerator[T], pred func(T) (bool, error), defaultValue T) (T, error)
- func Max[T constraints.Ordered](src Enumerator[T]) (def T, _ error)
- func MaxBy[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) (def T, _ error)
- func MaxByFunc[T any](src Enumerator[T], greater func(a, b T) (bool, error)) (def T, _ error)
- func Min[T constraints.Ordered](src Enumerator[T]) (def T, _ error)
- func MinBy[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) (def T, _ error)
- func MinByFunc[T any](src Enumerator[T], less func(a, b T) (bool, error)) (def T, _ error)
- func Single[T any](src Enumerator[T], pred func(T) (bool, error)) (def T, _ error)
- func SingleOrDefault[T any](src Enumerator[T], pred func(T) (bool, error), defaultValue T) (def T, _ error)
- func Sum[T constraints.Integer](src Enumerator[T]) (int, error)
- func SumByFunc[T any, K constraints.Integer](src Enumerator[T], selector func(v T) (K, error)) (int, error)
- func SumByFuncf[T any, K constraints.Float](src Enumerator[T], selector func(v T) (K, error)) (float64, error)
- func Sumf[T constraints.Float](src Enumerator[T]) (float64, error)
- func ToMap[K comparable, V any](src Enumerator[KeyValue[K, V]]) (map[K]V, error)
- func ToMapFunc[T any, K comparable, V any](src Enumerator[T], selector func(T) (K, V, error)) (map[K]V, error)
- func ToSlice[T any](src Enumerator[T]) ([]T, error)
- type Enumerator
- func Chunk[T any](src Enumerator[T], size int) Enumerator[[]T]
- func Concat[T any](first, second Enumerator[T]) Enumerator[T]
- func DefaultIfEmpty[T any](src Enumerator[T], defaultValue T) Enumerator[T]
- func Distinct[T any](src Enumerator[T], equals func(T, T) (bool, error), ...) Enumerator[T]
- func DistinctBy[T any, K comparable](src Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
- func Empty[T any]() Enumerator[T]
- func Except[T any](first, second Enumerator[T], equals func(T, T) (bool, error), ...) Enumerator[T]
- func ExceptBy[T any, K comparable](first, second Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
- func FromMap[T ~map[K]V, K comparable, V any](m T) Enumerator[KeyValue[K, V]]
- func FromSlice[S ~[]T, T any](s S) Enumerator[T]
- func GroupBy[T any, K comparable](src Enumerator[T], keySelector func(T) (K, error)) Enumerator[Grouping[K, T]]
- func GroupJoin[S1, S2, T any, K comparable](outer Enumerator[S1], inner Enumerator[S2], ...) Enumerator[T]
- func Intersect[T any](first, second Enumerator[T], equals func(T, T) (bool, error), ...) Enumerator[T]
- func IntersectBy[T any, K comparable](first, second Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
- func Join[S1, S2, T any, K comparable](outer Enumerator[S1], inner Enumerator[S2], ...) Enumerator[T]
- func OrderByFunc[T any](src Enumerator[T], less func(a, b T) bool) Enumerator[T]
- func Range(start, count int) Enumerator[int]
- func Repeat[T any](v T, n int) Enumerator[T]
- func Reverse[T any](src Enumerator[T]) Enumerator[T]
- func Select[S, T any](src Enumerator[S], selector func(v S) (T, error)) Enumerator[T]
- func SelectMany[S, C, T any](src Enumerator[S], collectionSelector func(S) (Enumerator[C], error), ...) Enumerator[T]
- func Skip[T any](src Enumerator[T], count int) Enumerator[T]
- func SkipLast[T any](src Enumerator[T], count int) Enumerator[T]
- func SkipWhile[T any](src Enumerator[T], pred func(T) (bool, error)) Enumerator[T]
- func Take[T any](src Enumerator[T], count int) Enumerator[T]
- func TakeLast[T any](src Enumerator[T], count int) Enumerator[T]
- func TakeWhile[T any](src Enumerator[T], pred func(T) (bool, error)) Enumerator[T]
- func Union[T any](first, second Enumerator[T], equals func(T, T) (bool, error), ...) Enumerator[T]
- func UnionBy[T any, K comparable](first, second Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
- func Where[T any](src Enumerator[T], pred func(v T) (bool, error)) Enumerator[T]
- func Zip[S1, S2, T any](first Enumerator[S1], second Enumerator[S2], ...) Enumerator[T]
- type Error
- type Grouping
- type KeyValue
- type OrderedEnumerator
- func OrderBy[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
- func OrderByDescending[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
- func ThenBy[T any, K constraints.Ordered](src *OrderedEnumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
- func ThenByDescending[T any, K constraints.Ordered](src *OrderedEnumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
- type Real
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Aggregate ¶
func Aggregate[S, T any](src Enumerator[S], seed T, fn func(acc T, v S) (T, error)) (T, error)
Aggregate applies an accumulator function over a sequence.
func Average ¶
func Average[T Real](src Enumerator[T]) (float64, error)
Average computes the average of a sequence of numeric (real number) values.
func AverageFunc ¶
AverageFunc computes the average of a sequence of numeric values that are obtained by invoking a transform function on each element of the input sequence.
func Contains ¶
func Contains[T comparable](src Enumerator[T], val T) (bool, error)
Contains cetermines whether a sequence contains a specified element.
func ContainsFunc ¶
ContainsFunc determines whether a sequence contains a specified element by using a specified comparer function.
func Count ¶
Count returns a number that represents how many elements in the specified sequence satisfy a condition.
func ElementAt ¶
func ElementAt[T any](src Enumerator[T], n int) (def T, err error)
ElementAt returns the element at a specified index in a sequence.
func ElementAtOrDefault ¶
func ElementAtOrDefault[T any](src Enumerator[T], n int) (T, error)
ElementAtOrDefault returns the element at a specified index in a sequence or a default value if the index is out of range.
func First ¶
func First[T any](src Enumerator[T], pred func(T) (bool, error)) (def T, _ error)
First returns the first element in a sequence that satisfies a specified condition.
func FirstOrDefault ¶
func FirstOrDefault[T any](src Enumerator[T], pred func(T) (bool, error), defaultValue T) (T, error)
FirstOrDefault returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
func ForEach ¶
func ForEach[T any](e Enumerator[T], f func(T) error) error
ForEach performs the specified action on each element of the specified enumerator.
func Last ¶
func Last[T any](src Enumerator[T], pred func(T) (bool, error)) (def T, _ error)
Last returns the last element of a sequence that satisfies a specified condition.
func LastOrDefault ¶
func LastOrDefault[T any](src Enumerator[T], pred func(T) (bool, error), defaultValue T) (T, error)
LastOrDefault returns the last element of a sequence that satisfies a condition, or a specified default value if no such element is found.
func Max ¶
func Max[T constraints.Ordered](src Enumerator[T]) (def T, _ error)
Maxby returns the maximum value in a sequence of values.
func MaxBy ¶
func MaxBy[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) (def T, _ error)
MaxBy returns the maximum value in a generic sequence according to a specified key selector function.
func MaxByFunc ¶
func MaxByFunc[T any](src Enumerator[T], greater func(a, b T) (bool, error)) (def T, _ error)
MaxByFunc returns the maximum value in a generic sequence according to a comparer function.
func Min ¶
func Min[T constraints.Ordered](src Enumerator[T]) (def T, _ error)
Min returns the minimum value in a sequence of values.
func MinBy ¶
func MinBy[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) (def T, _ error)
MinBy returns the minimum value in a generic sequence according to a specified key selector function.
func MinByFunc ¶
func MinByFunc[T any](src Enumerator[T], less func(a, b T) (bool, error)) (def T, _ error)
MinByFunc returns the minimum value in a generic sequence according to a comparer function.
func Single ¶
func Single[T any](src Enumerator[T], pred func(T) (bool, error)) (def T, _ error)
Single returns the only element of a sequence that satisfies a specified condition, and return an error InvalidOperation if more than one such element exists.
func SingleOrDefault ¶
func SingleOrDefault[T any](src Enumerator[T], pred func(T) (bool, error), defaultValue T) (def T, _ error)
SingleOrDefault returns the only element of a sequence that satisfies a specified condition, or a specified default value if no such element exists; this function returns an error InvalidOperation if more than one element satisfies the condition.
func Sum ¶
func Sum[T constraints.Integer](src Enumerator[T]) (int, error)
Sum calculates the sum of a integer sequence.
func SumByFunc ¶
func SumByFunc[T any, K constraints.Integer](src Enumerator[T], selector func(v T) (K, error)) (int, error)
SumByFunc computes the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
func SumByFuncf ¶
func SumByFuncf[T any, K constraints.Float](src Enumerator[T], selector func(v T) (K, error)) (float64, error)
SumByFuncf computes the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence.
func Sumf ¶
func Sumf[T constraints.Float](src Enumerator[T]) (float64, error)
Sumf calculates the sum of a floating number sequence.
func ToMap ¶
func ToMap[K comparable, V any](src Enumerator[KeyValue[K, V]]) (map[K]V, error)
ToMap creates a map[K]V from an Enumerator[T]. T must be a type KeyValue[K, V].
func ToMapFunc ¶
func ToMapFunc[T any, K comparable, V any](src Enumerator[T], selector func(T) (K, V, error)) (map[K]V, error)
ToMapFunc creates a map[K]V from an Enumerator[T] according to specified key-value selector function.
func ToSlice ¶
func ToSlice[T any](src Enumerator[T]) ([]T, error)
ToSlice creates a slice from an Enumerator[T]
Types ¶
type Enumerator ¶
type Enumerator[T any] interface { // Next returns a next element of this collection. // It returns EOC as an `error` when it reaches the end of the collection. Next() (T, error) }
Enumerator[T] is a queryable collection
func Chunk ¶
func Chunk[T any](src Enumerator[T], size int) Enumerator[[]T]
Chunk splits the elements of a sequence into chunks of size at most `size`.
func Concat ¶
func Concat[T any](first, second Enumerator[T]) Enumerator[T]
Concat concatenates two sequences.
func DefaultIfEmpty ¶
func DefaultIfEmpty[T any](src Enumerator[T], defaultValue T) Enumerator[T]
DefaultIfEmpty returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
func Distinct ¶
func Distinct[T any](src Enumerator[T], equals func(T, T) (bool, error), getHashCode func(T) (int, error)) Enumerator[T]
Distinct returns distinct elements from a sequence by using the specified comparer functions.
func DistinctBy ¶
func DistinctBy[T any, K comparable](src Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
DistinctBy returns distinct elements from a sequence according to a specified key selector function.
func Empty ¶
func Empty[T any]() Enumerator[T]
Empty returns an empty IEnumerable<T> that has the specified type argument.
func Except ¶
func Except[T any](first, second Enumerator[T], equals func(T, T) (bool, error), getHashCode func(T) (int, error)) Enumerator[T]
Except produces the set difference of two sequences by using the specified comparer functions.
func ExceptBy ¶
func ExceptBy[T any, K comparable](first, second Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
ExceptBy produces the set difference of two sequences according to a specified key selector function.
func FromMap ¶
func FromMap[T ~map[K]V, K comparable, V any](m T) Enumerator[KeyValue[K, V]]
FromMap generates an Enumerator[T] from a map.
func FromSlice ¶
func FromSlice[S ~[]T, T any](s S) Enumerator[T]
FromSlice generates an Enumerator[T] from a slice.
func GroupBy ¶
func GroupBy[T any, K comparable](src Enumerator[T], keySelector func(T) (K, error)) Enumerator[Grouping[K, T]]
GroupBy groups the elements of a sequence according to a specified key selector function.
func GroupJoin ¶
func GroupJoin[S1, S2, T any, K comparable]( outer Enumerator[S1], inner Enumerator[S2], outerKeySelector func(S1) (K, error), innerKeySelector func(S2) (K, error), resultSelector func(S1, Enumerator[S2]) (T, error), ) Enumerator[T]
GroupJoin correlates the elements of two sequences based on equality of keys and groups the results.
func Intersect ¶
func Intersect[T any](first, second Enumerator[T], equals func(T, T) (bool, error), getHashCode func(T) (int, error)) Enumerator[T]
Intersect produces the set intersection of two sequences by using the specified comparer functions.
func IntersectBy ¶
func IntersectBy[T any, K comparable](first, second Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
IntersectBy produces the set intersection of two sequences according to a specified key selector function.
func Join ¶
func Join[S1, S2, T any, K comparable]( outer Enumerator[S1], inner Enumerator[S2], outerKeySelector func(S1) (K, error), innerKeySelector func(S2) (K, error), resultSelector func(S1, S2) (T, error), ) Enumerator[T]
Join correlates the elements of two sequences based on matching keys.
func OrderByFunc ¶
func OrderByFunc[T any](src Enumerator[T], less func(a, b T) bool) Enumerator[T]
OrderByFunc sorts the elements of a sequence by the provided less function.
func Range ¶
func Range(start, count int) Enumerator[int]
Range generates a sequence of integral numbers within a specified range.
func Repeat ¶
func Repeat[T any](v T, n int) Enumerator[T]
Repeat generates a sequence that contains one repeated value.
func Reverse ¶
func Reverse[T any](src Enumerator[T]) Enumerator[T]
Reverse inverts the order of the elements in a sequence.
func Select ¶
func Select[S, T any](src Enumerator[S], selector func(v S) (T, error)) Enumerator[T]
Select projects each element of a sequence into a new form.
func SelectMany ¶
func SelectMany[S, C, T any](src Enumerator[S], collectionSelector func(S) (Enumerator[C], error), resultSelector func(C) (T, error)) Enumerator[T]
SelectMany projects each element of a sequence to an Enumerable[T] and flattens the resulting sequences into one sequence.
func Skip ¶
func Skip[T any](src Enumerator[T], count int) Enumerator[T]
Skip bypasses a specified number of elements in a sequence and then returns the remaining elements.
func SkipLast ¶
func SkipLast[T any](src Enumerator[T], count int) Enumerator[T]
SkipLast returns a new enumerable collection that contains the elements from source with the last count elements of the source collection omitted.
func SkipWhile ¶
func SkipWhile[T any](src Enumerator[T], pred func(T) (bool, error)) Enumerator[T]
SkipWhile bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.
func Take ¶
func Take[T any](src Enumerator[T], count int) Enumerator[T]
Take returns a specified number of contiguous elements from the start of a sequence.
func TakeLast ¶
func TakeLast[T any](src Enumerator[T], count int) Enumerator[T]
TakeLast returns a new enumerable collection that contains the last count elements from source.
func TakeWhile ¶
func TakeWhile[T any](src Enumerator[T], pred func(T) (bool, error)) Enumerator[T]
TakeWhile returns elements from a sequence as long as a specified condition is true, and then skips the remaining elements.
func Union ¶
func Union[T any](first, second Enumerator[T], equals func(T, T) (bool, error), getHashCode func(T) (int, error)) Enumerator[T]
Union produces the set union of two sequences by using the specified comparer functions.
func UnionBy ¶
func UnionBy[T any, K comparable](first, second Enumerator[T], keySelector func(v T) (K, error)) Enumerator[T]
UnionBy produces the set union of two sequences according to a specified key selector function.
func Where ¶
func Where[T any](src Enumerator[T], pred func(v T) (bool, error)) Enumerator[T]
Where filters a sequence of values based on a predicate.
func Zip ¶
func Zip[S1, S2, T any](first Enumerator[S1], second Enumerator[S2], resultSelector func(S1, S2) (T, error)) Enumerator[T]
Zip applies a specified function to the corresponding elements of two sequences, producing a sequence of the results.
type Grouping ¶
type Grouping[K comparable, T any] interface { Enumerator[T] Key() K }
Grouping represents a collection of objects that have a common key.
type KeyValue ¶
type KeyValue[K comparable, V any] struct { Key K Value V }
KeyValue pair as an element of map[K]V
type OrderedEnumerator ¶
type OrderedEnumerator[T any] struct { // contains filtered or unexported fields }
OrderedEnumerator is an implementation of Enumerator[T] which produces a sorted sequence.
func OrderBy ¶
func OrderBy[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
OrderBy sorts the elements of a sequence in ascending order according to a key.
func OrderByDescending ¶
func OrderByDescending[T any, K constraints.Ordered](src Enumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
OrderByDescending sorts the elements of a sequence in descending order according to a key.
func ThenBy ¶
func ThenBy[T any, K constraints.Ordered](src *OrderedEnumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
ThenBy performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
func ThenByDescending ¶
func ThenByDescending[T any, K constraints.Ordered](src *OrderedEnumerator[T], keySelector func(T) (K, error)) *OrderedEnumerator[T]
ThenByDescending performs a subsequent ordering of the elements in a sequence in descending order, according to a key.
func (*OrderedEnumerator[T]) Next ¶
func (e *OrderedEnumerator[T]) Next() (def T, _ error)
type Real ¶
type Real interface { constraints.Integer | constraints.Float }
Source Files
¶
- aggregate.go
- all.go
- any.go
- average.go
- chunk.go
- concat.go
- contains.go
- count.go
- defaultifempty.go
- distinct.go
- elementat.go
- empty.go
- except.go
- first.go
- foreach.go
- groupby.go
- groupjoin.go
- intersect.go
- join.go
- last.go
- linq.go
- map.go
- max.go
- min.go
- orderby.go
- orderbyfunc.go
- range.go
- repeat.go
- reverse.go
- select.go
- selectmany.go
- single.go
- skip.go
- slice.go
- sum.go
- take.go
- union.go
- util.go
- where.go
- zip.go