com.metsci.glimpse.util.primitives.sorted
Class SortedLongsArray

java.lang.Object
  extended by com.metsci.glimpse.util.primitives.LongsArray
      extended by com.metsci.glimpse.util.primitives.sorted.SortedLongsArray
All Implemented Interfaces:
Longs, LongsModifiable, SortedLongs, SortedLongsModifiable

public class SortedLongsArray
extends LongsArray
implements SortedLongsModifiable

Author:
hogye

Field Summary
 
Fields inherited from class com.metsci.glimpse.util.primitives.LongsArray
a, n
 
Constructor Summary
SortedLongsArray()
           
SortedLongsArray(int n)
           
SortedLongsArray(long[] a)
          If the values of a are not in ascending order, the behavior of this instance is undefined.
SortedLongsArray(long[] a, int n)
          If the values of a are not in ascending order, the behavior of this instance is undefined.
SortedLongsArray(Longs xs)
          If the values of xs are not in ascending order, the behavior of this instance is undefined.
 
Method Summary
 int add(long v)
           
 ContinuousIndex continuousIndexOf(long x)
          The continuous index at which x falls in this sequence.
 void continuousIndexOf(long x, ContinuousIndex result)
          The continuous index at which x falls in this sequence.
 ContinuousIndexArray continuousIndicesOf(Longs xs)
          For each x in xs, the continuous index at which x falls in this sequence.
 void continuousIndicesOf(Longs xs, ContinuousIndexArray result)
          For each x in xs, the continuous index at which x falls in this sequence.
 ContinuousIndexArray continuousIndicesOf(SortedLongs xs)
          For each x in xs, the continuous index at which x falls in this sequence.
 void continuousIndicesOf(SortedLongs xs, ContinuousIndexArray result)
          For each x in xs, the continuous index at which x falls in this sequence.
 int indexAfter(long x)
          Smallest index whose value is greater than x
 int indexAtOrAfter(long x)
          Smallest index whose value is greater than or equal to x
 int indexAtOrBefore(long x)
          Largest index whose value is less than or equal to x
 int indexBefore(long x)
          Largest index whose value is less than x
 int indexNearest(long x)
          Index of the value closest to x.
 int indexOf(long x)
          Follows the convention of Arrays.binarySearch(long[], long): If x is contained in this sequence, returns the index of x Otherwise, returns (-insertionPoint - 1)
 
Methods inherited from class com.metsci.glimpse.util.primitives.LongsArray
append, append, append, append, append, append, append, compact, copyOf, copyOf, 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, 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.sorted.SortedLongsModifiable
ensureCapacity
 
Methods inherited from interface com.metsci.glimpse.util.primitives.LongsModifiable
append, append, append, append, append, append, append, compact, insert, insert, insert, insert, insert, insert, insert, prepend, prepend, prepend, prepend, prepend, prepend, prepend, remove, set
 
Methods inherited from interface com.metsci.glimpse.util.primitives.Longs
copyOf, copyOf, copyTo, first, isEmpty, last, n, v
 

Constructor Detail

SortedLongsArray

public SortedLongsArray(long[] a)
If the values of a are not in ascending order, the behavior of this instance is undefined. For efficiency, does not clone the array arg.


SortedLongsArray

public SortedLongsArray(int n)

SortedLongsArray

public SortedLongsArray()

SortedLongsArray

public SortedLongsArray(long[] a,
                        int n)
If the values of a are not in ascending order, the behavior of this instance is undefined. For efficiency, does not clone the array arg.


SortedLongsArray

public SortedLongsArray(Longs xs)
If the values of xs are not in ascending order, the behavior of this instance is undefined. Clones the sequence arg.

Method Detail

indexOf

public int indexOf(long x)
Description copied from interface: SortedLongs
Follows the convention of Arrays.binarySearch(long[], long):

Specified by:
indexOf in interface SortedLongs
See Also:
Arrays.binarySearch(long[], long)

indexNearest

public int indexNearest(long x)
Description copied from interface: SortedLongs
Index 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:
indexNearest in interface SortedLongs

indexAfter

public int indexAfter(long x)
Description copied from interface: SortedLongs
Smallest index whose value is greater than x

Specified by:
indexAfter in interface SortedLongs

indexAtOrAfter

public int indexAtOrAfter(long x)
Description copied from interface: SortedLongs
Smallest index whose value is greater than or equal to x

Specified by:
indexAtOrAfter in interface SortedLongs

indexBefore

public int indexBefore(long x)
Description copied from interface: SortedLongs
Largest index whose value is less than x

Specified by:
indexBefore in interface SortedLongs

indexAtOrBefore

public int indexAtOrBefore(long x)
Description copied from interface: SortedLongs
Largest index whose value is less than or equal to x

Specified by:
indexAtOrBefore in interface SortedLongs

continuousIndexOf

public void continuousIndexOf(long x,
                              ContinuousIndex result)
Description copied from interface: SortedLongs
The continuous index at which x falls in this sequence.

Specified by:
continuousIndexOf in interface SortedLongs
Throws:
java.lang.RuntimeException - if n is less than 2 and the exact value is not found
See Also:
ContinuousIndex

continuousIndexOf

public ContinuousIndex continuousIndexOf(long x)
Description copied from interface: SortedLongs
The continuous index at which x falls in this sequence.

Specified by:
continuousIndexOf in interface SortedLongs
Throws:
java.lang.RuntimeException - if n is less than 2 and the exact value is not found
See Also:
ContinuousIndex

continuousIndicesOf

public void continuousIndicesOf(Longs xs,
                                ContinuousIndexArray result)
Description copied from interface: SortedLongs
For each x in xs, the continuous index at which x falls in this sequence.

Specified by:
continuousIndicesOf in interface SortedLongs
Throws:
java.lang.RuntimeException - if n is less than 2
See Also:
ContinuousIndexArray

continuousIndicesOf

public ContinuousIndexArray continuousIndicesOf(Longs xs)
Description copied from interface: SortedLongs
For each x in xs, the continuous index at which x falls in this sequence.

Specified by:
continuousIndicesOf in interface SortedLongs
Throws:
java.lang.RuntimeException - if n is less than 2
See Also:
com.metsci.tracks.ContinuousIndexArray

continuousIndicesOf

public void continuousIndicesOf(SortedLongs xs,
                                ContinuousIndexArray result)
Description copied from interface: SortedLongs
For each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster than SortedLongs.continuousIndicesOf(Longs, ContinuousIndexArray) in some implementations.

Specified by:
continuousIndicesOf in interface SortedLongs
Throws:
java.lang.RuntimeException - if n is less than 2
See Also:
ContinuousIndexArray

continuousIndicesOf

public ContinuousIndexArray continuousIndicesOf(SortedLongs xs)
Description copied from interface: SortedLongs
For each x in xs, the continuous index at which x falls in this sequence. Since xs is sorted, this method may be faster than SortedLongs.continuousIndicesOf(Longs) in some implementations.

Specified by:
continuousIndicesOf in interface SortedLongs
Throws:
java.lang.RuntimeException - if n is less than 2
See Also:
ContinuousIndexArray

add

public int add(long v)
Specified by:
add in interface SortedLongsModifiable
Returns:
The index at which v was inserted


Copyright © 2012 Metron, Inc.. All Rights Reserved.