Documentation ¶
Index ¶
- Variables
- func Any[T any](q IEnumerable[T]) bool
- func Average[T Number](q IEnumerable[T]) (result T)
- func Contains[T comparable](q IEnumerable[T], v T) bool
- func Do[T any](q IEnumerable[T], f func(T))
- func First[T any](source IEnumerable[T], ok *bool) T
- func FirstWhere[T any](source IEnumerable[T], pred func(T) bool, found *bool) T
- func Foreach[T any](q IEnumerable[T], f func(T) error) (err error)
- func ForeachI[T any](q IEnumerable[T], f func(int, T) error) (err error)
- func Last[T any](source IEnumerable[T], found *bool) T
- func LastWhere[T any](source IEnumerable[T], pred func(T) bool, retFound *bool) T
- func Max[T constraints.Ordered](q IEnumerable[T]) (result T)
- func MaxBy[T any, K constraints.Ordered](q IEnumerable[T], selector func(T) K) (result T)
- func Min[T constraints.Ordered](q IEnumerable[T]) (result T)
- func MinBy[T any, K constraints.Ordered](q IEnumerable[T], selector func(T) K) (result T)
- func Sum[T Number](q IEnumerable[T]) (result T)
- func ToMap[T any, K comparable, V any](me IEnumerable[T], keyFunc func(T) K, valFunc func(T) V) map[K]V
- func ToSlice[T any](me IEnumerable[T]) []T
- type ICount
- type IEnumerable
- func Abs[T Number](q IEnumerable[T]) IEnumerable[T]
- func Clamp[T constraints.Ordered](q IEnumerable[T], min, max T) IEnumerable[T]
- func FromMap[K comparable, V any](v map[K]V) IEnumerable[Pair[K, V]]
- func FromMapCopy[K comparable, V any](v map[K]V) IEnumerable[Pair[K, V]]
- func FromMapReflect[K comparable, V any](v map[K]V) IEnumerable[Pair[K, V]]
- func FromSlice[T any](v []T) IEnumerable[T]
- func Join[Outer, Inner, Result any](outer IEnumerable[Outer], inner IEnumerable[Inner], ...) IEnumerable[Result]
- func Range[T constraints.Integer | constraints.Float](start, end T) IEnumerable[T]
- func RangeStep[T constraints.Integer | constraints.Float](start, end, step T) IEnumerable[T]
- func Select[T any, T2 any](source IEnumerable[T], selector func(T) T2) IEnumerable[T2]
- func Skip[T any](source IEnumerable[T], n int) IEnumerable[T]
- func Take[T any](source IEnumerable[T], n int) IEnumerable[T]
- func Where[T any](source IEnumerable[T], pred func(T) bool) IEnumerable[T]
- type IEnumerableAndEnumerator
- type IEnumerator
- type IGetAt
- type IRangeEnumerator
- type JoinEnumerableIterator
- func (me *JoinEnumerableIterator[Outer, Inner, Result]) Any() bool
- func (me *JoinEnumerableIterator[Outer, Inner, Result]) Clone() IEnumerator[Result]
- func (me *JoinEnumerableIterator[Outer, Inner, Result]) Count() int
- func (me *JoinEnumerableIterator) Current() T
- func (me *JoinEnumerableIterator) GetEnumerator() IEnumerator[T]
- func (me *JoinEnumerableIterator[Outer, Inner, Result]) MoveNext() bool
- type Map
- type MapEnumerator
- type Number
- type OrderIterator
- type Pair
- type RangeIterator
- func (me *RangeIterator[T]) Any() bool
- func (me *RangeIterator[T]) Clone() IEnumerator[T]
- func (me *RangeIterator[T]) Count() int
- func (me *RangeIterator) Current() T
- func (me *RangeIterator[T]) GetAt(pos int) (result T, err error)
- func (me *RangeIterator) GetEnumerator() IEnumerator[T]
- func (me *RangeIterator[T]) MoveNext() bool
- func (me *RangeIterator[T]) SeekOnce(pos int) error
- type SelectEnumerableIterator
- func (me *SelectEnumerableIterator[T, T2]) Any() bool
- func (me *SelectEnumerableIterator[T, T2]) Clone() IEnumerator[T2]
- func (me *SelectEnumerableIterator[T, T2]) Count() int
- func (me *SelectEnumerableIterator) Current() T
- func (me *SelectEnumerableIterator) GetEnumerator() IEnumerator[T]
- func (me *SelectEnumerableIterator[T, T2]) MoveNext() bool
- type SkipIterator
- type Slice
- type SliceEnumerator
- type TakeIterator
- type WhereEnumerableIterator
- func (me *WhereEnumerableIterator[T]) Any() bool
- func (me *WhereEnumerableIterator[T]) Clone() IEnumerator[T]
- func (me *WhereEnumerableIterator[T]) Count() int
- func (me *WhereEnumerableIterator) Current() T
- func (me *WhereEnumerableIterator) GetEnumerator() IEnumerator[T]
- func (me *WhereEnumerableIterator[T]) MoveNext() bool
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrEmptyEnumerable = errors.New(`IEnumerable is empty`)
)
View Source
var (
ErrInvalidState = errors.New(`Invalid state`)
)
Functions ¶
func Contains ¶
func Contains[T comparable](q IEnumerable[T], v T) bool
func FirstWhere ¶
func ForeachI ¶
Apply f() to all items in q, break when f() returns false. A counted index is passed to f()
func Max ¶
func Max[T constraints.Ordered](q IEnumerable[T]) (result T)
func MaxBy ¶
func MaxBy[T any, K constraints.Ordered](q IEnumerable[T], selector func(T) K) (result T)
func Min ¶
func Min[T constraints.Ordered](q IEnumerable[T]) (result T)
func MinBy ¶
func MinBy[T any, K constraints.Ordered](q IEnumerable[T], selector func(T) K) (result T)
func ToMap ¶
func ToMap[T any, K comparable, V any]( me IEnumerable[T], keyFunc func(T) K, valFunc func(T) V) map[K]V
Types ¶
type IEnumerable ¶
type IEnumerable[T any] interface { GetEnumerator() IEnumerator[T] Count() int Any() bool }
func Clamp ¶
func Clamp[T constraints.Ordered](q IEnumerable[T], min, max T) IEnumerable[T]
func FromMap ¶
func FromMap[K comparable, V any](v map[K]V) IEnumerable[Pair[K, V]]
func FromMapCopy ¶
func FromMapCopy[K comparable, V any](v map[K]V) IEnumerable[Pair[K, V]]
先复制出一个 []Pair[K,V],再转成 IEnumerable,不适用于map很大的情况
func FromMapReflect ¶
func FromMapReflect[K comparable, V any](v map[K]V) IEnumerable[Pair[K, V]]
通过 reflect.MapRange 遍历 map,线性读取快,随机访问慢
func Range ¶
func Range[T constraints.Integer | constraints.Float](start, end T) IEnumerable[T]
func RangeStep ¶
func RangeStep[T constraints.Integer | constraints.Float](start, end, step T) IEnumerable[T]
type IEnumerableAndEnumerator ¶
type IEnumerableAndEnumerator[T any] interface { IEnumerable[T] IEnumerator[T] }
type IEnumerator ¶
type IRangeEnumerator ¶
type JoinEnumerableIterator ¶
type JoinEnumerableIterator[Outer, Inner, Result any] struct { // contains filtered or unexported fields }
func NewJoinIterator ¶
func NewJoinIterator[Outer, Inner, Result any]( outer IEnumerable[Outer], inner IEnumerable[Inner], pred func(Outer, Inner) (selected bool, result Result)) *JoinEnumerableIterator[Outer, Inner, Result]
func (*JoinEnumerableIterator[Outer, Inner, Result]) Any ¶
func (me *JoinEnumerableIterator[Outer, Inner, Result]) Any() bool
func (*JoinEnumerableIterator[Outer, Inner, Result]) Clone ¶
func (me *JoinEnumerableIterator[Outer, Inner, Result]) Clone() IEnumerator[Result]
func (*JoinEnumerableIterator[Outer, Inner, Result]) Count ¶
func (me *JoinEnumerableIterator[Outer, Inner, Result]) Count() int
func (*JoinEnumerableIterator) GetEnumerator ¶
func (me *JoinEnumerableIterator) GetEnumerator() IEnumerator[T]
func (*JoinEnumerableIterator[Outer, Inner, Result]) MoveNext ¶
func (me *JoinEnumerableIterator[Outer, Inner, Result]) MoveNext() bool
type Map ¶
type Map[K comparable, V any] map[K]V
func (Map[K, V]) GetEnumerator ¶
func (me Map[K, V]) GetEnumerator() IEnumerator[Pair[K, V]]
type MapEnumerator ¶
type MapEnumerator[K comparable, V any] struct { // contains filtered or unexported fields }
type Number ¶
type Number interface { constraints.Integer | constraints.Float }
type OrderIterator ¶
type OrderIterator[T any] struct { // contains filtered or unexported fields }
func (*OrderIterator) GetEnumerator ¶
func (me *OrderIterator) GetEnumerator() IEnumerator[T]
type Pair ¶
type Pair[K comparable, V any] struct { Key K Value V }
type RangeIterator ¶
type RangeIterator[T constraints.Integer | constraints.Float] struct { // contains filtered or unexported fields }
func NewRangeIterator ¶
func NewRangeIterator[T constraints.Integer | constraints.Float](start, end, step T) *RangeIterator[T]
func (*RangeIterator[T]) Any ¶
func (me *RangeIterator[T]) Any() bool
func (*RangeIterator[T]) Clone ¶
func (me *RangeIterator[T]) Clone() IEnumerator[T]
func (*RangeIterator[T]) Count ¶
func (me *RangeIterator[T]) Count() int
func (*RangeIterator[T]) GetAt ¶
func (me *RangeIterator[T]) GetAt(pos int) (result T, err error)
func (*RangeIterator) GetEnumerator ¶
func (me *RangeIterator) GetEnumerator() IEnumerator[T]
func (*RangeIterator[T]) MoveNext ¶
func (me *RangeIterator[T]) MoveNext() bool
func (*RangeIterator[T]) SeekOnce ¶
func (me *RangeIterator[T]) SeekOnce(pos int) error
type SelectEnumerableIterator ¶
func NewSelectIterator ¶
func NewSelectIterator[T any, T2 any](source IEnumerable[T], selector func(T) T2) *SelectEnumerableIterator[T, T2]
func (*SelectEnumerableIterator[T, T2]) Any ¶
func (me *SelectEnumerableIterator[T, T2]) Any() bool
func (*SelectEnumerableIterator[T, T2]) Clone ¶
func (me *SelectEnumerableIterator[T, T2]) Clone() IEnumerator[T2]
func (*SelectEnumerableIterator[T, T2]) Count ¶
func (me *SelectEnumerableIterator[T, T2]) Count() int
func (*SelectEnumerableIterator) GetEnumerator ¶
func (me *SelectEnumerableIterator) GetEnumerator() IEnumerator[T]
func (*SelectEnumerableIterator[T, T2]) MoveNext ¶
func (me *SelectEnumerableIterator[T, T2]) MoveNext() bool
type SkipIterator ¶
type SkipIterator[T any] struct { // contains filtered or unexported fields }
func NewSkipIterator ¶
func NewSkipIterator[T any](source IEnumerable[T], n int) *SkipIterator[T]
func (*SkipIterator[T]) Any ¶
func (me *SkipIterator[T]) Any() bool
func (*SkipIterator[T]) Clone ¶
func (me *SkipIterator[T]) Clone() IEnumerator[T]
func (*SkipIterator[T]) Count ¶
func (me *SkipIterator[T]) Count() int
func (*SkipIterator) GetEnumerator ¶
func (me *SkipIterator) GetEnumerator() IEnumerator[T]
func (*SkipIterator[T]) MoveNext ¶
func (me *SkipIterator[T]) MoveNext() bool
type Slice ¶
type Slice[T any] []T
func (Slice[T]) GetEnumerator ¶
func (me Slice[T]) GetEnumerator() IEnumerator[T]
type SliceEnumerator ¶
type SliceEnumerator[T any] struct { // contains filtered or unexported fields }
type TakeIterator ¶
type TakeIterator[T any] struct { // contains filtered or unexported fields }
func NewTakeIterator ¶
func NewTakeIterator[T any](source IEnumerable[T], n int) *TakeIterator[T]
func (*TakeIterator[T]) Any ¶
func (me *TakeIterator[T]) Any() bool
func (*TakeIterator[T]) Clone ¶
func (me *TakeIterator[T]) Clone() IEnumerator[T]
func (*TakeIterator[T]) Count ¶
func (me *TakeIterator[T]) Count() int
func (*TakeIterator) GetEnumerator ¶
func (me *TakeIterator) GetEnumerator() IEnumerator[T]
func (*TakeIterator[T]) MoveNext ¶
func (me *TakeIterator[T]) MoveNext() bool
type WhereEnumerableIterator ¶
type WhereEnumerableIterator[T any] struct { // contains filtered or unexported fields }
func NewWhereIterator ¶
func NewWhereIterator[T any](source IEnumerable[T], pred func(T) bool) *WhereEnumerableIterator[T]
func (*WhereEnumerableIterator[T]) Any ¶
func (me *WhereEnumerableIterator[T]) Any() bool
func (*WhereEnumerableIterator[T]) Clone ¶
func (me *WhereEnumerableIterator[T]) Clone() IEnumerator[T]
func (*WhereEnumerableIterator[T]) Count ¶
func (me *WhereEnumerableIterator[T]) Count() int
func (*WhereEnumerableIterator) GetEnumerator ¶
func (me *WhereEnumerableIterator) GetEnumerator() IEnumerator[T]
func (*WhereEnumerableIterator[T]) MoveNext ¶
func (me *WhereEnumerableIterator[T]) MoveNext() bool
Click to show internal directories.
Click to hide internal directories.