ustream

package
v1.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector[T any] interface {
	Collect() []T
	CollectToMap(func(*T) (any, any)) map[any]any
}

Collector defines the interface for collecting elements from a stream.

type Stream

type Stream[T any] struct {
	// contains filtered or unexported fields
}

func NewStream

func NewStream[T any](values []T) *Stream[T]

NewStream creates a new Stream from the given slice.

func (*Stream[T]) Collect

func (s *Stream[T]) Collect() []T

func (*Stream[T]) CollectToMap

func (s *Stream[T]) CollectToMap(mapper func(*T) (any, any)) map[any]any

CollectToMap uses the uarray.ToMultiMap function to collect elements of the Stream into a map.

func (*Stream[T]) Filter

func (s *Stream[T]) Filter(predicate func(*T) bool) *Stream[T]

Filter wraps the uarray.Filter function in the stream API.

func (*Stream[T]) FilterOut

func (s *Stream[T]) FilterOut(predicate func(*T) bool) *Stream[T]

FilterOut wraps the uarray.FilterOut function in the stream API.

func (*Stream[T]) Map

func (s *Stream[T]) Map(mapper func(*T) any) *TerminalStream[any]

Map wraps the uarray.Map function in the stream API. This operation can only be the last in a pipeline.

func (*Stream[T]) ToTerminal

func (s *Stream[T]) ToTerminal() *TerminalStream[T]

type TerminalStream

type TerminalStream[T any] struct {
	// contains filtered or unexported fields
}

TerminalStream represents a stream that can only be collected.

func NewTerminalStream

func NewTerminalStream[T any](values []T) *TerminalStream[T]

func (*TerminalStream[T]) Collect

func (s *TerminalStream[T]) Collect() []T

func (*TerminalStream[T]) CollectToMap

func (s *TerminalStream[T]) CollectToMap(mapper func(*T) (any, T)) map[any][]T

CollectToMap uses the uarray.ToMultiMap function to collect elements of the Stream into a map.

func (*TerminalStream[T]) ParallelExecute

func (s *TerminalStream[T]) ParallelExecute(fn func(int, *T), parallelism int)

ParallelExecute executes the given function concurrently on each element of the stream's values using the specified level of parallelism.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL