From e64347994d0b65c133c6969b452ea3887d074bfb Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 24 Sep 2015 13:18:56 -0400 Subject: [PATCH] lib/core/collection: add start so iterators are usable with `with` Signed-off-by: Jean Privat --- lib/core/collection/abstract_collection.nit | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/core/collection/abstract_collection.nit b/lib/core/collection/abstract_collection.nit index 5192797..aca4fdc 100644 --- a/lib/core/collection/abstract_collection.nit +++ b/lib/core/collection/abstract_collection.nit @@ -228,6 +228,16 @@ interface Iterator[E] # Iterate over `self` fun iterator: Iterator[E] do return self + # Pre-iteration hook. + # + # Used to inform `self` that the iteration is starting. + # Specific iterators can use this to prepare some resources. + # + # Is automatically invoked at the beginning of `for` structures. + # + # Do nothing by default. + fun start do end + # Post-iteration hook. # # Used to inform `self` that the iteration is over. @@ -708,6 +718,16 @@ interface MapIterator[K, V] # Set a new `item` at `key`. #fun item=(item: E) is abstract + # Pre-iteration hook. + # + # Used to inform `self` that the iteration is starting. + # Specific iterators can use this to prepare some resources. + # + # Is automatically invoked at the beginning of `for` structures. + # + # Do nothing by default. + fun start do end + # Post-iteration hook. # # Used to inform `self` that the iteration is over. -- 1.7.9.5