the FlatArrayIterator has been moved to the new file iter-list.go

This commit is contained in:
2024-04-26 04:30:43 +02:00
parent ebb2811ed3
commit 7941c2dfec
2 changed files with 43 additions and 30 deletions
+1 -30
View File
@@ -4,37 +4,8 @@
// iterator.go
package expr
import "io"
type Iterator interface {
Reset()
Next() (item any, err error) // must return io.EOF after the last item
Current() (item any, err error)
Index() int
}
type FlatArrayIterator struct {
a []any
index int
}
func NewFlatArrayIterator(array []any) *FlatArrayIterator {
return &FlatArrayIterator{a: array, index: 0}
}
func (it *FlatArrayIterator) Reset() {
it.index = 0
}
func (it *FlatArrayIterator) Next() (item any, err error) {
if it.index < len(it.a) {
item = it.a[it.index]
it.index++
} else {
err = io.EOF
}
return
}
func (it *FlatArrayIterator) Index() int {
return it.index - 1
}