funcit

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package funcit allows for functional sources of items to be used with iterators.

Iterator functions:

  • IterFn - calls a NextFnT and a ValueFnT function to test for more data and retrieving it
  • PullFn - calls a single PullFnT function to test for more data and retrieving it

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IterFn

func IterFn[T any](nextFn NextFnT, valueFn ValueFnT[T]) itkit.Iterator[T]

IterFn provides an iterator which calls the provided next function to test whenever there is another item available and yields the values returned from the provided value function.

func PullFn

func PullFn[T any](puller PullFnT[T]) itkit.Iterator[T]

PullFn provides an iterator which calls the given function returning its items until the function signals there are no more items left.

Types

type NextFnT

type NextFnT func() bool

NextFnT advances the iterator to the first/next item, returning true if successful meaning there is an item available to be fetched and false otherwise.

type PullFnT

type PullFnT[T any] func() (T, bool)

PullFnT represents a function that returns a single value and a boolean value indicating whenever calling the function will yield more values or not.

type PullIterator

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

PullIterator represents an iterator which calls a function until it returns no more items.

func (*PullIterator[T]) Next

func (it *PullIterator[T]) Next() (ok bool)

func (*PullIterator[T]) Value

func (it *PullIterator[T]) Value() T

type StateIterator

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

StateIterator represents an iterator which calls a given next function to test whenever there is another item available and yields the values returned from a provided value retrieval function.

func (StateIterator[T]) Next

func (it StateIterator[T]) Next() bool

func (StateIterator[T]) Value

func (it StateIterator[T]) Value() T

type ValueFnT

type ValueFnT[T any] func() T

ValueFnT returns the current item of the iterator.

Jump to

Keyboard shortcuts

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