com.aliasi.util
Class Iterators.PrimitiveInt

java.lang.Object
  extended by com.aliasi.util.Iterators.PrimitiveInt
All Implemented Interfaces:
Iterator<Integer>
Enclosing class:
Iterators

public abstract static class Iterators.PrimitiveInt
extends Object
implements Iterator<Integer>

A Iterators.PrimitiveInt is an integer iterator that also allows objects to be accessed as primitive int values.

The method next() returns an Integer, whereas nextPrimitive() returns a primitive int value. Using either one will advanced the iterator to the next element.

Implementation Note: Using the standard iterator implementation as Integer requires boxing of the primitive values as objects. Therefore, use the method nextPrimitive() wherever possible.

Since:
Lingpipe3.8
Version:
3.8
Author:
Mike Ross, Bob Carpenter

Constructor Summary
Iterators.PrimitiveInt()
           
 
Method Summary
abstract  boolean hasNext()
          Returns true if there is another integer in the iteration.
 Integer next()
          Returns the next integer result.
abstract  int nextPrimitive()
          Returns the next primitive integer.
 void remove()
          Throws unsupported operation exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Iterators.PrimitiveInt

public Iterators.PrimitiveInt()
Method Detail

nextPrimitive

public abstract int nextPrimitive()
Returns the next primitive integer.

Returns:
The next primitive integer.

hasNext

public abstract boolean hasNext()
Returns true if there is another integer in the iteration.

Specified by:
hasNext in interface Iterator<Integer>
Returns:
true if there is another integer in the iteration.

remove

public void remove()
Throws unsupported operation exception.

Specified by:
remove in interface Iterator<Integer>
Throws:
UnsupportedOperationException - Always.

next

public Integer next()
Returns the next integer result.

Implementation Note: Requires boxing the primitive int returned by nextPrimitive().

Specified by:
next in interface Iterator<Integer>
Returns:
The next integer.