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:
Iterator<Long>, LongPrimitiveIterator, SkippingIterator<Long>

public final class SamplingLongPrimitiveIterator
extends AbstractLongPrimitiveIterator

Wraps a LongPrimitiveIterator 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)
           
SamplingLongPrimitiveIterator(RandomWrapper random, 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)

SamplingLongPrimitiveIterator

public SamplingLongPrimitiveIterator(RandomWrapper random,
                                     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:
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–2014 The Apache Software Foundation. All rights reserved.