net.sf.saffron.runtime
Interface Iterable

All Known Implementing Classes:
BufferedIterator, ThreadIterator

public interface Iterable

An object is Iterable if it has an iterator() method to create an Iterator over its elements.

Some implementations of this interface may allow only one iterator at a time. For example, BufferedIterator simply restarts and returns itself. Iterators received from previous calls to iterator() will also restart.

If an object implements this interface, it can be used as a relation in a saffron relational expression. For example,

Iterable iterable = new Iterable() {
     public Iterator iterator() {
         ArrayList list = new ArrayList();
         list.add(new Integer(1));
         list.add(new Integer(2));
         return list.iterator();
     }
 };
 for (i in (Integer[]) iterable) {
     print(i.intValue());
 }

Since:
1 May, 2002
Version:
$Id: //open/saffron/src/net/sf/saffron/runtime/Iterable.java#2 $
Author:
jhyde

Method Summary
 Iterator iterator()
          Returns an iterator over the elements in this collection.
 

Method Detail

iterator

public Iterator iterator()
Returns an iterator over the elements in this collection. There are no guarantees over the order in which the elements are returned.

If this method is called twice on the same object, and the object is not modified in between times, the iterators produced may or may not be the same iterator, and may or may not return the elements in the same order, but must return the same objects.


SourceForge.net_Logo