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