org.apache.mahout.cf.taste.impl.common
Class SamplingLongPrimitiveIterator

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.common.AbstractLongPrimitiveIterator
      extended by org.apache.mahout.cf.taste.impl.common.SamplingLongPrimitiveIterator
All Implemented Interfaces:
java.util.Iterator<java.lang.Long>, LongPrimitiveIterator, SkippingIterator<java.lang.Long>

public final class SamplingLongPrimitiveIterator
extends AbstractLongPrimitiveIterator

Wraps an Iterator and returns only some subset of the elements that it would, as determined by a sampling rate parameter.


Constructor Summary
SamplingLongPrimitiveIterator(LongPrimitiveIterator delegate, double samplingRate)
           
 
Method Summary
 boolean hasNext()
           
static LongPrimitiveIterator maybeWrapIterator(LongPrimitiveIterator delegate, double samplingRate)
           
 long nextLong()
           
 long peek()
           
 void remove()
           
 void skip(int n)
          Skip the next n elements supplied by this Iterator.
 
Methods inherited from class org.apache.mahout.cf.taste.impl.common.AbstractLongPrimitiveIterator
next
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SamplingLongPrimitiveIterator

public SamplingLongPrimitiveIterator(LongPrimitiveIterator delegate,
                                     double samplingRate)
Method Detail

hasNext

public boolean hasNext()

nextLong

public long nextLong()
Returns:
next long in iteration

peek

public long peek()
Returns:
next long in iteration without advancing iteration

remove

public void remove()
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.


maybeWrapIterator

public static LongPrimitiveIterator maybeWrapIterator(LongPrimitiveIterator delegate,
                                                      double samplingRate)


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