mirror of
https://github.com/emirpasic/gods.git
synced 2026-06-15 16:16:35 +03:00
- iterator reset on all structures
This commit is contained in:
@@ -111,6 +111,7 @@ func (stack *Stack) Iterator() Iterator {
|
||||
|
||||
// Next moves the iterator to the next element and returns true if there was a next element in the container.
|
||||
// If Next() returns true, then next element's index and value can be retrieved by Index() and Value().
|
||||
// If Next() was called for the first time, then it will point the iterator to the first element if it exists.
|
||||
// Modifies the state of the iterator.
|
||||
func (iterator *Iterator) Next() bool {
|
||||
if iterator.index < iterator.stack.Size() {
|
||||
@@ -142,6 +143,12 @@ func (iterator *Iterator) Index() int {
|
||||
return iterator.index
|
||||
}
|
||||
|
||||
// Reset sets the iterator to the initial state.
|
||||
// Call Next() to fetch the first element if any.
|
||||
func (iterator *Iterator) Reset() {
|
||||
iterator.index = -1
|
||||
}
|
||||
|
||||
// String returns a string representation of container
|
||||
func (stack *Stack) String() string {
|
||||
str := "ArrayStack\n"
|
||||
|
||||
Reference in New Issue
Block a user