mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
core,vm: remove System.Enumerator.*
interops
Map iterator now returns key-value pair, while array/byte-array iterators work like old enumerators. Follow neo-project/neo#2190.
This commit is contained in:
parent
d04b000748
commit
2130e17f0c
16 changed files with 86 additions and 422 deletions
|
@ -3,8 +3,6 @@ Package iterator provides functions to work with Neo iterators.
|
|||
*/
|
||||
package iterator
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/interop/enumerator"
|
||||
|
||||
// Iterator represents a Neo iterator, it's an opaque data structure that can
|
||||
// be properly created by Create or storage.Find. Unlike enumerators, iterators
|
||||
// range over key-value pairs, so it's convenient to use them for maps. This
|
||||
|
@ -19,37 +17,17 @@ func Create(items interface{}) Iterator {
|
|||
return Iterator{}
|
||||
}
|
||||
|
||||
// Key returns iterator's key at current position. It's only valid to call after
|
||||
// successful Next call. This function uses `System.Iterator.Key` syscall.
|
||||
func Key(it Iterator) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Keys returns Enumerator ranging over keys or the given Iterator. Note that
|
||||
// this Enumerator is actually directly tied to the underlying Iterator, so that
|
||||
// advancing it with Next will actually advance the Iterator too. This function
|
||||
// uses `System.Iterator.Keys` syscall.
|
||||
func Keys(it Iterator) enumerator.Enumerator {
|
||||
return enumerator.Enumerator{}
|
||||
}
|
||||
|
||||
// Next advances the iterator returning true if it is was successful (and you
|
||||
// can use Key or Value) and false otherwise (and there are no more elements in
|
||||
// this Iterator). This function uses `System.Enumerator.Next` syscall.
|
||||
// this Iterator). This function uses `System.Iterator.Next` syscall.
|
||||
func Next(it Iterator) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Value returns iterator's current value. It's only valid to call after
|
||||
// successful Next call. This function uses `System.Enumerator.Value` syscall.
|
||||
// successful Next call. This function uses `System.Iterator.Value` syscall.
|
||||
// For slices the result is just value.
|
||||
// For maps the result can be casted to a slice of 2 elements: key and value.
|
||||
func Value(it Iterator) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Values returns Enumerator ranging over values or the given Iterator. Note that
|
||||
// this Enumerator is actually directly tied to the underlying Iterator, so that
|
||||
// advancing it with Next will actually advance the Iterator too. This function
|
||||
// uses `System.Iterator.Values` syscall.
|
||||
func Values(it Iterator) enumerator.Enumerator {
|
||||
return enumerator.Enumerator{}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue