iter

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MPL-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package iter provides utilities for working with iterators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Seq

type Seq[T any] func(yield func(T) bool)

Seq is a sequence of elements.

func Deduplicate

func Deduplicate[T any](elems []T, equal func(a, b T) bool) Seq[T]

Deduplicate yields elements from elems, skipping duplicates. It always yields the last equal element. The equal function is used to compare elements. The yield function is used to yield elements. If it returns false, the iteration stops. Slice should be sorted before calling this function.

func Filter

func Filter[T any](seq Seq[T], fn func(T) bool) Seq[T]

Filter iterates over elements in seq, calling the given function for each element. If the function returns true, the element is yielded.

Jump to

Keyboard shortcuts

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