Documentation ¶
Overview ¶
Package linq defines a set of useful linq to be used with type parameters.
Index ¶
- Constants
- func Aggregate[T any](source []T, initial T, f func(agg, now T) T) T
- func All[T any](source []T, predicator func(x T) bool) bool
- func Any[T any](source []T, predicator func(x T) bool) bool
- func Average[T Number](source []T) float64
- func Chunk[T any](source []T, size int) [][]T
- func Contains[T comparable](source []T, key T) bool
- func Count[T any](source []T, f func(x T) bool) int
- func DefaultIfEmpty[T any](source []T) []T
- func Distinct[T comparable](source []T) []T
- func DistinctBy[T any, R comparable](source []T, f func(x T) R) []T
- func Except[T comparable](l []T, r []T) []T
- func ExceptBy[T any, R comparable](source []T, keys []R, f func(x T) R) []T
- func First[T any](source []T, f func(x T) bool) T
- func FirstOrDefault[T any](source []T, pred func(x T) bool) T
- func GroupBy[T any, R comparable, S any](source []T, keyGen func(x T) R, groupSelector func([]T) S) map[R]S
- func GroupJoin[T, R, S any, K comparable](outter []T, inner []R, outterKeySelector func(T) K, innerKeySelector func(R) K, ...) []S
- func Intersect[T comparable](l, r []T) []T
- func IntersectBy[T any, K comparable](source []T, keys []K, keyGen func(x T) K) []T
- func Keys[T comparable, R any](source map[T]R) []T
- func Last[T comparable](source []T, predictor func(x T) bool) T
- func LastOrDefault[T comparable](source []T, predictor func(x T) bool) T
- func Max[T constraints.Ordered](source []T) T
- func MaxBy[T any, K constraints.Ordered](source []T, com func(x T) K) T
- func Min[T constraints.Ordered](source []T) T
- func MinBy[T any, K constraints.Ordered](source []T, com func(x T) K) T
- func OfType(source []any, expectType reflect.Type) []any
- func Order[T constraints.Ordered](source []T) []T
- func OrderBy[T constraints.Ordered](source []T, comparer func(l, r T) bool) []T
- func OrderByDescending[T constraints.Ordered](source []T, comparer func(l, r T) bool) []T
- func OrderDescending[T constraints.Ordered](source []T) []T
- func Prepend[T any](source []T, target ...T) []T
- func Repeat[T any](element T, times uint) []T
- func Reverse[T any](source []T) (target []T)
- func Select[T, R any](source []T, f func(x T) R) []R
- func SelectMany[T, R any](source []T, manySelector func(x T) []R) []R
- func Single[T comparable](source []T, pred func(x T) bool) T
- func SingleOrDefault[T comparable](source []T, pred func(x T) bool) T
- func Skip[T any](source []T, n int) []T
- func SkipLast[T any](source []T, count int) []T
- func SkipWhile[T any](source []T, skipCond func(x T) bool) []T
- func Sum[T Number](source []T) T
- func Take[T any](source []T, n int) []T
- func TakeLast[T any](source []T, n int) []T
- func TakeWhile[T any](source []T, takeCond func(x T) bool) []T
- func ToDictionary[T any, K comparable](source []T, keyGen func(x T) K) map[K]T
- func ToHashSet[T comparable](source []T) map[T]struct{}
- func ToLookUp[T, R any, K comparable](source []T, keySelector func(x T) K, elementSelector func(x T) R) map[K]R
- func Union[T comparable](left, right []T) []T
- func UnionBy[T any, K comparable](left, right []T, keySelector func(x T) K) []T
- func Values[T comparable, R any](source map[T]R) []R
- func Where[T any](source []T, f func(x T) bool) []T
- type Complex
- type Float
- type Integer
- type Number
- type Ordered
- type Pair
- type Signed
- type Unsigned
Constants ¶
const ( ElementNotFound string = "element not found" MultipleElementFound string = "multiple element found" EmptySource string = "empty source" InvalidParam string = "Invalid parameter" )
Variables ¶
This section is empty.
Functions ¶
func Contains ¶
func Contains[T comparable](source []T, key T) bool
func DefaultIfEmpty ¶
func DefaultIfEmpty[T any](source []T) []T
func Distinct ¶
func Distinct[T comparable](source []T) []T
func DistinctBy ¶
func DistinctBy[T any, R comparable](source []T, f func(x T) R) []T
func Except ¶
func Except[T comparable](l []T, r []T) []T
func ExceptBy ¶
func ExceptBy[T any, R comparable](source []T, keys []R, f func(x T) R) []T
func FirstOrDefault ¶
func GroupBy ¶
func GroupBy[T any, R comparable, S any](source []T, keyGen func(x T) R, groupSelector func([]T) S) map[R]S
func GroupJoin ¶
func GroupJoin[T, R, S any, K comparable]( outter []T, inner []R, outterKeySelector func(T) K, innerKeySelector func(R) K, resultSelector func(T, []R) S) []S
func Intersect ¶
func Intersect[T comparable](l, r []T) []T
func IntersectBy ¶
func IntersectBy[T any, K comparable](source []T, keys []K, keyGen func(x T) K) []T
func Keys ¶
func Keys[T comparable, R any](source map[T]R) []T
func Last ¶
func Last[T comparable](source []T, predictor func(x T) bool) T
func LastOrDefault ¶
func LastOrDefault[T comparable](source []T, predictor func(x T) bool) T
func Max ¶
func Max[T constraints.Ordered](source []T) T
func MaxBy ¶
func MaxBy[T any, K constraints.Ordered](source []T, com func(x T) K) T
func Min ¶
func Min[T constraints.Ordered](source []T) T
func MinBy ¶
func MinBy[T any, K constraints.Ordered](source []T, com func(x T) K) T
func Order ¶
func Order[T constraints.Ordered](source []T) []T
func OrderBy ¶
func OrderBy[T constraints.Ordered](source []T, comparer func(l, r T) bool) []T
func OrderByDescending ¶
func OrderByDescending[T constraints.Ordered](source []T, comparer func(l, r T) bool) []T
func OrderDescending ¶
func OrderDescending[T constraints.Ordered](source []T) []T
func SelectMany ¶
func SelectMany[T, R any](source []T, manySelector func(x T) []R) []R
func Single ¶
func Single[T comparable](source []T, pred func(x T) bool) T
func SingleOrDefault ¶
func SingleOrDefault[T comparable](source []T, pred func(x T) bool) T
func ToDictionary ¶
func ToDictionary[T any, K comparable](source []T, keyGen func(x T) K) map[K]T
func ToHashSet ¶
func ToHashSet[T comparable](source []T) map[T]struct{}
func ToLookUp ¶
func ToLookUp[T, R any, K comparable](source []T, keySelector func(x T) K, elementSelector func(x T) R) map[K]R
func Union ¶
func Union[T comparable](left, right []T) []T
func UnionBy ¶
func UnionBy[T any, K comparable](left, right []T, keySelector func(x T) K) []T
func Values ¶
func Values[T comparable, R any](source map[T]R) []R
Types ¶
type Complex ¶
type Complex interface { ~complex64 | ~complex128 }
Complex is a constraint that permits any complex numeric type. If future releases of Go add new predeclared complex numeric types, this constraint will be modified to include them.
type Float ¶
Float is a constraint that permits any floating-point type. If future releases of Go add new predeclared floating-point types, this constraint will be modified to include them.
type Integer ¶
Integer is a constraint that permits any integer type. If future releases of Go add new predeclared integer types, this constraint will be modified to include them.
type Ordered ¶
Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >. If future releases of Go add new ordered types, this constraint will be modified to include them.
Source Files ¶
- aggregate.go
- all.go
- any.go
- average.go
- chunk.go
- constraints.go
- consts.go
- contains.go
- count.go
- default_if_empty.go
- distinct.go
- distinct_by.go
- except.go
- except_by.go
- first.go
- first_or_default.go
- group_by.go
- group_join.go
- intersect.go
- intersect_by.go
- keys.go
- last.go
- last_or_default.go
- max.go
- max_by.go
- min.go
- min_by.go
- of_type.go
- order.go
- order_by.go
- order_by_descending.go
- order_descending.go
- prepend.go
- repeat.go
- reverse.go
- select.go
- select_many.go
- single.go
- single_or_default.go
- skip.go
- skip_last.go
- skip_while.go
- sum.go
- take.go
- take_last.go
- take_while.go
- to_dictionary.go
- to_hash_set.go
- to_lookup.go
- union.go
- union_by.go
- values.go
- where.go
- zero.go
- zip.go