Documentation ¶
Index ¶
- func Accumulate[T any](collection any, f func(cur, mem T) T) T
- func Compare[T constraints.Ordered](first, second any) int
- func Concat[T any](collections ...any) func() (T, bool)
- func CreateMap[K comparable, V any](keys any, values any) map[K]V
- func Empty[T any]() func() (T, bool)
- func Enumerate[T any](collection any) func() (int, T, bool)
- func Filter[T any](collection any, f func(T) bool) func() (T, bool)
- func In[T comparable](item T, collection any) bool
- func Iterate[T any](collection any) func() (T, bool)
- func Map[T, S any](collection any, f func(T) S) func() (S, bool)
- func One[T any](collection any) T
- func Sink[T, S any](f func(values ...T) S, collections ...any) func() (S, bool)
- func ToChan[T any](collection any) <-chan T
- func ToMap[K comparable, V any](collection any, f func(K) V) map[K]V
- func ToSlice[T any](collection any) []T
- func Zip[T any](first, second any) func() (T, bool)
- type Iterable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Accumulate ¶
Accumulate calculation on collection items.
func Compare ¶
func Compare[T constraints.Ordered](first, second any) int
Compare two collections, negative if first is bigger, positive if second, zero for equality.
func CreateMap ¶
func CreateMap[K comparable, V any](keys any, values any) map[K]V
CreateMap initializes and returns a new map with keys from the keys collection and corresponding values from the values collection
func Filter ¶
Filter filters a collection using a predicate, it will return the result as an iterator.
func In ¶
func In[T comparable](item T, collection any) bool
In returns true if the given item is found within the collection, it returns false otherwise.
func Iterate ¶
Iterate returns an iterator for iterating over the collection, which can be of type Slice, Array, Map, Iterable or iterator (func() (T, bool), will be returned as-is).
func Map ¶
Map every item in the collection using the mapping function, returns an iterator as the result.
func Sink ¶
Sink maps values from multiple collections into a single collection, returned as an iterator.
func ToMap ¶
func ToMap[K comparable, V any](collection any, f func(K) V) map[K]V
ToMap initializes and returns a new map from the given collection, a mapping function is called to map a value for every key
Types ¶
type Iterable ¶
type Iterable[T any] interface { // Iterator returns an interator in the form // of a function that returns the next value // and a second boolean that signals the end // of the iteration. Iterator() func() (T, bool) }
Iterable types that implement this interface can be used with all the funcs in this package.