org.apache.mahout.common.iterator
Class ArrayIterator<T>

java.lang.Object
  extended by org.apache.mahout.common.iterator.ArrayIterator<T>
All Implemented Interfaces:
java.lang.Iterable<T>, java.util.Iterator<T>, SkippingIterator<T>

public final class ArrayIterator<T>
extends java.lang.Object
implements SkippingIterator<T>, java.lang.Iterable<T>

Simple, fast Iterator for an array.


Constructor Summary
ArrayIterator(T[] array)
           Creates an over an entire array.
 
Method Summary
 boolean hasNext()
           
 java.util.Iterator<T> iterator()
           
 T next()
           
 void remove()
           
 void skip(int n)
          Skip the next n elements supplied by this Iterator.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArrayIterator

public ArrayIterator(T[] array)

Creates an over an entire array.

Parameters:
array - array to iterate over
Method Detail

hasNext

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

next

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

remove

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

skip

public void skip(int n)
Description copied from interface: SkippingIterator
Skip the next n elements supplied by this Iterator. If there are less than n elements remaining, this skips all remaining elements in the Iterator. This method has the same effect as calling Iterator.next() n times, except that it will never throw NoSuchElementException.

Specified by:
skip in interface SkippingIterator<T>

iterator

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.