Documentation
¶
Index ¶
- func FromTypedArrayToInterfaceArray(arr interface{}) []interface{}
- type HashPair
- type OperationDescriptor
- type OperationTag
- type ParallelStream
- func (s *ParallelStream) AllMatch(predict func(interface{}) bool) bool
- func (s *ParallelStream) AnyMatch(predict func(interface{}) bool) bool
- func (s *ParallelStream) AsParallel(routines int) Stream
- func (s *ParallelStream) AsSequence() Stream
- func (s *ParallelStream) Count() int
- func (s *ParallelStream) Distinct(hash func(interface{}) string) Stream
- func (s *ParallelStream) Filter(filter func(interface{}) bool) Stream
- func (s *ParallelStream) FilterOrdered(filter func(interface{}) bool) Stream
- func (s *ParallelStream) FindAny() *util.Optional
- func (s *ParallelStream) FindFirst() *util.Optional
- func (s *ParallelStream) FlatMap(mapper func(interface{}) []interface{}) Stream
- func (s *ParallelStream) FlatMapOrdered(mapper func(interface{}) []interface{}) Stream
- func (s *ParallelStream) ForEach(consumer func(interface{}))
- func (s *ParallelStream) IsParallel() bool
- func (s *ParallelStream) Limit(limit int) Stream
- func (s *ParallelStream) Map(mapper func(interface{}) interface{}) Stream
- func (s *ParallelStream) MapOrdered(mapper func(interface{}) interface{}) Stream
- func (s *ParallelStream) Max(less func(interface{}, interface{}) bool) *util.Optional
- func (s *ParallelStream) Min(less func(interface{}, interface{}) bool) *util.Optional
- func (s *ParallelStream) NoneMatch(predict func(interface{}) bool) bool
- func (s *ParallelStream) Peek(peeker func(interface{})) Stream
- func (s *ParallelStream) Reduce(init interface{}, reducer func(interface{}, interface{}) interface{}) interface{}
- func (s *ParallelStream) ReduceCombine(init interface{}, reducer func(interface{}, interface{}) interface{}, ...) interface{}
- func (s *ParallelStream) ReduceOptional(reducer func(interface{}, interface{}) interface{}) *util.Optional
- func (s *ParallelStream) Reverse() Stream
- func (s *ParallelStream) Skip(skip int) Stream
- func (s *ParallelStream) Sorted(less func(interface{}, interface{}) bool) Stream
- func (s *ParallelStream) ToArray() []interface{}
- func (s *ParallelStream) ToMap(keyMapper func(interface{}) interface{}, ...) map[interface{}]interface{}
- func (s *ParallelStream) ToTypedArray(t reflect.Type) reflect.Value
- func (s *ParallelStream) ToTypedMap(t reflect.Type, keyMapper func(interface{}) interface{}, ...) reflect.Value
- type SequencialStream
- func (s *SequencialStream) AllMatch(predict func(interface{}) bool) bool
- func (s *SequencialStream) AnyMatch(predict func(interface{}) bool) bool
- func (s *SequencialStream) AsParallel(routines int) Stream
- func (s *SequencialStream) AsSequence() Stream
- func (s *SequencialStream) Count() int
- func (s *SequencialStream) Distinct(hash func(interface{}) string) Stream
- func (s *SequencialStream) Filter(filter func(interface{}) bool) Stream
- func (s *SequencialStream) FilterOrdered(filter func(interface{}) bool) Stream
- func (s *SequencialStream) FindAny() *util.Optional
- func (s *SequencialStream) FindFirst() *util.Optional
- func (s *SequencialStream) FlatMap(mapper func(interface{}) []interface{}) Stream
- func (s *SequencialStream) FlatMapOrdered(mapper func(interface{}) []interface{}) Stream
- func (s *SequencialStream) ForEach(consumer func(interface{}))
- func (s *SequencialStream) IsParallel() bool
- func (s *SequencialStream) Limit(limit int) Stream
- func (s *SequencialStream) Map(mapper func(interface{}) interface{}) Stream
- func (s *SequencialStream) MapOrdered(mapper func(interface{}) interface{}) Stream
- func (s *SequencialStream) Max(less func(interface{}, interface{}) bool) *util.Optional
- func (s *SequencialStream) Min(less func(interface{}, interface{}) bool) *util.Optional
- func (s *SequencialStream) NoneMatch(predict func(interface{}) bool) bool
- func (s *SequencialStream) Peek(peeker func(interface{})) Stream
- func (s *SequencialStream) Reduce(init interface{}, reducer func(acc, cur interface{}) interface{}) interface{}
- func (s *SequencialStream) ReduceCombine(init interface{}, reducer func(interface{}, interface{}) interface{}, ...) interface{}
- func (s *SequencialStream) ReduceOptional(reducer func(acc, cur interface{}) interface{}) *util.Optional
- func (s *SequencialStream) Reverse() Stream
- func (s *SequencialStream) Skip(skip int) Stream
- func (s *SequencialStream) Sorted(less func(prev, next interface{}) bool) Stream
- func (s *SequencialStream) ToArray() []interface{}
- func (s *SequencialStream) ToMap(keyMapper func(interface{}) interface{}, ...) map[interface{}]interface{}
- func (s *SequencialStream) ToTypedArray(t reflect.Type) reflect.Value
- func (s *SequencialStream) ToTypedMap(t reflect.Type, keyMapper func(interface{}) interface{}, ...) reflect.Value
- type Stream
- func Concat(s ...Stream) Stream
- func ConcatAsParallel(routines int, s ...Stream) Stream
- func FromArray(arr []interface{}) Stream
- func FromArrayParallel(routines int, arr []interface{}) Stream
- func FromTypedArray(arr interface{}) Stream
- func FromTypedArrayParallel(routines int, arr interface{}) Stream
- func Of(i ...interface{}) Stream
- func OfParallel(routines int, i ...interface{}) Stream
- func Transform(stream Stream, descriptors []OperationDescriptor) Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromTypedArrayToInterfaceArray ¶
func FromTypedArrayToInterfaceArray(arr interface{}) []interface{}
Types ¶
type OperationDescriptor ¶
type OperationDescriptor struct {
// contains filtered or unexported fields
}
type OperationTag ¶
type OperationTag string
const ( DISTINCT OperationTag = "DISTINCT" FILTER OperationTag = "FILTER" FILTER_ORDERED OperationTag = "FILTER_ORDERED" FLAT_MAP OperationTag = "FLATMAP" FLAT_MAP_ORDERED OperationTag = "FLAT_MAP_ORDERED" LIMIT OperationTag = "LIMIT" MAP OperationTag = "MAP" MAP_ORDERED OperationTag = "MAP_ORDERED" PEEK OperationTag = "PEEK" REVERSE OperationTag = "REVERSE" SKIP OperationTag = "SKIP" SORTED OperationTag = "SORTED" )
type ParallelStream ¶
type ParallelStream struct {
// contains filtered or unexported fields
}
func (*ParallelStream) AllMatch ¶
func (s *ParallelStream) AllMatch(predict func(interface{}) bool) bool
func (*ParallelStream) AnyMatch ¶
func (s *ParallelStream) AnyMatch(predict func(interface{}) bool) bool
func (*ParallelStream) AsParallel ¶
func (s *ParallelStream) AsParallel(routines int) Stream
func (*ParallelStream) AsSequence ¶
func (s *ParallelStream) AsSequence() Stream
func (*ParallelStream) Count ¶
func (s *ParallelStream) Count() int
func (*ParallelStream) Distinct ¶
func (s *ParallelStream) Distinct(hash func(interface{}) string) Stream
func (*ParallelStream) Filter ¶
func (s *ParallelStream) Filter(filter func(interface{}) bool) Stream
func (*ParallelStream) FilterOrdered ¶
func (s *ParallelStream) FilterOrdered(filter func(interface{}) bool) Stream
func (*ParallelStream) FindAny ¶
func (s *ParallelStream) FindAny() *util.Optional
func (*ParallelStream) FindFirst ¶
func (s *ParallelStream) FindFirst() *util.Optional
func (*ParallelStream) FlatMap ¶
func (s *ParallelStream) FlatMap(mapper func(interface{}) []interface{}) Stream
func (*ParallelStream) FlatMapOrdered ¶
func (s *ParallelStream) FlatMapOrdered(mapper func(interface{}) []interface{}) Stream
func (*ParallelStream) ForEach ¶
func (s *ParallelStream) ForEach(consumer func(interface{}))
func (*ParallelStream) IsParallel ¶
func (s *ParallelStream) IsParallel() bool
func (*ParallelStream) Limit ¶
func (s *ParallelStream) Limit(limit int) Stream
func (*ParallelStream) Map ¶
func (s *ParallelStream) Map(mapper func(interface{}) interface{}) Stream
func (*ParallelStream) MapOrdered ¶
func (s *ParallelStream) MapOrdered(mapper func(interface{}) interface{}) Stream
func (*ParallelStream) Max ¶
func (s *ParallelStream) Max(less func(interface{}, interface{}) bool) *util.Optional
func (*ParallelStream) Min ¶
func (s *ParallelStream) Min(less func(interface{}, interface{}) bool) *util.Optional
func (*ParallelStream) NoneMatch ¶
func (s *ParallelStream) NoneMatch(predict func(interface{}) bool) bool
func (*ParallelStream) Peek ¶
func (s *ParallelStream) Peek(peeker func(interface{})) Stream
func (*ParallelStream) Reduce ¶
func (s *ParallelStream) Reduce(init interface{}, reducer func(interface{}, interface{}) interface{}) interface{}
func (*ParallelStream) ReduceCombine ¶
func (s *ParallelStream) ReduceCombine(init interface{}, reducer func(interface{}, interface{}) interface{}, combiner func(interface{}, interface{}) interface{}) interface{}
func (*ParallelStream) ReduceOptional ¶
func (s *ParallelStream) ReduceOptional(reducer func(interface{}, interface{}) interface{}) *util.Optional
func (*ParallelStream) Reverse ¶
func (s *ParallelStream) Reverse() Stream
func (*ParallelStream) Skip ¶
func (s *ParallelStream) Skip(skip int) Stream
func (*ParallelStream) Sorted ¶
func (s *ParallelStream) Sorted(less func(interface{}, interface{}) bool) Stream
func (*ParallelStream) ToArray ¶
func (s *ParallelStream) ToArray() []interface{}
func (*ParallelStream) ToMap ¶
func (s *ParallelStream) ToMap(keyMapper func(interface{}) interface{}, valueMapper func(interface{}) interface{}) map[interface{}]interface{}
func (*ParallelStream) ToTypedArray ¶
func (s *ParallelStream) ToTypedArray(t reflect.Type) reflect.Value
func (*ParallelStream) ToTypedMap ¶
func (s *ParallelStream) ToTypedMap(t reflect.Type, keyMapper func(interface{}) interface{}, valueMapper func(interface{}) interface{}) reflect.Value
type SequencialStream ¶
type SequencialStream struct {
// contains filtered or unexported fields
}
func (*SequencialStream) AllMatch ¶
func (s *SequencialStream) AllMatch(predict func(interface{}) bool) bool
func (*SequencialStream) AnyMatch ¶
func (s *SequencialStream) AnyMatch(predict func(interface{}) bool) bool
func (*SequencialStream) AsParallel ¶
func (s *SequencialStream) AsParallel(routines int) Stream
func (*SequencialStream) AsSequence ¶
func (s *SequencialStream) AsSequence() Stream
func (*SequencialStream) Count ¶
func (s *SequencialStream) Count() int
func (*SequencialStream) Distinct ¶
func (s *SequencialStream) Distinct(hash func(interface{}) string) Stream
func (*SequencialStream) Filter ¶
func (s *SequencialStream) Filter(filter func(interface{}) bool) Stream
func (*SequencialStream) FilterOrdered ¶
func (s *SequencialStream) FilterOrdered(filter func(interface{}) bool) Stream
func (*SequencialStream) FindAny ¶
func (s *SequencialStream) FindAny() *util.Optional
func (*SequencialStream) FindFirst ¶
func (s *SequencialStream) FindFirst() *util.Optional
func (*SequencialStream) FlatMap ¶
func (s *SequencialStream) FlatMap(mapper func(interface{}) []interface{}) Stream
func (*SequencialStream) FlatMapOrdered ¶
func (s *SequencialStream) FlatMapOrdered(mapper func(interface{}) []interface{}) Stream
func (*SequencialStream) ForEach ¶
func (s *SequencialStream) ForEach(consumer func(interface{}))
func (*SequencialStream) IsParallel ¶
func (s *SequencialStream) IsParallel() bool
func (*SequencialStream) Limit ¶
func (s *SequencialStream) Limit(limit int) Stream
func (*SequencialStream) Map ¶
func (s *SequencialStream) Map(mapper func(interface{}) interface{}) Stream
func (*SequencialStream) MapOrdered ¶
func (s *SequencialStream) MapOrdered(mapper func(interface{}) interface{}) Stream
func (*SequencialStream) Max ¶
func (s *SequencialStream) Max(less func(interface{}, interface{}) bool) *util.Optional
func (*SequencialStream) Min ¶
func (s *SequencialStream) Min(less func(interface{}, interface{}) bool) *util.Optional
func (*SequencialStream) NoneMatch ¶
func (s *SequencialStream) NoneMatch(predict func(interface{}) bool) bool
func (*SequencialStream) Peek ¶
func (s *SequencialStream) Peek(peeker func(interface{})) Stream
func (*SequencialStream) Reduce ¶
func (s *SequencialStream) Reduce(init interface{}, reducer func(acc, cur interface{}) interface{}) interface{}
func (*SequencialStream) ReduceCombine ¶
func (s *SequencialStream) ReduceCombine(init interface{}, reducer func(interface{}, interface{}) interface{}, combiner func(interface{}, interface{}) interface{}) interface{}
func (*SequencialStream) ReduceOptional ¶
func (s *SequencialStream) ReduceOptional(reducer func(acc, cur interface{}) interface{}) *util.Optional
func (*SequencialStream) Reverse ¶
func (s *SequencialStream) Reverse() Stream
func (*SequencialStream) Skip ¶
func (s *SequencialStream) Skip(skip int) Stream
func (*SequencialStream) Sorted ¶
func (s *SequencialStream) Sorted(less func(prev, next interface{}) bool) Stream
func (*SequencialStream) ToArray ¶
func (s *SequencialStream) ToArray() []interface{}
func (*SequencialStream) ToMap ¶
func (s *SequencialStream) ToMap(keyMapper func(interface{}) interface{}, valueMapper func(interface{}) interface{}) map[interface{}]interface{}
func (*SequencialStream) ToTypedArray ¶
func (s *SequencialStream) ToTypedArray(t reflect.Type) reflect.Value
func (*SequencialStream) ToTypedMap ¶
func (s *SequencialStream) ToTypedMap(t reflect.Type, keyMapper func(interface{}) interface{}, valueMapper func(interface{}) interface{}) reflect.Value
type Stream ¶
type Stream interface {
// AsParallel returns a parallel stream
//
// @param routines Number of go routines to use
// @return A parallel stream with the same pipeline as original stream
AsParallel(routines int) Stream
// AsSequence returns a sequential stream
//
// @return A sequential stream with the same pipeline as original stream
AsSequence() Stream
// AllMatch returns true if all items in the data stream match a prediction
//
// @param predict Prediction function
// @return True if all data items matches condition, false otherwise
AllMatch(predict func(interface{}) bool) bool
// AnyMatch returns true if any items in the data stream match a prediction
//
// @param predict Prediction function
// @return True if any data items matches condition, false otherwise
AnyMatch(predict func(interface{}) bool) bool
// Count returns total number of items in data stream
//
// @return Number of items in data stream
Count() int
// Distinct returns a data stream containing unique items
//
// @param hash Function to generate data item's identity
// @return A data stream with unique items
Distinct(hash func(interface{}) string) Stream
// Filter returns a new stream containing only items matching filter condition
// This method does not guarantee the processing order
//
// @param filter Function to detect if a data item meets the condition
// @return A stream containing filtered data items
Filter(filter func(interface{}) bool) Stream
// FilterOrdered does the same thing as Filter but keeps the original order
//
// @param filter Function to detect if a data item meets the condition
// @return A stream containing filtered data items
FilterOrdered(filter func(interface{}) bool) Stream
// FindAny randomly returns an item in the data stream if exists
//
// @return Any item in data stream
FindAny() *util.Optional
// FindFirst find the first item in data stream if exists
//
// @return First item in data stream
FindFirst() *util.Optional
// FlatMap applies a mapping function, which will generate a list of new items, onto every item in data stream, and then flatten the results into one list
// This method does not guarantee the order of original items in the data stream
//
// @param mapper Function to map an item into a list of new items of any type
// @return A stream after applyting flatmap operation
FlatMap(mapper func(interface{}) []interface{}) Stream
// FlatMapOrdered does the same thing as FlatMap, besides that it keeps the order of original items in the data stream
//
// @param mapper Function to map an item into a list of new items of any type
// @return A stream after applyting flatmap operation
FlatMapOrdered(mapper func(interface{}) []interface{}) Stream
// ForEach applies a consumer function onto each item in data stream
//
// @param Function to be applied onto data items
ForEach(consumer func(interface{}))
// IsParallel returns true if this stream is a parallel one
//
// @return True if this stream is a parallel one, false otherwise
IsParallel() bool
// Limit returns a stream with only limited number of data items
//
// @param limit Number of items to keep
// @return A stream after applying limit operation
Limit(limit int) Stream
// Map applies a function onto every item in data stream and returns another stream of data items with, maybe, different type
// This method does not guarantee the processing order
//
// @param mapper Function to be transform a data type into another one
// @return A stream after applying map operation
Map(mapper func(interface{}) interface{}) Stream
// MapOrdered does the same thing as Map function but keeps the order of the original data items
//
// @param mapper Function to be transform a data type into another one
// @return A stream after applying map operation
MapOrdered(mapper func(interface{}) interface{}) Stream
// Max returns the maximum value in the data stream
//
// @param less Function to judge which value is smaller
// @return Maximum value in the data stream
Max(less func(interface{}, interface{}) bool) *util.Optional
// Min returns the minimal value in the data stream
//
// @param less Function to judge which value is smaller
// @return Minimal value in the data stream
Min(less func(interface{}, interface{}) bool) *util.Optional
// NoneMatch returns true if none of the items in the data stream matches the given condition
//
// @param predict Prediction function
// @return True if none of items matches the given condition, false otherwise
NoneMatch(predict func(interface{}) bool) bool
// Peek applies a function onto each items in data stream and returns a new stream
//
// @param peeker Function to be applied onto each data item
// @return A stream with items in original data stream
Peek(peeker func(interface{})) Stream
// Reduce returns a single value after accumulatively merge every data item in the stream
//
// @param init Initial value to be accumulated
// @param reducer Function to merge elements
// @return A merged result
Reduce(init interface{}, reducer func(interface{}, interface{}) interface{}) interface{}
// ReduceCombine returns a single value after accumulatively merge and combine every data item in the stream
//
// @param init Initial value to be accumulated
// @param reducer Function to merge elements
// @param combiner Function to combine merged result and other value
// @return A merged result
ReduceCombine(init interface{}, reducer func(interface{}, interface{}) interface{}, combiner func(interface{}, interface{}) interface{}) interface{}
// ReduceOptional returns a single value after accumulatively merge every data item in the stream if any item exists, empty otherwise
//
// @param reducer Function to merge elements
// @return A merged result or empty
ReduceOptional(reducer func(interface{}, interface{}) interface{}) *util.Optional
// Reverse completely reverse the current order of data items in this stream and return a new stream
//
// @return A stream with items' order reversed in original stream
Reverse() Stream
// Skip throws the first N items away in the data stream and returns the new stream
// If N is greater than current stream length, an empty stream is returned
//
// @param skip Number of items to be skipped
// @return A stream with first several elements given up
Skip(skip int) Stream
// Sorted sorts the data stream in ascending order
//
// @param less Function to judge which value is smaller
// @return A stream with data items sorted in ascending order
Sorted(less func(interface{}, interface{}) bool) Stream
// ToArray collects data from this stream into an array
//
// @return An array whose data is generated from this stream
ToArray() []interface{}
// ToMap collects data from this stream and transform to a map
//
// @param keyMapper Function to map data item to map key
// @param valueMapper Function to map data item to map value
// @return A map whose data is generated from this stream
ToMap(keyMapper func(interface{}) interface{}, valueMapper func(interface{}) interface{}) map[interface{}]interface{}
// ToTypedArray does the same thing as ToArray method but will transform the result into a typed one via reflection
//
// @param t Type of array element
// @return Typed array containing stream processing result
ToTypedArray(t reflect.Type) reflect.Value
// ToTypedMap does the same thing as ToMap method but will transform the result into a typed key-value pair via reflection
//
// @param t Type of target map
// @param keyMapper Function to map data item to map key
// @param valueMapper Function to map data item to map value
// @return Typed map containing stream processing result
ToTypedMap(t reflect.Type, keyMapper func(interface{}) interface{}, valueMapper func(interface{}) interface{}) reflect.Value
}
func Concat ¶
Concat returns a sequential stream from several streams, either sequential or parallel
@param s Several streams @return A sequential stream
func ConcatAsParallel ¶
ConcatAsParallel returns a parallel stream from several streams, either sequential or parallel
@param routines Number of goroutines @param s Several streams @return A parallel stream
func FromArray ¶
func FromArray(arr []interface{}) Stream
FromArray returns a sequential stream from an interface array
@param arr An interface array @return A sequential stream
func FromArrayParallel ¶
FromArrayParallel returns a parallel stream from an interface array
@param routines Number of goroutines @param arr An interface array @return A parallel stream
func FromTypedArray ¶
func FromTypedArray(arr interface{}) Stream
FromTypedArray returns a sequential stream from a typed array
@param arr A typed array @return A sequential stream
func FromTypedArrayParallel ¶
FromTypedArrayParallel returns a parallel stream from a typed array
@param routines Number of goroutines @param arr A typed array @return A parallel stream
func Of ¶
func Of(i ...interface{}) Stream
Of returns a sequential stream from given data items
@param i Data items @return A sequential stream
func OfParallel ¶
OfParallel returns a parallel stream from given data items
@param routines Number of goroutines @param i Data items @return A parallel stream
func Transform ¶
func Transform(stream Stream, descriptors []OperationDescriptor) Stream