## org.apache.cassandra.utils
Class ReducingIterator<T1,T2>

    java.lang.Object
      com.google.common.collect.UnmodifiableIterator<T>
          com.google.common.collect.AbstractIterator<T2>
              org.apache.cassandra.utils.ReducingIterator<T1,T2>

All Implemented Interfaces:
  java.lang.Iterable<T2>, java.util.Iterator<T2>

Direct Known Subclasses:
  CompactionIterator

    public abstract class ReducingIterator<T1,T2>

extends com.google.common.collect.AbstractIterator<T2>
implements java.util.Iterator<T2>, java.lang.Iterable<T2>

reduces equal values from the source iterator to a single (optionally transformed) instance.

Field Summary
`protected T1` `last`
`protected java.util.Iterator<T1>` `source`

Constructor Summary
`ReducingIterator(java.util.Iterator<T1> source)`

Method Summary
`protected T2` `computeNext()`
`protected abstract T2` `getReduced()` return the last object computed by reduce
`protected boolean` `isEqual(T1 o1, T1 o2)` override this if the keys you want to base the reduce on are not the same as the object itself (but can be generated from it)
`java.util.Iterator<T2>` `iterator()`
`abstract void` `reduce(T1 current)` combine this object with the previous ones.

Methods inherited from class com.google.common.collect.AbstractIterator
`endOfData, hasNext, next, peek`

Methods inherited from class com.google.common.collect.UnmodifiableIterator
`remove`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface java.util.Iterator
`hasNext, next, remove`

Field Detail

### source

    protected java.util.Iterator<T1> source

### last

    protected T1 last

Constructor Detail

### ReducingIterator

    public ReducingIterator(java.util.Iterator<T1> source)

Method Detail

### reduce

    public abstract void reduce(T1 current)

  combine this object with the previous ones. intermediate state is up to your implementation.

### getReduced

    protected abstract T2 getReduced()

  return the last object computed by reduce

### isEqual

    protected boolean isEqual(T1 o1,
                              T1 o2)

  override this if the keys you want to base the reduce on are not the same as the object itself (but can be generated from it)

### computeNext

    protected T2 computeNext()

  Specified by:
    `computeNext` in class `com.google.common.collect.AbstractIterator<T2>`

### iterator

    public java.util.Iterator<T2> iterator()

  Specified by:
    `iterator` in interface `java.lang.Iterable<T2>`

Copyright © 2010 The Apache Software Foundation