Class GenericSortedViewIterator<T>
- java.lang.Object
-
- org.apache.datasketches.quantilescommon.GenericSortedViewIterator<T>
-
- Type Parameters:
T- The generic quantile type
- All Implemented Interfaces:
SortedViewIterator
- Direct Known Subclasses:
ItemsSketchSortedView.ItemsSketchSortedViewIterator,KllItemsSketchSortedView.KllItemsSketchSortedViewIterator
public class GenericSortedViewIterator<T> extends Object implements SortedViewIterator
The quantiles SortedView Iterator for generic types.- Author:
- Alexander Saydakov, Lee Rhodes
- See Also:
SortedViewIterator
-
-
Constructor Summary
Constructors Constructor Description GenericSortedViewIterator(T[] quantiles, long[] cumWeights)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCumulativeWeight(QuantileSearchCriteria searchCrit)Gets the cumulative weight at the current index (or previous index) based on the chosen search criterion.longgetN()Gets the total count of all items presented to the sketch.doublegetNormalizedRank(QuantileSearchCriteria searchCrit)Gets the normalized rank at the current index (or previous index) based on the chosen search criterion.TgetQuantile()longgetWeight()Gets the natural weight at the current index.booleannext()Advances the index and checks if it is valid.
-
-
-
Constructor Detail
-
GenericSortedViewIterator
public GenericSortedViewIterator(T[] quantiles, long[] cumWeights)
-
-
Method Detail
-
getCumulativeWeight
public long getCumulativeWeight(QuantileSearchCriteria searchCrit)
Description copied from interface:SortedViewIteratorGets the cumulative weight at the current index (or previous index) based on the chosen search criterion. This is also referred to as the "Natural Rank".Don't call this before calling next() for the first time or after getting false from next().
- Specified by:
getCumulativeWeightin interfaceSortedViewIterator- Parameters:
searchCrit- if INCLUSIVE, includes the weight at the current index in the cumulative sum. Otherwise, it will return the cumulative weight of the previous index.- Returns:
- cumulative weight at the current index on the chosen search criterion.
-
getQuantile
public T getQuantile()
-
getN
public long getN()
Description copied from interface:SortedViewIteratorGets the total count of all items presented to the sketch.- Specified by:
getNin interfaceSortedViewIterator- Returns:
- the total count of all items presented to the sketch.
-
getNormalizedRank
public double getNormalizedRank(QuantileSearchCriteria searchCrit)
Description copied from interface:SortedViewIteratorGets the normalized rank at the current index (or previous index) based on the chosen search criterion.Don't call this before calling next() for the first time or after getting false from next().
- Specified by:
getNormalizedRankin interfaceSortedViewIterator- Parameters:
searchCrit- if INCLUSIVE, includes the normalized rank at the current index. Otherwise, returns the normalized rank of the previous index.- Returns:
- the normalized rank at the current index (or previous index) based on the chosen search criterion.
-
getWeight
public long getWeight()
Description copied from interface:SortedViewIteratorGets the natural weight at the current index.Don't call this before calling next() for the first time or after getting false from next().
- Specified by:
getWeightin interfaceSortedViewIterator- Returns:
- the natural weight at the current index.
-
next
public boolean next()
Description copied from interface:SortedViewIteratorAdvances the index and checks if it is valid. The state of this iterator is undefined before the first call of this method.- Specified by:
nextin interfaceSortedViewIterator- Returns:
- true if the next index is valid.
-
-