Class SortedIntsArray
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.IntsArray
-
- com.metsci.glimpse.util.primitives.sorted.SortedIntsArray
-
- All Implemented Interfaces:
Ints,IntsModifiable,SortedInts,SortedIntsModifiable
public class SortedIntsArray extends IntsArray implements SortedIntsModifiable
- Author:
- hogye
-
-
Constructor Summary
Constructors Constructor Description SortedIntsArray()SortedIntsArray(int n)SortedIntsArray(int[] a)If the values ofaare not in ascending order, the behavior of this instance is undefined.SortedIntsArray(int[] a, int n)If the values ofaare not in ascending order, the behavior of this instance is undefined.SortedIntsArray(Ints 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(int v)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.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.SortedIntsArraycopy()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)-
Methods inherited from class com.metsci.glimpse.util.primitives.IntsArray
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.Ints
copyOf, copyOf, copyTo, copyTo, copyTo, first, isEmpty, last, n, v
-
Methods inherited from interface com.metsci.glimpse.util.primitives.IntsModifiable
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
-
SortedIntsArray
public SortedIntsArray(int[] a)
If the values ofaare not in ascending order, the behavior of this instance is undefined. For efficiency, does not clone the array arg.
-
SortedIntsArray
public SortedIntsArray(int n)
-
SortedIntsArray
public SortedIntsArray()
-
SortedIntsArray
public SortedIntsArray(int[] 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.
-
SortedIntsArray
public SortedIntsArray(Ints 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(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
-
indexAfter
public int indexAfter(int x)
Description copied from interface:SortedIntsSmallest index whose value is greater than x- Specified by:
indexAfterin 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
-
indexBefore
public int indexBefore(int x)
Description copied from interface:SortedIntsLargest index whose value is less than x- Specified by:
indexBeforein 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
-
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- Throws:
RuntimeException- if n is less than 2 and the exact value is not found- 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- Throws:
RuntimeException- if n is less than 2 and the exact value is not found- 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- Throws:
RuntimeException- if n is less than 2- 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- Throws:
RuntimeException- if n is less than 2- 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- Throws:
RuntimeException- if n is less than 2- 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- Throws:
RuntimeException- if n is less than 2- See Also:
ContinuousIndexArray
-
add
public int add(int v)
- Specified by:
addin interfaceSortedIntsModifiable- Returns:
- The index at which v was inserted
-
copy
public SortedIntsArray copy()
- Specified by:
copyin interfaceInts- Specified by:
copyin interfaceIntsModifiable- Specified by:
copyin interfaceSortedInts- Specified by:
copyin interfaceSortedIntsModifiable- Overrides:
copyin classIntsArray
-
-