public class DoubleArray extends java.lang.Object implements NumberArrayAdapter<java.lang.Double,DoubleArray>
Modifier and Type | Field and Description |
---|---|
double[] |
data
(Reused) store for numerical attributes.
|
private static int |
LAST_GROW_SIZE
Last value where we can grow by 50%.
|
private static int |
MAX_ARRAY_SIZE
Maximum array size permitted by Java.
|
int |
size
Number of numerical attributes.
|
Constructor and Description |
---|
DoubleArray()
Constructor.
|
DoubleArray(DoubleArray existing)
Constructor from an existing array.
|
DoubleArray(int initialsize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double attribute)
Append a value.
|
void |
clear()
Reset the numeric attribute counter.
|
java.lang.Double |
get(DoubleArray array,
int off)
Get the off'th item from the array.
|
double |
get(int pos)
Get the value at this position.
|
byte |
getByte(DoubleArray array,
int off)
Get the off'th item from the array as byte.
|
double |
getDouble(DoubleArray array,
int off)
Get the off'th item from the array as double.
|
float |
getFloat(DoubleArray array,
int off)
Get the off'th item from the array as float.
|
int |
getInteger(DoubleArray array,
int off)
Get the off'th item from the array as integer.
|
long |
getLong(DoubleArray array,
int off)
Get the off'th item from the array as long.
|
short |
getShort(DoubleArray array,
int off)
Get the off'th item from the array as short.
|
private void |
grow()
Grow the current array.
|
void |
insert(int pos,
double val)
Insert a value at the given position.
|
boolean |
isEmpty()
Test if the array is empty.
|
void |
remove(int start,
int len)
Remove a range from the array.
|
void |
set(int pos,
double value)
Set the value at this position.
|
int |
size()
Get the size of the array.
|
int |
size(DoubleArray array)
Get the size of the array.
|
void |
sort()
Sort the contents.
|
double[] |
toArray()
Return a copy of the contents as array.
|
private static final int MAX_ARRAY_SIZE
private static final int LAST_GROW_SIZE
public double[] data
public int size
public DoubleArray()
public DoubleArray(int initialsize)
initialsize
- Initial size.public DoubleArray(DoubleArray existing)
existing
- Existing arraypublic void clear()
public void add(double attribute)
attribute
- Attribute value.private void grow() throws java.lang.OutOfMemoryError
java.lang.OutOfMemoryError
public double get(int pos)
pos
- Positionpublic void set(int pos, double value)
pos
- Positionvalue
- Valuepublic void remove(int start, int len)
start
- Startlen
- Lengthpublic void insert(int pos, double val)
pos
- Insert positionval
- Value to insertpublic int size()
public boolean isEmpty()
true
if empty.public void sort()
public int size(DoubleArray array)
ArrayAdapter
size
in interface ArrayAdapter<java.lang.Double,DoubleArray>
size
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array-like thingpublic java.lang.Double get(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
ArrayAdapter
get
in interface ArrayAdapter<java.lang.Double,DoubleArray>
get
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public double getDouble(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
NumberArrayAdapter
getDouble
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public float getFloat(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
NumberArrayAdapter
getFloat
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public int getInteger(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
NumberArrayAdapter
getInteger
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public short getShort(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
NumberArrayAdapter
getShort
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public long getLong(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
NumberArrayAdapter
getLong
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public byte getByte(DoubleArray array, int off) throws java.lang.IndexOutOfBoundsException
NumberArrayAdapter
getByte
in interface NumberArrayAdapter<java.lang.Double,DoubleArray>
array
- Array to get fromoff
- Offsetjava.lang.IndexOutOfBoundsException
- for an invalid index.public double[] toArray()
Copyright © 2019 ELKI Development Team. License information.