mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-30 09:33:36 +00:00
2130e17f0c
Map iterator now returns key-value pair, while array/byte-array iterators work like old enumerators. Follow neo-project/neo#2190.
23 lines
651 B
Go
23 lines
651 B
Go
package iterator
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
|
)
|
|
|
|
// Create creates an iterator from array-like or map stack item.
|
|
func Create(ic *interop.Context) error {
|
|
return vm.IteratorCreate(ic.VM)
|
|
}
|
|
|
|
// Next advances the iterator, pushes true on success and false otherwise.
|
|
func Next(ic *interop.Context) error {
|
|
return vm.IteratorNext(ic.VM)
|
|
}
|
|
|
|
// Value returns current iterator value and depends on iterator type:
|
|
// For slices the result is just value.
|
|
// For maps the result is key-value pair packed in a struct.
|
|
func Value(ic *interop.Context) error {
|
|
return vm.IteratorValue(ic.VM)
|
|
}
|