Iterator interface for more than one return value.
The Java standard
Iterator
interface has some drawbacks:
- the only way to get the current value is to advance the iterator
- the iterator can only point to a single value
- the iterator can only return objects, not primitives
This iterator interface is a bit more flexible. For example on a distance
list, we can have a single type of iterator that allows access to the
distance, the object ID or the combination of both.
In some situations, this can save the creation of many small objects, which
put load on the garbage collector. This super interface does not have a "get"
operation, which is to come from specialized interfaces instead.
Usage example:
for (Iter iter = ids.iter(); iter.valid(); iter.advance()) {
iter.doSomething();
}