Documentation
¶
Overview ¶
Package collection consists of common operations of c.Iterable based collections
Index ¶
- func Conv[From, To any, I c.Iterable[From]](collection I, converter func(From) (To, error)) breakStream.Iter[To]
- func Convert[From, To any, I c.Iterable[From]](collection I, converter func(From) To) stream.Iter[To]
- func Filter[T any, I c.Iterable[T]](collection I, filter func(T) bool) stream.Iter[T]
- func FilterAndConvert[From, To any, I c.Iterable[From]](collection I, filter func(From) bool, converter func(From) To) stream.Iter[To]
- func FilterAndFlatt[From, To any, I c.Iterable[From]](collection I, filter func(From) bool, flattener func(From) []To) stream.Iter[To]
- func First[T any, I c.Iterable[T]](collection I, predicate func(T) bool) (v T, ok bool)
- func Firstt[T any, I c.Iterable[T]](collection I, predicate func(T) (bool, error)) (v T, ok bool, err error)
- func Flat[From, To comparable, I c.Iterable[From]](collection I, flattener func(From) ([]To, error)) breakStream.Iter[To]
- func Flatt[From, To any, I c.Iterable[From]](collection I, by func(From) []To) stream.Iter[To]
- func GetValues[T any, I c.Iterable[*T]](collection I) stream.Iter[T]
- func Group[T any, K comparable, I c.Iterable[T]](collection I, by func(T) K) kvstream.Iter[K, T, map[K][]T]
- func NilSafe[From, To any](next func() (*From, bool), converter func(*From) *To) stream.Iter[*To]
- func NotNil[T any, I c.Iterable[*T]](collection I) stream.Iter[*T]
- func ToValues[T any, I c.Iterable[*T]](collection I) stream.Iter[T]
- type Collection
- type Map
- type Set
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Conv ¶
func Conv[From, To any, I c.Iterable[From]](collection I, converter func(From) (To, error)) breakStream.Iter[To]
Conv returns a breakable stream that applies the 'converter' function to the collection elements
func Convert ¶
func Convert[From, To any, I c.Iterable[From]](collection I, converter func(From) To) stream.Iter[To]
Convert returns a stream that applies the 'converter' function to the collection elements
func Filter ¶
Filter instantiates a stream that checks elements by the 'filter' function and returns successful ones
func FilterAndConvert ¶
func FilterAndConvert[From, To any, I c.Iterable[From]](collection I, filter func(From) bool, converter func(From) To) stream.Iter[To]
FilterAndConvert returns a stream that filters source elements and converts them
func FilterAndFlatt ¶
func FilterAndFlatt[From, To any, I c.Iterable[From]](collection I, filter func(From) bool, flattener func(From) []To) stream.Iter[To]
FilterAndFlatt filters source elements and extracts slices of 'To' by the 'flattener' function
func First ¶
First returns the first element that satisfies the condition of the 'predicate' function
func Firstt ¶
func Firstt[T any, I c.Iterable[T]](collection I, predicate func(T) (bool, error)) (v T, ok bool, err error)
Firstt returns the first element that satisfies the condition of the 'predicate' function
func Flat ¶
func Flat[From, To comparable, I c.Iterable[From]](collection I, flattener func(From) ([]To, error)) breakStream.Iter[To]
Flat returns a breakable stream that converts the collection elements into slices and then flattens them to one level
func Flatt ¶
Flatt returns a stream that converts the collection elements into slices and then flattens them to one level
func GetValues ¶
GetValues creates a stream that transform only not nil pointers to the values referenced referenced by those pointers. Nil pointers are ignored.
func Group ¶
func Group[T any, K comparable, I c.Iterable[T]](collection I, by func(T) K) kvstream.Iter[K, T, map[K][]T]
Group groups elements to slices by a converter and returns a map
func NilSafe ¶
NilSafe - convert.NilSafe filters not nil next, converts that ones, filters not nils after converting and returns them
Types ¶
type Collection ¶
type Collection[T any] interface { c.Collection[T] c.Filterable[T, stream.Iter[T], breakStream.Iter[T]] c.Convertable[T, stream.Iter[T], breakStream.Iter[T]] Len() int IsEmpty() bool HasAny(func(T) bool) bool }
Collection is the base interface for the Vector and the Set impelementations
type Map ¶
type Map[K comparable, V any] interface { kv.Collection[K, V, map[K]V] kv.Filterable[K, V, kvstream.Iter[K, V, map[K]V], breakKvstream.Iter[K, V, map[K]V]] kv.Convertable[K, V, kvstream.Iter[K, V, map[K]V], breakKvstream.Iter[K, V, map[K]V]] c.Checkable[K] c.Access[K, V] Len() int IsEmpty() bool HasAny(func(K, V) bool) bool }
Map - collection interface that stores key/value pairs and provide access to an element by its key
type Set ¶
type Set[T comparable] interface { Collection[T] c.Checkable[T] }
Set - collection interface that ensures the uniqueness of elements (does not insert duplicate values).
Directories
¶
Path | Synopsis |
---|---|
Package convert provides converation helpers for collection implementations
|
Package convert provides converation helpers for collection implementations |
Package filter provides aliases for collections filtering helpers
|
Package filter provides aliases for collections filtering helpers |
Package group provides short aliases for functions that are used to group collection elements
|
Package group provides short aliases for functions that are used to group collection elements |
Package immutable provides immutable collection implementations
|
Package immutable provides immutable collection implementations |
map_
Package map_ provides immutable.Map constructors
|
Package map_ provides immutable.Map constructors |
ordered
Package ordered provides immutable ordered collection implementations
|
Package ordered provides immutable ordered collection implementations |
ordered/map_
Package map_ provides immutale ordered.Map constructors
|
Package map_ provides immutale ordered.Map constructors |
ordered/set
Package set provides ordered.Set constructors and helpers
|
Package set provides ordered.Set constructors and helpers |
set
Package set provides unordered immutable.Set constructors and helpers
|
Package set provides unordered immutable.Set constructors and helpers |
vector
Package vector provides ordered immutable.Vector constructors and helpers
|
Package vector provides ordered immutable.Vector constructors and helpers |
Package mutable provides implementations of mutable containers.
|
Package mutable provides implementations of mutable containers. |
map_
Package map_ provides unordered mutable.Map constructors
|
Package map_ provides unordered mutable.Map constructors |
ordered
Package ordered provides mutable ordered collection implementations
|
Package ordered provides mutable ordered collection implementations |
ordered/map_
Package map_ provides mutable ordered.Map constructors
|
Package map_ provides mutable ordered.Map constructors |
ordered/set
Package set provides mutable ordered.Set constructors and helpers
|
Package set provides mutable ordered.Set constructors and helpers |
set
Package set provides unordered mutable.Set constructors and helpers
|
Package set provides unordered mutable.Set constructors and helpers |
sync
Package sync provides parametrized Map implementation
|
Package sync provides parametrized Map implementation |
vector
Package vector provides mutable.Vector constructors and helpers
|
Package vector provides mutable.Vector constructors and helpers |