Package org.eclipse.mat.collect
Class ArrayIntBig
- java.lang.Object
-
- org.eclipse.mat.collect.ArrayIntBig
-
- All Implemented Interfaces:
Serializable
public final class ArrayIntBig extends Object implements Serializable
This class simplifies the handling of growing int[] in a very fast and memory efficient manner so that no slow collections must be used. However this class is only fast on big int[] and not on small ones where you collect just a couple of ints. The internal data is never copied during the process of growing. Only withtoArray()
the data is copied to the result int[].- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ArrayIntBig()
Create anIntArray
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int element)
Add int toIntArray
.void
addAll(int[] elements)
Add int[] toIntArray
.long
consumption()
Get memory consumption ofIntArray
.int
get(int index)
Get int at index fromIntArray
.boolean
isEmpty()
Returnstrue
if this list contains no elements.int
length()
Get length ofIntArray
.int[]
toArray()
ConvertIntArray
to int[].
-
-
-
Method Detail
-
add
public final void add(int element)
Add int toIntArray
.- Parameters:
element
- int which should be added
-
addAll
public final void addAll(int[] elements)
Add int[] toIntArray
.- Parameters:
elements
- int[] which should be added
-
get
public final int get(int index) throws IndexOutOfBoundsException
Get int at index fromIntArray
.- Parameters:
index
- index of int which should be returned- Returns:
- int at index
- Throws:
IndexOutOfBoundsException
- if the index is beyond the end.
-
length
public final int length()
Get length ofIntArray
.- Returns:
- length of
IntArray
-
isEmpty
public boolean isEmpty()
Returnstrue
if this list contains no elements.- Returns:
true
if this list contains no elements.
-
consumption
public final long consumption()
Get memory consumption ofIntArray
.- Returns:
- memory consumption of
IntArray
-
toArray
public final int[] toArray()
ConvertIntArray
to int[]. This operation is the only one where the internal data is copied. It is directly copied to the int[] which is returned, so don't call this method more than once when done.- Returns:
- int[] representing the
IntArray
-
-