Iterators: Removed NewAnyIterator(), added NewIterator()
This commit is contained in:
+8
-8
@@ -70,7 +70,7 @@ func NewDictIterator(dict *DictType, args []any) (it *DictIterator, err error) {
|
||||
var s string
|
||||
var argAny any
|
||||
|
||||
it = &DictIterator{a: dict, count: 0, index: -1, keys: nil, iterMode: dictIterModeKeys}
|
||||
dictIt := &DictIterator{a: dict, count: 0, index: -1, keys: nil, iterMode: dictIterModeKeys}
|
||||
if len(args) > 0 {
|
||||
argAny = args[0]
|
||||
} else {
|
||||
@@ -100,13 +100,13 @@ func NewDictIterator(dict *DictType, args []any) (it *DictIterator, err error) {
|
||||
if s, err = ToGoString(argAny, "iteration mode"); err == nil {
|
||||
switch strings.ToLower(s) {
|
||||
case "k", "key", "keys":
|
||||
it.iterMode = dictIterModeKeys
|
||||
dictIt.iterMode = dictIterModeKeys
|
||||
case "v", "value", "values":
|
||||
it.iterMode = dictIterModeValues
|
||||
dictIt.iterMode = dictIterModeValues
|
||||
case "i", "item", "items":
|
||||
it.iterMode = dictIterModeItems
|
||||
dictIt.iterMode = dictIterModeItems
|
||||
case "", "default":
|
||||
it.iterMode = dictIterModeKeys
|
||||
dictIt.iterMode = dictIterModeKeys
|
||||
default:
|
||||
err = fmt.Errorf("invalid iteration mode %q", s)
|
||||
}
|
||||
@@ -114,8 +114,8 @@ func NewDictIterator(dict *DictType, args []any) (it *DictIterator, err error) {
|
||||
}
|
||||
}
|
||||
|
||||
it.makeKeys(*dict, sortType)
|
||||
return
|
||||
dictIt.makeKeys(*dict, sortType)
|
||||
return dictIt, err
|
||||
}
|
||||
|
||||
func NewMapIterator(m map[any]any) (it *DictIterator) {
|
||||
@@ -129,7 +129,7 @@ func (it *DictIterator) String() string {
|
||||
if it.a != nil {
|
||||
l = len(*it.a)
|
||||
}
|
||||
return fmt.Sprintf("$(#%d)", l)
|
||||
return fmt.Sprintf("$({#%d})", l)
|
||||
}
|
||||
|
||||
func (it *DictIterator) TypeName() string {
|
||||
|
||||
Reference in New Issue
Block a user