slice

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All added in v1.2.4

func All[T any](s SliceIterator[T], predicate func(v T) bool) bool

Returns true if all elements meet predicate

func Any added in v1.2.4

func Any[T any](s SliceIterator[T], predicate func(v T) bool) bool

Returns true if any elements meet predicate

func Reduce

func Reduce[T, V any](i SliceIterator[T], initial V, reduce func(acc V, curr T) V) V

Reduce combines all elements of a iterator of type T into a single accumulated value V, starting with an initial value

Types

type Enumerated added in v1.2.4

type Enumerated[U any] struct {
	Index int
	Value U
}

type Enumerator added in v1.2.4

type Enumerator[V any] iter.Seq[Enumerated[V]]

type SliceIterator added in v1.2.1

type SliceIterator[T any] iter.Seq[T]

SliceIterator is a type definition of an iter.Seq for value of type T

func Concat added in v1.2.4

func Concat[T any](iters ...SliceIterator[T]) SliceIterator[T]

Concatenates multiple iterators into a single iterator

func Filter

func Filter[T any](s SliceIterator[T], filter func(t T) bool) SliceIterator[T]

Filter iterates over a slice T and returns a new iterator containing only the elements for which the provided filter function returns true.

func Map

func Map[T, V any](s SliceIterator[T], transform func(t T) V) SliceIterator[V]

Map applies a transformation function to every element of a slice T and returns a new iterator of V.

func NewIterator added in v1.2.1

func NewIterator[T any](s []T) SliceIterator[T]

NewIterator creates a SliceIterator that iterates over the elements of the provided slice s.

func Zip added in v1.2.4

func Zip[T, V any](s1 []T, s2 []V) SliceIterator[Tuple[T, V]]

Combines two slices and returns an iterator of tuples

func (SliceIterator[T]) Collect added in v1.2.1

func (i SliceIterator[T]) Collect() []T

Collect consumes the SliceIterator and returns a new slice containing all the yielded elements.

func (SliceIterator[T]) Count added in v1.2.4

func (s SliceIterator[T]) Count() int

Returns count of elements in iterator

func (SliceIterator[T]) Enumerate added in v1.2.4

func (s SliceIterator[T]) Enumerate() Enumerator[T]

type Tuple added in v1.2.4

type Tuple[T, V any] struct {
	Left  T
	Right V
}

Jump to

Keyboard shortcuts

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