package arrayiter

import "github.com/lestrrat-go/iter/arrayiter"

Index

Functions

func AsArray

func AsArray(ctx context.Context, s interface{}, v interface{}) error

func Walk

func Walk(ctx context.Context, s Source, v Visitor) error

Walk walks through each element in the array

Types

type Iterator

type Iterator interface {
	Next(context.Context) bool
	Pair() *Pair
}

Iterator iterates through keys and values of a array

func Iterate

func Iterate(ctx context.Context, a interface{}) (Iterator, error)

func New

func New(ch chan *Pair) Iterator

type Pair

type Pair struct {
	Index int
	Value interface{}
}

Pair represents a single pair of key and value from a array

type Source

type Source interface {
	Iterate(context.Context) Iterator
}

Source represents a array that knows how to create an iterator

type Visitor

type Visitor interface {
	Visit(int, interface{}) error
}

Visitor represents an object that handles each pair in a array

type VisitorFunc

type VisitorFunc func(int, interface{}) error

VisitorFunc is a type of Visitor based on a function

func (VisitorFunc) Visit

func (fn VisitorFunc) Visit(s int, v interface{}) error

Source Files

arrayiter.go

Version
v1.0.2 (latest)
Published
Mar 29, 2022
Platform
linux/amd64
Imports
4 packages
Last checked
3 weeks ago

Tools for package owners.