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