becker.robots
Interface IIterate<Element>
- All Superinterfaces:
- Iterable<Element>, Iterator<Element>
public interface IIterate<Element>
- extends Iterator<Element>, Iterable<Element>
The IIterate
interface allows the same method to provide an iterator
and to be used in a foreach loop. For example, an intersection has a
method, examineThings()
that returns an object implementing
IIterate
. It can be used as
Iterator things = anIntersection.examineThings();
while(things.hasNext())
{ Thing t = things.next();
// do something with t
}
as well as
for(Thing t : anIntersection.examineThings())
{ // do something with t
}
- Author:
- Byron Weber Becker