-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I set iterator index? #95
Comments
Not at the moment, but somebody proposed something interesting: All three, including yourself, are asking for the same thing more or less, i.e. the ability to get the iterator from a specific location. For key-value structures that's the key, for others perhaps the index. Not sure if I will call it |
I think making setter method in iterator is better than |
@mcauto I don't have a strong opinion on either. so |
#189 Implements the NextTo iterator function. @mcauto please let me know if the below implements the requested functionality so that I can reopen this issue: seek := func(index int, value interface{}) bool {
return index == 3
}
for found := it.NextTo(seek); found; found = it.Next() {
index, value := it.Index(), it.Value()
} PS. I hope that this NextTo function can support the requested functionality rather than adding more functions (SetIndex and SetKey). The reason is to keep GoDS as minimal as possible and yet flexible. But please let me know if it is not what you asked for and I'll reevaluate again, adding SetIndex and SetKey is simple |
The text was updated successfully, but these errors were encountered: