SoftNet-Consult Java Utility Library

com.softnetConsult.utils.collections
Class ArrayIterator<ET>

java.lang.Object
  extended by com.softnetConsult.utils.collections.ArrayIterator<ET>
Type Parameters:
ET - Type of objects over which this iterator iterates.
All Implemented Interfaces:
java.util.Iterator<ET>

public class ArrayIterator<ET>
extends java.lang.Object
implements java.util.Iterator<ET>

Implements an iterator over an array.

This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.

File: AttayIterator.java
Library API version: "2.02"
Java compliance version: "1.5"

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:

1. Redistributions of source code must retain the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library project and its contributors.

THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version:
"2.02"
Author:
Greg Paperin (http://www.paperin.org)

Field Summary
private  ET[] array
          Array being iterated.
private  int cursor
          Cursor into the array.
 
Constructor Summary
ArrayIterator(AET[] array)
          Creates an array iterator over the specified array.
 
Method Summary
 boolean hasNext()
          Returns true if this iteration has more elements.
 ET next()
          Returns the next element in this iteration.
 void remove()
          Removing of array elements is obviously not supported.
 void restart()
          Resets the internal cursor of this iterator to point to the start of the unederlying array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

private ET[] array
Array being iterated.


cursor

private int cursor
Cursor into the array.

Constructor Detail

ArrayIterator

public ArrayIterator(AET[] array)
Creates an array iterator over the specified array.

Type Parameters:
AET - The array may contain objects of any class which is a subclass to the parameter type of this iterator.
Parameters:
array - Array to be iterated.
Method Detail

hasNext

public boolean hasNext()
Returns true if this iteration has more elements.

Specified by:
hasNext in interface java.util.Iterator<ET>
Returns:
true if next() would return an element rather than throwing an exception, false otherwise.

next

public ET next()
Returns the next element in this iteration.

Specified by:
next in interface java.util.Iterator<ET>
Returns:
The next element in this iteration.
Throws:
java.util.NoSuchElementException - If this iteration has no more elements.

remove

public void remove()
Removing of array elements is obviously not supported.

Specified by:
remove in interface java.util.Iterator<ET>
Throws:
java.lang.UnsupportedOperationException - is always thrown.

restart

public void restart()
Resets the internal cursor of this iterator to point to the start of the unederlying array. This method allows traversing an array several times using the same iterator.


SoftNet-Consult Java Utility Library is a member of SourceForge.net