T
- an item of type Tpublic class VarOptItemsSamples<T> extends Object implements Iterable<VarOptItemsSamples.WeightedSample>
Iterator
over WeightedSample
objects which can can be used to
access both the items and weights in the sample, and which avoids copying data from the
sketch.If using getters with a sketch storing heterogeneous items from a polymorphic base class, you
must call setClass()
prior to calling one of the getter methods. This is not
necessary if using the iterator.
The class also implements Iterable
to allow the use of forEach loops for
convenience.
Modifier and Type | Class and Description |
---|---|
class |
VarOptItemsSamples.VarOptItemsIterator
The standard iterator
|
class |
VarOptItemsSamples.WeightedSample
A convenience class to allow easy iterator access to a VarOpt sample.
|
Modifier and Type | Method and Description |
---|---|
int |
getNumSamples()
Returns the length Copies items and weights from the sketch, if necessary, and returns the
length of
any
resulting array.
|
T[] |
items()
Returns a shallow copy of the array of sample items contained in the sketch.
|
T |
items(int i)
Returns a single item from the samples contained in the sketch.
|
Iterator<VarOptItemsSamples.WeightedSample> |
iterator() |
void |
setClass(Class<?> clazz)
Specifies the class to use when copying the item array from the sketch.
|
double[] |
weights()
Returns a copy of the array of weights contained in the sketch.
|
double |
weights(int i)
Returns a single weight from the samples contained in the sketch.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public Iterator<VarOptItemsSamples.WeightedSample> iterator()
iterator
in interface Iterable<VarOptItemsSamples.WeightedSample>
public void setClass(Class<?> clazz)
Number
s.clazz
- The class to use when creating the item array resultpublic int getNumSamples()
public T[] items()
public T items(int i)
i
- An index into the list of samplesi
public double[] weights()
public double weights(int i)
i
- An index into the list of weightsi
Copyright © 2015–2022 The Apache Software Foundation. All rights reserved.