...

Package arrayiter

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

Overview ▾

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

type Iterator

Iterator iterates through keys and values of a array

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

func Iterate

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

func New

func New(ch chan *Pair) Iterator

type Pair

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

type Pair struct {
    Index int
    Value interface{}
}

type Source

Source represents a array that knows how to create an iterator

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

type Visitor

Visitor represents an object that handles each pair in a array

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

type VisitorFunc

VisitorFunc is a type of Visitor based on a function

type VisitorFunc func(int, interface{}) error

func (VisitorFunc) Visit

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