Documentation
¶
Index ¶
- func Identity[T any](v T) T
- func Reduce[T, R any](s *Stream[T], reducer func(R, T) R, initial R) R
- type Pair
- type Stream
- func Batched[T any](s *Stream[T], n int) *Stream[[]T]
- func Chunked[T any](s *Stream[T], predicate func(T) bool) *Stream[[]T]
- func Count(start int, step int) *Stream[int]
- func Cycle[T any](data []T) *Stream[T]
- func DistinctBy[T any, R comparable](s *Stream[T], keyFunc func(T) R) *Stream[T]
- func FlatMap[T, R any](s *Stream[T], mapper func(T) []R) *Stream[R]
- func Flatten[T any](s *Stream[[]T]) *Stream[T]
- func FromChannel[T any](ch <-chan T) *Stream[T]
- func FromFile(path string) *Stream[string]
- func FromSeq[T any](seq iter.Seq[T]) *Stream[T]
- func FromSlice[T any](data []T) *Stream[T]
- func FromStdin() *Stream[string]
- func GroupBy[T any](s *Stream[T], keyFunc func(T) T) *Stream[[]T]
- func Map[T, R any](s *Stream[T], mapper func(T) R) *Stream[R]
- func PairWise[T any](s *Stream[T]) *Stream[Pair[T, T]]
- func Range(start, end, step int) *Stream[int]
- func Repeat[T any](elem T, n int) *Stream[T]
- func Sort[T cmp.Ordered](s *Stream[T]) *Stream[T]
- func ToPairStream[K, V any](s *Stream2[K, V]) *Stream[Pair[K, V]]
- func Unique[T any, R comparable](s *Stream[T], keyFunc func(T) R) *Stream[T]
- func ZipLongest[T any](s *Stream[T], other *Stream[T], fillValue T) *Stream[[]T]
- func (s *Stream[T]) Accumulate(fn func(T, T) T) *Stream[T]
- func (s *Stream[T]) All(predicate func(T) bool) bool
- func (s *Stream[T]) Any(predicate func(T) bool) bool
- func (s *Stream[T]) Append(items ...T) *Stream[T]
- func (s *Stream[T]) Cache() *Stream[T]
- func (s *Stream[T]) Chain(args ...*Stream[T]) *Stream[T]
- func (s *Stream[T]) Compress(d *Stream[bool]) *Stream[T]
- func (s *Stream[T]) Count(predicate func(T) bool) int
- func (s *Stream[T]) Cycle() *Stream[T]
- func (s *Stream[T]) Drop(n int) *Stream[T]
- func (s *Stream[T]) DropWhile(predicate func(T) bool) *Stream[T]
- func (s *Stream[T]) Enumerate() *Stream2[int, T]
- func (s *Stream[T]) Exists(predicate func(T) bool) bool
- func (s *Stream[T]) Filter(predicate func(T) bool) *Stream[T]
- func (s *Stream[T]) FilterFalse(predicate func(T) bool) *Stream[T]
- func (s *Stream[T]) Find(predicate func(T) bool) (T, bool)
- func (s *Stream[T]) ForEach(action func(T))
- func (s *Stream[T]) Head() T
- func (s *Stream[T]) ISlice(start int, stop int) *Stream[T]
- func (s *Stream[T]) Init() *Stream[T]
- func (s *Stream[T]) Iter() iter.Seq[T]
- func (s *Stream[T]) Join(separator string) string
- func (s *Stream[T]) Last() T
- func (s *Stream[T]) Len() int
- func (s *Stream[T]) List() []T
- func (s *Stream[T]) MakeString(separator string) string
- func (s *Stream[T]) MapBool(mapper func(T) bool) *Stream[bool]
- func (s *Stream[T]) MapByte(mapper func(T) byte) *Stream[byte]
- func (s *Stream[T]) MapComplex128(mapper func(T) complex128) *Stream[complex128]
- func (s *Stream[T]) MapComplex64(mapper func(T) complex64) *Stream[complex64]
- func (s *Stream[T]) MapError(mapper func(T) error) *Stream[error]
- func (s *Stream[T]) MapFloat32(mapper func(T) float32) *Stream[float32]
- func (s *Stream[T]) MapFloat64(mapper func(T) float64) *Stream[float64]
- func (s *Stream[T]) MapInt(mapper func(T) int) *Stream[int]
- func (s *Stream[T]) MapInt16(mapper func(T) int16) *Stream[int16]
- func (s *Stream[T]) MapInt32(mapper func(T) int32) *Stream[int32]
- func (s *Stream[T]) MapInt64(mapper func(T) int64) *Stream[int64]
- func (s *Stream[T]) MapInt8(mapper func(T) int8) *Stream[int8]
- func (s *Stream[T]) MapRune(mapper func(T) rune) *Stream[rune]
- func (s *Stream[T]) MapString(mapper func(T) string) *Stream[string]
- func (s *Stream[T]) MapT(mapper func(T) T) *Stream[T]
- func (s *Stream[T]) MapUint(mapper func(T) uint) *Stream[uint]
- func (s *Stream[T]) MapUint16(mapper func(T) uint16) *Stream[uint16]
- func (s *Stream[T]) MapUint32(mapper func(T) uint32) *Stream[uint32]
- func (s *Stream[T]) MapUint64(mapper func(T) uint64) *Stream[uint64]
- func (s *Stream[T]) MapUint8(mapper func(T) uint8) *Stream[uint8]
- func (s *Stream[T]) MapUintptr(mapper func(T) uintptr) *Stream[uintptr]
- func (s *Stream[T]) Max(comparator func(T, T) int) T
- func (s *Stream[T]) Min(comparator func(T, T) int) T
- func (s *Stream[T]) Peek(action func(T)) *Stream[T]
- func (s *Stream[T]) Prepend(items ...T) *Stream[T]
- func (s *Stream[T]) Reduce(reducer func(T, T) T, initial T) T
- func (s *Stream[T]) Reversed() *Stream[T]
- func (s *Stream[T]) Slice(start, stop, step int) *Stream[T]
- func (s *Stream[T]) Sorted(cmp func(T, T) int) *Stream[T]
- func (s *Stream[T]) SortedStable(cmp func(T, T) int) *Stream[T]
- func (s *Stream[T]) Sum(addFunc func(T, T) T) T
- func (s *Stream[T]) Tail() *Stream[T]
- func (s *Stream[T]) Take(n int) *Stream[T]
- func (s *Stream[T]) TakeWhile(predicate func(T) bool) *Stream[T]
- func (s *Stream[T]) ToChannel() chan T
- func (s *Stream[T]) Uncons() (T, *Stream[T])
- func (s *Stream[T]) Unsnoc() (*Stream[T], T)
- type Stream2
- type Triplet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Stream ¶
type Stream[T any] struct { // contains filtered or unexported fields }
func DistinctBy ¶
func DistinctBy[T any, R comparable](s *Stream[T], keyFunc func(T) R) *Stream[T]
func FromChannel ¶
func ZipLongest ¶
ZipLongest returns a new Stream where each element is a slice containing elements from the original stream and the provided 'other' stream. If the streams are of unequal length, the shorter stream will be padded with 'fillValue' until both streams are exhausted.
func (*Stream[T]) Accumulate ¶
func (*Stream[T]) Cache ¶
| `cache()` | Forces evaluation of sequence immediately and caches the result | action |
func (*Stream[T]) Drop ¶
| `drop(n)` | Drops the first `n` elements of the sequence | transformation |
func (*Stream[T]) FilterFalse ¶
func (*Stream[T]) ForEach ¶
func (s *Stream[T]) ForEach(action func(T))
| `for_each(func)` | Executes `func` on each element of the sequence | action |
func (*Stream[T]) MakeString ¶
| `make_string(separator)` | Returns string with `separator` between each `str(element)` | action |
func (*Stream[T]) MapComplex128 ¶
func (s *Stream[T]) MapComplex128(mapper func(T) complex128) *Stream[complex128]
func (*Stream[T]) MapComplex64 ¶
func (*Stream[T]) MapFloat32 ¶
func (*Stream[T]) MapFloat64 ¶
func (*Stream[T]) MapUintptr ¶
func (*Stream[T]) Peek ¶
| `peek(func)` | Executes `func` on each element of the sequence and returns it | transformation |****
func (*Stream[T]) SortedStable ¶
func (*Stream[T]) TakeWhile ¶
TakeWhile returns a new Stream that yields items from the original Stream as long as the provided predicate function returns true. Once the predicate function returns false, the Stream stops yielding items.
The predicate function takes an item of type T and returns a boolean indicating whether the item should be included in the resulting Stream.
Example usage:
stream := NewStream([]int{1, 2, 3, 4, 5}) result := stream.TakeWhile(func(n int) bool { return n < 4 }) // result will yield 1, 2, 3
Parameters:
predicate - A function that takes an item of type T and returns a boolean.
Returns:
A new Stream that yields items from the original Stream as long as the predicate function returns true.