saffron.runtime
Interface Infinite


public interface Infinite

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.

Since:
26 April, 2002
Version:
$Id: //open/saffron/src/main/saffron/runtime/Infinite.java#1 $
Author:
jhyde


SourceForge.net_Logo