public class IntegerArray extends Object implements NumberArrayAdapter<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.
|
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.
|
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 OutOfMemoryError
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 void sort()
public int size(IntegerArray array)
ArrayAdapter
size
in interface ArrayAdapter<Integer,IntegerArray>
size
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array-like thingpublic Integer get(IntegerArray array, int off) throws IndexOutOfBoundsException
ArrayAdapter
get
in interface ArrayAdapter<Integer,IntegerArray>
get
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public double getDouble(IntegerArray array, int off) throws IndexOutOfBoundsException
NumberArrayAdapter
getDouble
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public float getFloat(IntegerArray array, int off) throws IndexOutOfBoundsException
NumberArrayAdapter
getFloat
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public int getInteger(IntegerArray array, int off) throws IndexOutOfBoundsException
NumberArrayAdapter
getInteger
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public short getShort(IntegerArray array, int off) throws IndexOutOfBoundsException
NumberArrayAdapter
getShort
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public long getLong(IntegerArray array, int off) throws IndexOutOfBoundsException
NumberArrayAdapter
getLong
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public byte getByte(IntegerArray array, int off) throws IndexOutOfBoundsException
NumberArrayAdapter
getByte
in interface NumberArrayAdapter<Integer,IntegerArray>
array
- Array to get fromoff
- OffsetIndexOutOfBoundsException
- for an invalid index.public int[] toArray()
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.