Class SortedLongsArithmetic
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.sorted.SortedLongsArithmetic
-
- All Implemented Interfaces:
Longs,SortedLongs
public class SortedLongsArithmetic extends Object implements SortedLongs
- Author:
- hogye
-
-
Field Summary
Fields Modifier and Type Field Description intndoubleoneOverVSteplongv0longvStep
-
Constructor Summary
Constructors Constructor Description SortedLongsArithmetic(long v0, long vStep, int n)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BigIntegerbig(int x)static BigIntegerbig(long x)ContinuousIndexcontinuousIndexOf(long x)The continuous index at which x falls in this sequence.voidcontinuousIndexOf(long x, ContinuousIndex result)The continuous index at which x falls in this sequence.ContinuousIndexArraycontinuousIndicesIn(SortedLongs xs)Like continuousIndicesOf, but in reverse: for each v in this sequence, the continuous index at which v falls in xs.ContinuousIndexArraycontinuousIndicesOf(Longs xs)For each x in xs, the continuous index at which x falls in this sequence.voidcontinuousIndicesOf(Longs xs, ContinuousIndexArray result)For each x in xs, the continuous index at which x falls in this sequence.ContinuousIndexArraycontinuousIndicesOf(SortedLongs xs)For each x in xs, the continuous index at which x falls in this sequence.voidcontinuousIndicesOf(SortedLongs xs, ContinuousIndexArray result)For each x in xs, the continuous index at which x falls in this sequence.SortedLongsArithmeticcopy()long[]copyOf()long[]copyOf(int i, int c)voidcopyTo(int i, long[] dest, int iDest, int c)voidcopyTo(int i, LongBuffer dest, int c)voidcopyTo(LongBuffer dest)longfirst()intindexAfter(long x)Smallest index whose value is greater than xintindexAtOrAfter(long x)Smallest index whose value is greater than or equal to xintindexAtOrBefore(long x)Largest index whose value is less than or equal to xintindexBefore(long x)Largest index whose value is less than xintindexNearest(long x)Index of the value closest to x.intindexOf(long x)Follows the convention ofArrays.binarySearch(long[], long): Ifxis contained in this sequence, returns the index ofxOtherwise, returns (-insertionPoint - 1)booleanisEmpty()longlast()intn()Length of the sequencelongv(int i)Value at index i
-
-
-
Constructor Detail
-
SortedLongsArithmetic
public SortedLongsArithmetic(long v0, long vStep, int n)- Throws:
IllegalArgumentException- ifvStepis non-positive, ornis negative, or(v0 + (n-1)*vStep)is greater thanLong.MAX_VALUE
-
-
Method Detail
-
big
public static BigInteger big(long x)
-
big
public static BigInteger big(int x)
-
v
public long v(int i)
Description copied from interface:LongsValue at index i
-
n
public int n()
Description copied from interface:LongsLength of the sequence
-
copyTo
public void copyTo(int i, long[] dest, int iDest, int c)
-
copyTo
public void copyTo(int i, LongBuffer dest, int c)
-
copyTo
public void copyTo(LongBuffer dest)
-
copy
public SortedLongsArithmetic copy()
- Specified by:
copyin interfaceLongs- Specified by:
copyin interfaceSortedLongs
-
indexOf
public int indexOf(long x)
Description copied from interface:SortedLongsFollows the convention ofArrays.binarySearch(long[], long):- If
xis contained in this sequence, returns the index ofx - Otherwise, returns (-insertionPoint - 1)
- Specified by:
indexOfin interfaceSortedLongs- See Also:
Arrays.binarySearch(long[], long)
- If
-
indexNearest
public int indexNearest(long x)
Description copied from interface:SortedLongsIndex of the value closest to x. If the two closest values are x-C and x+C, returns the index of x+C. If longs is empty, returns -1.- Specified by:
indexNearestin interfaceSortedLongs
-
indexBefore
public int indexBefore(long x)
Description copied from interface:SortedLongsLargest index whose value is less than x- Specified by:
indexBeforein interfaceSortedLongs
-
indexAfter
public int indexAfter(long x)
Description copied from interface:SortedLongsSmallest index whose value is greater than x- Specified by:
indexAfterin interfaceSortedLongs
-
indexAtOrBefore
public int indexAtOrBefore(long x)
Description copied from interface:SortedLongsLargest index whose value is less than or equal to x- Specified by:
indexAtOrBeforein interfaceSortedLongs
-
indexAtOrAfter
public int indexAtOrAfter(long x)
Description copied from interface:SortedLongsSmallest index whose value is greater than or equal to x- Specified by:
indexAtOrAfterin interfaceSortedLongs
-
continuousIndexOf
public void continuousIndexOf(long x, ContinuousIndex result)Description copied from interface:SortedLongsThe continuous index at which x falls in this sequence.- Specified by:
continuousIndexOfin interfaceSortedLongs- See Also:
ContinuousIndex
-
continuousIndexOf
public ContinuousIndex continuousIndexOf(long x)
Description copied from interface:SortedLongsThe continuous index at which x falls in this sequence.- Specified by:
continuousIndexOfin interfaceSortedLongs- See Also:
ContinuousIndex
-
continuousIndicesOf
public void continuousIndicesOf(Longs xs, ContinuousIndexArray result)
Description copied from interface:SortedLongsFor each x in xs, the continuous index at which x falls in this sequence.- Specified by:
continuousIndicesOfin interfaceSortedLongs- See Also:
ContinuousIndexArray
-
continuousIndicesOf
public ContinuousIndexArray continuousIndicesOf(Longs xs)
Description copied from interface:SortedLongsFor each x in xs, the continuous index at which x falls in this sequence.- Specified by:
continuousIndicesOfin interfaceSortedLongs- See Also:
com.metsci.tracks.ContinuousIndexArray
-
continuousIndicesOf
public void continuousIndicesOf(SortedLongs xs, ContinuousIndexArray result)
Description copied from interface:SortedLongsFor each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster thanSortedLongs.continuousIndicesOf(Longs, ContinuousIndexArray)in some implementations.- Specified by:
continuousIndicesOfin interfaceSortedLongs- See Also:
ContinuousIndexArray
-
continuousIndicesOf
public ContinuousIndexArray continuousIndicesOf(SortedLongs xs)
Description copied from interface:SortedLongsFor each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster thanSortedLongs.continuousIndicesOf(Longs)in some implementations.- Specified by:
continuousIndicesOfin interfaceSortedLongs- See Also:
ContinuousIndexArray
-
continuousIndicesIn
public ContinuousIndexArray continuousIndicesIn(SortedLongs 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.
-
-