edu.stanford.nlp.util
Class IterableIterator<E>

java.lang.Object
  extended by edu.stanford.nlp.util.IterableIterator<E>
All Implemented Interfaces:
Iterable<E>, Iterator<E>

public class IterableIterator<E>
extends Object
implements Iterator<E>, Iterable<E>

This cures a pet peeve of mine: that you can't use an Iterator directly in Java 5's foreach construct. Well, this one you can, dammit.

Author:
Bill MacCartney

Constructor Summary
IterableIterator(Iterator<E> it)
           
 
Method Summary
 boolean hasNext()
           
 Iterator<E> iterator()
           
static void main(String[] args)
           
 E next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterableIterator

public IterableIterator(Iterator<E> it)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>

next

public E next()
Specified by:
next in interface Iterator<E>

remove

public void remove()
Specified by:
remove in interface Iterator<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>

main

public static void main(String[] args)


Stanford NLP Group