|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Infinite is an empty interface which informs the optimizer that
an Iterator will -- or may -- never end. You can then
safely write code like
class MultiplesOf implements Iterator {
int i, n;
MultiplesOf(int n) {
this.n = n;
this.i = 0;
}
public boolean hasNext() {
return true;
}
public Object next() {
return i += n;
}
public void remove() {
throw new UnsupportedOperationException();
}
};
Iterator tens = (select from new MultiplesOf(2) as twos where twos % 5 == 0);
and be sure that the optimizer will not try to do anything
silly like writing the contents to an intermediate array.
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||