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

java.lang.Object
  extended by com.metsci.glimpse.util.primitives.sorted.SortedLongsArithmetic
All Implemented Interfaces:
Longs, SortedLongs

public class SortedLongsArithmetic
extends java.lang.Object
implements SortedLongs

Author:
hogye

Field Summary
 int n
           
 double oneOverVStep
           
 long v0
           
 long vStep
           
 
Constructor Summary
SortedLongsArithmetic(long v0, long vStep, int n)
           
 
Method Summary
static java.math.BigInteger big(int x)
           
static java.math.BigInteger big(long x)
           
 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 continuousIndicesIn(SortedLongs xs)
          Like continuousIndicesOf, but in reverse: for each v in this sequence, the continuous index at which v falls in xs.
 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.
 long[] copyOf()
           
 long[] copyOf(int i, int c)
           
 void copyTo(int i, long[] dest, int iDest, int c)
           
 long first()
           
 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)
 boolean isEmpty()
           
 long last()
           
 int n()
          Length of the sequence
 long v(int i)
          Value at index i
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

v0

public final long v0

vStep

public final long vStep

n

public final int n

oneOverVStep

public final double oneOverVStep
Constructor Detail

SortedLongsArithmetic

public SortedLongsArithmetic(long v0,
                             long vStep,
                             int n)
Throws:
java.lang.IllegalArgumentException - if vStep is non-positive, or n is negative, or (v0 + (n-1)*vStep) is greater than Long.MAX_VALUE
Method Detail

big

public static java.math.BigInteger big(long x)

big

public static java.math.BigInteger big(int x)

v

public long v(int i)
Description copied from interface: Longs
Value at index i

Specified by:
v in interface Longs

n

public int n()
Description copied from interface: Longs
Length of the sequence

Specified by:
n in interface Longs

copyTo

public void copyTo(int i,
                   long[] dest,
                   int iDest,
                   int c)
Specified by:
copyTo in interface Longs

copyOf

public long[] copyOf(int i,
                     int c)
Specified by:
copyOf in interface Longs

copyOf

public long[] copyOf()
Specified by:
copyOf in interface Longs

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Longs

first

public long first()
Specified by:
first in interface Longs

last

public long last()
Specified by:
last in interface Longs

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

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

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

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

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

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
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
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
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
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
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
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.



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