net.sf.jga.util
Class ArrayIterator<T>

java.lang.Object
  extended by net.sf.jga.util.ArrayIterator<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Iterator<T>, java.util.ListIterator<T>

public class ArrayIterator<T>
extends java.lang.Object
implements java.util.ListIterator<T>, java.lang.Iterable<T>

Iterates over an array of objects. Not safe for use by multiple threads.

Copyright © 2005 David A. Hall

Author:
David A. Hall

Constructor Summary
ArrayIterator(T[] array)
          Builds an ArrayIterator for the given array
 
Method Summary
 void add(T value)
           
 boolean hasNext()
           
 boolean hasPrevious()
           
static
<E> ArrayIterator<E>
iterate(E[] arr)
          Produce an ArrayIterator over the given array.
 java.util.Iterator<T> iterator()
           
 T next()
           
 int nextIndex()
           
 T previous()
           
 int previousIndex()
           
 void remove()
           
 void set(T value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayIterator

public ArrayIterator(T[] array)
Builds an ArrayIterator for the given array

Method Detail

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator<T>
Specified by:
hasNext in interface java.util.ListIterator<T>

hasPrevious

public boolean hasPrevious()
Specified by:
hasPrevious in interface java.util.ListIterator<T>

nextIndex

public int nextIndex()
Specified by:
nextIndex in interface java.util.ListIterator<T>

previousIndex

public int previousIndex()
Specified by:
previousIndex in interface java.util.ListIterator<T>

next

public T next()
Specified by:
next in interface java.util.Iterator<T>
Specified by:
next in interface java.util.ListIterator<T>

previous

public T previous()
Specified by:
previous in interface java.util.ListIterator<T>

set

public void set(T value)
Specified by:
set in interface java.util.ListIterator<T>

add

public void add(T value)
Specified by:
add in interface java.util.ListIterator<T>

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<T>
Specified by:
remove in interface java.util.ListIterator<T>

iterate

public static <E> ArrayIterator<E> iterate(E[] arr)
Produce an ArrayIterator over the given array.



Copyright © 2002-2005 David A. Hall. All Rights Reserved.