Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnsupportType unsupport type ErrUnsupportType = errors.New("unsupport type") )
Functions ¶
Types ¶
type Sortable ¶
type Sortable[T any] struct { List []T Cmp types.Comparator[T] }
Sortable implement sort.Interface
type Streamer ¶
type Streamer[T any] interface { // WithContext set Streamer context WithContext(context.Context) Streamer[T] // Filter filter data by Judge result Filter(types.Judge[T]) Streamer[T] Map(types.Mapper[T]) Streamer[T] Convert(types.Converter[T, any]) Streamer[any] Peek(types.Consumer[T]) Streamer[T] Distinct() Streamer[T] Sort(types.Comparator[T]) Streamer[T] ReverseSort(types.Comparator[T]) Streamer[T] Reverse() Streamer[T] Limit(int64) Streamer[T] Skip(int64) Streamer[T] Pick(startIndex, endIndex, interval int) Streamer[T] // Append append data to streamer source Append(...T) Streamer[T] // Execute eager execute streamer stage Execute() Streamer[T] // Parallel 0 do nothing, 1 async work, 2-n concurrent work Parallel(int) Streamer[T] // ToSlice ToSlice() []T Collect(types.Collector[T]) any // ForEach ForEach(types.Consumer[T]) // Match methods AllMatch(types.Judge[T]) bool NonMatch(types.Judge[T]) bool AnyMatch(types.Judge[T]) bool // Reduce reduce calculate Reduce(accumulator types.BinaryOperator[T]) T ReduceFrom(initValue T, accumulator types.BinaryOperator[T]) T ReduceWith(initValue any, accumulator types.Accumulator[T, any]) any // ReduceBy use `buildInitValue` to build the initValue, which parameter is a int64 means element size, or -1 if unknown size. // Then use `accumulator` to add each element to previous result ReduceBy(initValueBulider func(sizeMayNegative int) any, accumulator types.Accumulator[T, any]) any // Pick one First() T Take() T Any() T Last() T // Cout return count result Count() int64 }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.