arrayiter

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: MIT Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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

Jump to

Keyboard shortcuts

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