Package org.eclipse.mat.collect
Class ArrayIntBig
java.lang.Object
org.eclipse.mat.collect.ArrayIntBig
- All Implemented Interfaces:
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 with
toArray()
the data is copied to the result int[].- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(int element) Add int toIntArray
.final void
addAll
(int[] elements) Add int[] toIntArray
.final long
Get memory consumption ofIntArray
.final int
get
(int index) Get int at index fromIntArray
.boolean
isEmpty()
Returnstrue
if this list contains no elements.final int
length()
Get length ofIntArray
.final int[]
toArray()
ConvertIntArray
to int[].
-
Constructor Details
-
ArrayIntBig
public ArrayIntBig()Create anIntArray
. Memory consumption is equal to creating a newArrayList
.
-
-
Method Details
-
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
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
-