com.evanmclean.evlib.util
Class ArrayListIterator<T>

java.lang.Object
  extended by com.evanmclean.evlib.util.ArrayListIterator<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterator<T>, ListIterator<T>

public class ArrayListIterator<T>
extends Object
implements ListIterator<T>

A (list) iterator over an array of any objects.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Constructor Summary
ArrayListIterator(T... arr)
           
ArrayListIterator(T[] arr, int start_index, int end_index)
           
ArrayListIterator(T[] arr, int start_index, int end_index, int initial_index)
           
 
Method Summary
 void add(T obj)
          Always throws UnsupportedOperationException.
static
<T> ArrayListIterator<T>
create(T... arr)
           
static
<T> ArrayListIterator<T>
create(T[] arr, int start_index, int end_index)
           
static
<T> ArrayListIterator<T>
create(T[] arr, int start_index, int end_index, int initial_index)
           
 boolean hasNext()
           
 boolean hasPrevious()
           
 T next()
           
 int nextIndex()
           
 T previous()
           
 int previousIndex()
           
 void remove()
          Always throws UnsupportedOperationException.
 void set(T obj)
          Replaces the last element in the array returned by next or previous with the specified element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayListIterator

public ArrayListIterator(T... arr)

ArrayListIterator

public ArrayListIterator(T[] arr,
                         int start_index,
                         int end_index)

ArrayListIterator

public ArrayListIterator(T[] arr,
                         int start_index,
                         int end_index,
                         int initial_index)
Method Detail

create

public static <T> ArrayListIterator<T> create(T... arr)

create

public static <T> ArrayListIterator<T> create(T[] arr,
                                              int start_index,
                                              int end_index)

create

public static <T> ArrayListIterator<T> create(T[] arr,
                                              int start_index,
                                              int end_index,
                                              int initial_index)

add

public void add(T obj)
Always throws UnsupportedOperationException.

Specified by:
add in interface ListIterator<T>
Parameters:
obj -
Throws:
UnsupportedOperationException

hasNext

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

hasPrevious

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

next

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

nextIndex

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

previous

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

previousIndex

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

remove

public void remove()
Always throws UnsupportedOperationException.

Specified by:
remove in interface Iterator<T>
Specified by:
remove in interface ListIterator<T>
Throws:
UnsupportedOperationException

set

public void set(T obj)
Replaces the last element in the array returned by next or previous with the specified element. If

Specified by:
set in interface ListIterator<T>
Parameters:
obj - The object (may be null) to replace the corresponding entry in the array.
Throws:
IllegalStateException - if neither next() or previous() have been called.