Class SortedFloatsArray
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.FloatsArray
-
- com.metsci.glimpse.util.primitives.sorted.SortedFloatsArray
-
- All Implemented Interfaces:
Floats,FloatsModifiable,SortedFloats,SortedFloatsModifiable
public class SortedFloatsArray extends FloatsArray implements SortedFloatsModifiable
- Author:
- hogye
-
-
Field Summary
-
Fields inherited from class com.metsci.glimpse.util.primitives.FloatsArray
a, n
-
-
Constructor Summary
Constructors Constructor Description SortedFloatsArray()SortedFloatsArray(float[] a)If the values ofaare not in ascending order, the behavior of this instance is undefined.SortedFloatsArray(float[] a, int n)If the values ofaare not in ascending order, the behavior of this instance is undefined.SortedFloatsArray(int n)SortedFloatsArray(Floats xs)If the values ofxsare not in ascending order, the behavior of this instance is undefined.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intadd(float v)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.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.SortedFloatsArraycopy()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)-
Methods inherited from class com.metsci.glimpse.util.primitives.FloatsArray
append, append, append, append, append, append, append, clear, compact, copyOf, copyOf, copyTo, copyTo, copyTo, ensureCapacity, first, insert, insert, insert, insert, insert, insert, insert, isEmpty, last, n, newArray, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepForAppend, prepForInsert, prepForPrepend, remove, removeIndex, removeRange, set, set, set, v
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.metsci.glimpse.util.primitives.Floats
copyOf, copyOf, copyTo, copyTo, copyTo, first, isEmpty, last, n, v
-
Methods inherited from interface com.metsci.glimpse.util.primitives.FloatsModifiable
append, append, append, append, append, append, append, clear, compact, ensureCapacity, insert, insert, insert, insert, insert, insert, insert, prepend, prepend, prepend, prepend, prepend, prepend, prepend, remove, removeIndex, removeRange, set, set, set
-
-
-
-
Constructor Detail
-
SortedFloatsArray
public SortedFloatsArray(float[] a)
If the values ofaare not in ascending order, the behavior of this instance is undefined. For efficiency, does not clone the array arg.
-
SortedFloatsArray
public SortedFloatsArray(int n)
-
SortedFloatsArray
public SortedFloatsArray()
-
SortedFloatsArray
public SortedFloatsArray(float[] a, int n)If the values ofaare not in ascending order, the behavior of this instance is undefined. For efficiency, does not clone the array arg.
-
SortedFloatsArray
public SortedFloatsArray(Floats xs)
If the values ofxsare not in ascending order, the behavior of this instance is undefined. Clones the sequence arg.
-
-
Method Detail
-
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
-
indexAfter
public int indexAfter(float x)
Description copied from interface:SortedFloatsSmallest index whose value is greater than x- Specified by:
indexAfterin 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
-
indexBefore
public int indexBefore(float x)
Description copied from interface:SortedFloatsLargest index whose value is less than x- Specified by:
indexBeforein 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
-
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- Throws:
RuntimeException- if n is less than 2 and the exact value is not found- 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- Throws:
RuntimeException- if n is less than 2 and the exact value is not found- 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- Throws:
RuntimeException- if n is less than 2- 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- Throws:
RuntimeException- if n is less than 2- 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- Throws:
RuntimeException- if n is less than 2- 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- Throws:
RuntimeException- if n is less than 2- See Also:
ContinuousIndexArray
-
add
public int add(float v)
- Specified by:
addin interfaceSortedFloatsModifiable- Returns:
- The index at which v was inserted
-
copy
public SortedFloatsArray copy()
- Specified by:
copyin interfaceFloats- Specified by:
copyin interfaceFloatsModifiable- Specified by:
copyin interfaceSortedFloats- Specified by:
copyin interfaceSortedFloatsModifiable- Overrides:
copyin classFloatsArray
-
-