Class DoublesArray
- java.lang.Object
-
- com.metsci.glimpse.util.primitives.DoublesArray
-
- All Implemented Interfaces:
Doubles,DoublesModifiable
- Direct Known Subclasses:
SortedDoublesArray
public class DoublesArray extends Object implements DoublesModifiable
- Author:
- hogye
-
-
Constructor Summary
Constructors Constructor Description DoublesArray()DoublesArray(double[] a)For efficiency, does not clone the array arg.DoublesArray(double[] a, int n)For efficiency, does not clone the array arg.DoublesArray(int n)DoublesArray(Doubles xs)Clones the sequence arg.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(double v)voidappend(double[] vs)voidappend(double[] vs, int from, int to)voidappend(Doubles vs)voidappend(Doubles vs, int from, int to)voidappend(DoubleBuffer vs)voidappend(DoubleBuffer vs, int c)voidclear()voidcompact()DoublesArraycopy()double[]copyOf()double[]copyOf(int i, int c)voidcopyTo(int i, double[] dest, int iDest, int c)voidcopyTo(int i, DoubleBuffer dest, int c)voidcopyTo(DoubleBuffer dest)voidensureCapacity(int minCapacity)doublefirst()voidinsert(int i, double v)voidinsert(int i, double[] vs)voidinsert(int i, double[] vs, int from, int to)voidinsert(int i, Doubles vs)voidinsert(int i, Doubles vs, int from, int to)voidinsert(int i, DoubleBuffer vs)voidinsert(int i, DoubleBuffer vs, int c)booleanisEmpty()doublelast()intn()Length of the sequencestatic double[]newArray(int oldCapacity, int minNewCapacity)Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.voidprepend(double v)voidprepend(double[] vs)voidprepend(double[] vs, int from, int to)voidprepend(Doubles vs)voidprepend(Doubles vs, int from, int to)voidprepend(DoubleBuffer vs)voidprepend(DoubleBuffer vs, int c)voidprepForAppend(int c)Makes room in this array for new values to be appended.voidprepForInsert(int i, int c)Makes room in this array for new values to be inserted.voidprepForPrepend(int c)Makes room in this array for new values to be prepended.voidremove(double v)Removes a single copy of the specified value.voidremoveIndex(int index)Remove value at index.voidremoveRange(int from, int to)Removes values starting at index from (inclusive) to index to (exclusive).voidset(int i, double v)voidset(int i, double[] vs)voidset(int i, double[] vs, int from, int to)doublev(int i)Value at index i
-
-
-
Constructor Detail
-
DoublesArray
public DoublesArray(double[] a)
For efficiency, does not clone the array arg.
-
DoublesArray
public DoublesArray(int n)
-
DoublesArray
public DoublesArray()
-
DoublesArray
public DoublesArray(double[] a, int n)For efficiency, does not clone the array arg.
-
DoublesArray
public DoublesArray(Doubles xs)
Clones the sequence arg.
-
-
Method Detail
-
v
public double v(int i)
Description copied from interface:DoublesValue at index i
-
n
public int n()
Description copied from interface:DoublesLength of the sequence
-
copyTo
public void copyTo(int i, double[] dest, int iDest, int c)
-
copyTo
public void copyTo(int i, DoubleBuffer dest, int c)
-
copyTo
public void copyTo(DoubleBuffer dest)
-
copy
public DoublesArray copy()
- Specified by:
copyin interfaceDoubles- Specified by:
copyin interfaceDoublesModifiable
-
set
public void set(int i, double v)- Specified by:
setin interfaceDoublesModifiable
-
set
public void set(int i, double[] vs)- Specified by:
setin interfaceDoublesModifiable
-
set
public void set(int i, double[] vs, int from, int to)- Specified by:
setin interfaceDoublesModifiable
-
insert
public void insert(int i, double v)- Specified by:
insertin interfaceDoublesModifiable
-
insert
public void insert(int i, Doubles vs)- Specified by:
insertin interfaceDoublesModifiable
-
insert
public void insert(int i, Doubles vs, int from, int to)- Specified by:
insertin interfaceDoublesModifiable
-
insert
public void insert(int i, double[] vs)- Specified by:
insertin interfaceDoublesModifiable
-
insert
public void insert(int i, double[] vs, int from, int to)- Specified by:
insertin interfaceDoublesModifiable
-
insert
public void insert(int i, DoubleBuffer vs)- Specified by:
insertin interfaceDoublesModifiable
-
insert
public void insert(int i, DoubleBuffer vs, int c)- Specified by:
insertin interfaceDoublesModifiable
-
prepForInsert
public void prepForInsert(int i, int c)Makes room in this array for new values to be inserted. When this call returns, the values inthis.aon[i,i+c)are undefined. Writing meaningful values to these indices is up to the caller.- Parameters:
i- The index at which new values will be insertedc- The count of new values that will be inserted
-
prepend
public void prepend(double v)
- Specified by:
prependin interfaceDoublesModifiable
-
prepend
public void prepend(Doubles vs)
- Specified by:
prependin interfaceDoublesModifiable
-
prepend
public void prepend(Doubles vs, int from, int to)
- Specified by:
prependin interfaceDoublesModifiable
-
prepend
public void prepend(double[] vs)
- Specified by:
prependin interfaceDoublesModifiable
-
prepend
public void prepend(double[] vs, int from, int to)- Specified by:
prependin interfaceDoublesModifiable
-
prepend
public void prepend(DoubleBuffer vs)
- Specified by:
prependin interfaceDoublesModifiable
-
prepend
public void prepend(DoubleBuffer vs, int c)
- Specified by:
prependin interfaceDoublesModifiable
-
prepForPrepend
public void prepForPrepend(int c)
Makes room in this array for new values to be prepended. When this call returns, the values inthis.aon[0,c)are undefined. Writing meaningful values to these indices is up to the caller.- Parameters:
c- The count of new values that will be inserted
-
append
public void append(double v)
- Specified by:
appendin interfaceDoublesModifiable
-
append
public void append(Doubles vs)
- Specified by:
appendin interfaceDoublesModifiable
-
append
public void append(Doubles vs, int from, int to)
- Specified by:
appendin interfaceDoublesModifiable
-
append
public void append(double[] vs)
- Specified by:
appendin interfaceDoublesModifiable
-
append
public void append(double[] vs, int from, int to)- Specified by:
appendin interfaceDoublesModifiable
-
append
public void append(DoubleBuffer vs)
- Specified by:
appendin interfaceDoublesModifiable
-
append
public void append(DoubleBuffer vs, int c)
- Specified by:
appendin interfaceDoublesModifiable
-
prepForAppend
public void prepForAppend(int c)
Makes room in this array for new values to be appended. When this call returns, the values inthis.aon[this.n-c,this.n)are undefined. Writing meaningful values to these indices is up to the caller.- Parameters:
c- The count of new values that will be appended
-
remove
public void remove(double v)
Description copied from interface:DoublesModifiableRemoves a single copy of the specified value. If multiple copies are present, there is no guarantee which one will be removed.- Specified by:
removein interfaceDoublesModifiable
-
removeRange
public void removeRange(int from, int to)Description copied from interface:DoublesModifiableRemoves values starting at index from (inclusive) to index to (exclusive). All other values with indices greater than or equal to index to have their index in the array decreased by to-from and the size of the array is decreased by to-from.- Specified by:
removeRangein interfaceDoublesModifiable
-
removeIndex
public void removeIndex(int index)
Description copied from interface:DoublesModifiableRemove value at index. All other values with indices greater than index have their index in the array decreased by one and the size of the array is decreased by one.- Specified by:
removeIndexin interfaceDoublesModifiable
-
clear
public void clear()
- Specified by:
clearin interfaceDoublesModifiable
-
ensureCapacity
public void ensureCapacity(int minCapacity)
- Specified by:
ensureCapacityin interfaceDoublesModifiable
-
compact
public void compact()
- Specified by:
compactin interfaceDoublesModifiable
-
newArray
public static double[] newArray(int oldCapacity, int minNewCapacity)Creates a new array whose capacity is at least minNewCapacity, and at least 1.618 * oldCapacity, up to Integer.MAX_VALUE.
-
-