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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(int element) Add int toIntArray.final voidaddAll(int[] elements) Add int[] toIntArray.final longGet memory consumption ofIntArray.final intget(int index) Get int at index fromIntArray.booleanisEmpty()Returnstrueif this list contains no elements.final intlength()Get length ofIntArray.final int[]toArray()ConvertIntArrayto 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()Returnstrueif this list contains no elements.- Returns:
trueif this list contains no elements.
-
consumption
public final long consumption()Get memory consumption ofIntArray.- Returns:
- memory consumption of
IntArray
-
toArray
public final int[] toArray()ConvertIntArrayto 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
-