- iterator last on all structures with reversible iterators

This commit is contained in:
Emir Pasic
2016-06-26 22:27:08 +02:00
parent 3a938233a0
commit f8b0747409
8 changed files with 74 additions and 2 deletions
+8
View File
@@ -149,6 +149,14 @@ func (iterator *Iterator) Reset() {
iterator.index = -1
}
// Last moves the iterator to the last element and returns true if there was a last element in the container.
// 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()
return iterator.Prev()
}
// String returns a string representation of container
func (stack *Stack) String() string {
str := "ArrayStack\n"