org.progeeks.util
Class SingletonIterator

java.lang.Object
  extended by org.progeeks.util.SingletonIterator
All Implemented Interfaces:
java.util.Iterator

public class SingletonIterator
extends java.lang.Object
implements java.util.Iterator

Iterator implementation that contains a single object and returns it at the first call to next(). This is lighter weight than creating a singleton set of some other thing just to get an iterator.

Version:
$Revision: 1.1 $
Author:
Paul Speed

Constructor Summary
SingletonIterator(java.lang.Object obj)
           
 
Method Summary
 boolean hasNext()
           
 java.lang.Object next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonIterator

public SingletonIterator(java.lang.Object obj)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator

remove

public void remove()
Specified by:
remove in interface java.util.Iterator


Copyright © 2002-2003 Paul Speed. All Rights Reserved.