Package cern.jet.stat.quantile
Class DoubleBufferSet
java.lang.Object
cern.colt.PersistentObject
cern.jet.stat.quantile.BufferSet
cern.jet.stat.quantile.DoubleBufferSet
- All Implemented Interfaces:
Serializable
,Cloneable
A set of buffers holding double elements; internally used for computing approximate quantiles.
-
Field Summary
FieldsFields inherited from class cern.colt.PersistentObject
serialVersionUID
-
Constructor Summary
ConstructorsConstructorDescriptionDoubleBufferSet
(int b, int k) Constructs a buffer set with b buffers, each having k elements -
Method Summary
Modifier and TypeMethodDescriptionReturns an empty buffer if at least one exists.Returns all full or partial buffers._getFullOrPartialBuffersWithLevel
(int level) Determines all full buffers having the specified level.int
int
Returns the number of empty buffers.Returns all empty buffers.int
b()
void
clear()
Removes all elements from the receiver.protected void
clear
(int k) Removes all elements from the receiver.clone()
Returns a deep copy of the receiver.collapse
(DoubleBuffer[] buffers) Collapses the specified full buffers (must not include partial buffer).boolean
contains
(double element) Returns whether the specified element is contained in the receiver.boolean
forEach
(DoubleProcedure procedure) Applies a procedure to each element of the receiver, if any.protected double[]
getValuesAtPositions
(DoubleBuffer[] buffers, long[] triggerPositions) Determines all values of the specified buffers positioned at the specified triggerPositions within the sorted sequence and fills them into outputValues.int
k()
long
memory()
Returns the number of elements currently needed to store all contained elements.protected long
nextTriggerPosition
(int j, long W) Computes the next triggerPosition for collapsedouble
phi
(double element) Returns how many percent of the elements contained in the receiver are <= element.toString()
long
Returns the number of elements in all buffers.
-
Field Details
-
buffers
-
nextTriggerCalculationState
private boolean nextTriggerCalculationState
-
-
Constructor Details
-
DoubleBufferSet
public DoubleBufferSet(int b, int k) Constructs a buffer set with b buffers, each having k elements- Parameters:
b
- the number of buffersk
- the number of elements per buffer
-
-
Method Details
-
_getFirstEmptyBuffer
Returns an empty buffer if at least one exists. Preferably returns a buffer which has already been used, i.e. a buffer which has already been allocated. -
_getFullOrPartialBuffers
Returns all full or partial buffers. -
_getFullOrPartialBuffersWithLevel
Determines all full buffers having the specified level.- Returns:
- all full buffers having the specified level
-
_getMinLevelOfFullOrPartialBuffers
public int _getMinLevelOfFullOrPartialBuffers()- Returns:
- The minimum level of all buffers which are full.
-
_getNumberOfEmptyBuffers
public int _getNumberOfEmptyBuffers()Returns the number of empty buffers. -
_getPartialBuffer
Returns all empty buffers. -
b
public int b()- Returns:
- the number of buffers
-
clear
public void clear()Removes all elements from the receiver. The receiver will be empty after this call returns, and its memory requirements will be close to zero. -
clear
protected void clear(int k) Removes all elements from the receiver. The receiver will be empty after this call returns, and its memory requirements will be close to zero. -
clone
Returns a deep copy of the receiver.- Overrides:
clone
in classPersistentObject
- Returns:
- a deep copy of the receiver.
-
collapse
Collapses the specified full buffers (must not include partial buffer).- Parameters:
buffers
- the buffers to be collapsed (all of them must be full or partially full)- Returns:
- a full buffer containing the collapsed values. The buffer has accumulated weight.
-
contains
public boolean contains(double element) Returns whether the specified element is contained in the receiver. -
forEach
Applies a procedure to each element of the receiver, if any. Iterates over the receiver in no particular order.- Parameters:
procedure
- the procedure to be applied. Stops iteration if the procedure returns false, otherwise continues.
-
getValuesAtPositions
Determines all values of the specified buffers positioned at the specified triggerPositions within the sorted sequence and fills them into outputValues.- Parameters:
buffers
- the buffers to be searched (all must be full or partial)triggerPositions
- the positions of elements within the sorted sequence to be retrieved- Returns:
- outputValues a list filled with the values at triggerPositions
-
k
public int k()- Returns:
- the number of elements within a buffer.
-
memory
public long memory()Returns the number of elements currently needed to store all contained elements. -
nextTriggerPosition
protected long nextTriggerPosition(int j, long W) Computes the next triggerPosition for collapse- Parameters:
j
- specifies that the j-th trigger position is to be computedW
- the accumulated weights- Returns:
- the next triggerPosition for collapse
-
phi
public double phi(double element) Returns how many percent of the elements contained in the receiver are <= element. Does linear interpolation if the element is not contained but lies in between two contained elements.- Parameters:
the
- element to search for.- Returns:
- the percentage p of elements <= element (0.0 <= p <=1.0).
-
toString
-
totalSize
public long totalSize()Returns the number of elements in all buffers.
-