Class SortedFloatsArithmetic
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.sorted.SortedFloatsArithmetic
-
- All Implemented Interfaces:
Floats,SortedFloats
public class SortedFloatsArithmetic extends Object implements SortedFloats
- Author:
- hogye
-
-
Field Summary
Fields Modifier and Type Field Description floathalfVStepintnfloatoneOverVStepfloatv0floatvStep
-
Constructor Summary
Constructors Constructor Description SortedFloatsArithmetic(float v0, float vStep, int n)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BigDecimalbig(float x)ContinuousIndexcontinuousIndexOf(float x)The continuous index at which x falls in this sequence.voidcontinuousIndexOf(float x, ContinuousIndex result)The continuous index at which x falls in this sequence.ContinuousIndexArraycontinuousIndicesIn(SortedFloats xs)Like continuousIndicesOf, but in reverse: for each v in this sequence, the continuous index at which v falls in xs.ContinuousIndexArraycontinuousIndicesOf(Floats xs)For each x in xs, the continuous index at which x falls in this sequence.voidcontinuousIndicesOf(Floats xs, ContinuousIndexArray result)For each x in xs, the continuous index at which x falls in this sequence.ContinuousIndexArraycontinuousIndicesOf(SortedFloats xs)For each x in xs, the continuous index at which x falls in this sequence.voidcontinuousIndicesOf(SortedFloats xs, ContinuousIndexArray result)For each x in xs, the continuous index at which x falls in this sequence.SortedFloatsArithmeticcopy()float[]copyOf()float[]copyOf(int i, int c)voidcopyTo(int i, float[] dest, int iDest, int c)voidcopyTo(int i, FloatBuffer dest, int c)voidcopyTo(FloatBuffer dest)floatfirst()intindexAfter(float x)Smallest index whose value is greater than xintindexAtOrAfter(float x)Smallest index whose value is greater than or equal to xintindexAtOrBefore(float x)Largest index whose value is less than or equal to xintindexBefore(float x)Largest index whose value is less than xintindexNearest(float x)Index of the value closest to x.intindexOf(float x)Follows the convention ofArrays.binarySearch(float[], float): Ifxis contained in this sequence, returns the index ofxOtherwise, returns (-insertionPoint - 1)booleanisEmpty()floatlast()intn()Length of the sequencefloatv(int i)Value at index i
-
-
-
Constructor Detail
-
SortedFloatsArithmetic
public SortedFloatsArithmetic(float v0, float vStep, int n)- Throws:
IllegalArgumentException- ifv0is NaN, orv0is infinite, orvStepis NaN, orvStepis infinite, orvStepis non-positive, ornis negative, or(v0 + (n-1)*vStep)is greater thanFloat.MAX_VALUE
-
-
Method Detail
-
big
public static BigDecimal big(float x)
-
v
public float v(int i)
Description copied from interface:FloatsValue at index i
-
n
public int n()
Description copied from interface:FloatsLength of the sequence
-
copyTo
public void copyTo(int i, float[] dest, int iDest, int c)
-
copyTo
public void copyTo(int i, FloatBuffer dest, int c)
-
copyTo
public void copyTo(FloatBuffer dest)
-
copy
public SortedFloatsArithmetic copy()
- Specified by:
copyin interfaceFloats- Specified by:
copyin interfaceSortedFloats
-
indexOf
public int indexOf(float x)
Description copied from interface:SortedFloatsFollows the convention ofArrays.binarySearch(float[], float):- If
xis contained in this sequence, returns the index ofx - Otherwise, returns (-insertionPoint - 1)
- Specified by:
indexOfin interfaceSortedFloats- See Also:
Arrays.binarySearch(float[], float)
- If
-
indexNearest
public int indexNearest(float x)
Description copied from interface:SortedFloatsIndex of the value closest to x. If the two closest values are x-C and x+C, returns the index of x+C. If floats is empty, returns -1.- Specified by:
indexNearestin interfaceSortedFloats
-
indexBefore
public int indexBefore(float x)
Description copied from interface:SortedFloatsLargest index whose value is less than x- Specified by:
indexBeforein interfaceSortedFloats
-
indexAfter
public int indexAfter(float x)
Description copied from interface:SortedFloatsSmallest index whose value is greater than x- Specified by:
indexAfterin interfaceSortedFloats
-
indexAtOrBefore
public int indexAtOrBefore(float x)
Description copied from interface:SortedFloatsLargest index whose value is less than or equal to x- Specified by:
indexAtOrBeforein interfaceSortedFloats
-
indexAtOrAfter
public int indexAtOrAfter(float x)
Description copied from interface:SortedFloatsSmallest index whose value is greater than or equal to x- Specified by:
indexAtOrAfterin interfaceSortedFloats
-
continuousIndexOf
public void continuousIndexOf(float x, ContinuousIndex result)Description copied from interface:SortedFloatsThe continuous index at which x falls in this sequence.- Specified by:
continuousIndexOfin interfaceSortedFloats- See Also:
ContinuousIndex
-
continuousIndexOf
public ContinuousIndex continuousIndexOf(float x)
Description copied from interface:SortedFloatsThe continuous index at which x falls in this sequence.- Specified by:
continuousIndexOfin interfaceSortedFloats- See Also:
ContinuousIndex
-
continuousIndicesOf
public void continuousIndicesOf(Floats xs, ContinuousIndexArray result)
Description copied from interface:SortedFloatsFor each x in xs, the continuous index at which x falls in this sequence.- Specified by:
continuousIndicesOfin interfaceSortedFloats- See Also:
ContinuousIndexArray
-
continuousIndicesOf
public ContinuousIndexArray continuousIndicesOf(Floats xs)
Description copied from interface:SortedFloatsFor each x in xs, the continuous index at which x falls in this sequence.- Specified by:
continuousIndicesOfin interfaceSortedFloats- See Also:
com.metsci.tracks.ContinuousIndexArray
-
continuousIndicesOf
public void continuousIndicesOf(SortedFloats xs, ContinuousIndexArray result)
Description copied from interface:SortedFloatsFor each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster thanSortedFloats.continuousIndicesOf(Floats, ContinuousIndexArray)in some implementations.- Specified by:
continuousIndicesOfin interfaceSortedFloats- See Also:
ContinuousIndexArray
-
continuousIndicesOf
public ContinuousIndexArray continuousIndicesOf(SortedFloats xs)
Description copied from interface:SortedFloatsFor each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster thanSortedFloats.continuousIndicesOf(Floats)in some implementations.- Specified by:
continuousIndicesOfin interfaceSortedFloats- See Also:
ContinuousIndexArray
-
continuousIndicesIn
public ContinuousIndexArray continuousIndicesIn(SortedFloats xs)
Like continuousIndicesOf, but in reverse: for each v in this sequence, the continuous index at which v falls in xs. This may be faster than continuousIndicesOf when going from a sparser sequence to a dense arithmetic sequence.
-
-