mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-15 16:16:35 +03:00
- iterator end on reverse-iterable data structures
This commit is contained in:
@@ -149,6 +149,12 @@ func (iterator *Iterator) Begin() {
|
||||
iterator.index = -1
|
||||
}
|
||||
|
||||
// End moves the iterator past the last element (one-past-the-end).
|
||||
// Call Prev() to fetch the last element if any.
|
||||
func (iterator *Iterator) End() {
|
||||
iterator.index = iterator.stack.Size()
|
||||
}
|
||||
|
||||
// First moves the iterator to the first element and returns true if there was a first element in the container.
|
||||
// If First() returns true, then first element's index and value can be retrieved by Index() and Value().
|
||||
// Modifies the state of the iterator.
|
||||
@@ -161,7 +167,7 @@ func (iterator *Iterator) First() bool {
|
||||
// If Last() returns true, then last element's index and value can be retrieved by Index() and Value().
|
||||
// Modifies the state of the iterator.
|
||||
func (iterator *Iterator) Last() bool {
|
||||
iterator.index = iterator.stack.Size()
|
||||
iterator.End()
|
||||
return iterator.Prev()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user