|
|
|
@ -28,11 +28,28 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
package containers
|
|
|
|
|
|
|
|
|
|
type Iterator interface {
|
|
|
|
|
// Stateful iterator for ordered containers whose values can be fetched by an index.
|
|
|
|
|
type IteratorWithIndex interface {
|
|
|
|
|
// Moves the iterator to the next element and returns true if there was a next element in the container.
|
|
|
|
|
// Modifies the state of the iterator.
|
|
|
|
|
Next() bool
|
|
|
|
|
// Returns the current element's value.
|
|
|
|
|
// Does not modify the state of the iterator.
|
|
|
|
|
Value() interface{}
|
|
|
|
|
// Returns the current element's index(key).
|
|
|
|
|
Index() interface{}
|
|
|
|
|
// Returns the current element's index.
|
|
|
|
|
// Does not modify the state of the iterator.
|
|
|
|
|
Index() int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stateful iterator for ordered containers whose elements are key value pairs.
|
|
|
|
|
type IteratorWithKey interface {
|
|
|
|
|
// Moves the iterator to the next element and returns true if there was a next element in the container.
|
|
|
|
|
// Modifies the state of the iterator.
|
|
|
|
|
Next() bool
|
|
|
|
|
// Returns the current element's value.
|
|
|
|
|
// Does not modify the state of the iterator.
|
|
|
|
|
Value() interface{}
|
|
|
|
|
// Returns the current element's key.
|
|
|
|
|
// Does not modify the state of the iterator.
|
|
|
|
|
Key() interface{}
|
|
|
|
|
}
|
|
|
|
|