Package org.eclipse.mat.collect
Class ArrayLongBig
java.lang.Object
org.eclipse.mat.collect.ArrayLongBig
This class simplifies the handling of growing long[] in a very fast and
memory efficient manner so that no slow collections must be used. However
this class is only fast on big long[] and not on small ones where you collect
just a couple of longs. The internal data is never copied during the process
of growing. Only with
toArray()
the data is copied to the result
long[].-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
add
(long element) Add long toLongArray
.final void
addAll
(long[] elements) Add long[] toLongArray
.final long
Get memory consumption ofLongArray
.final long
get
(int index) Get long at index fromLongArray
.final int
length()
Get length ofLongArray
.final long[]
toArray()
ConvertLongArray
to long[].
-
Constructor Details
-
ArrayLongBig
public ArrayLongBig()Create anLongArray
. Memory consumption is equal to creating a newArrayList
.
-
-
Method Details
-
add
public final void add(long element) Add long toLongArray
.- Parameters:
element
- long which should be added
-
addAll
public final void addAll(long[] elements) Add long[] toLongArray
.- Parameters:
elements
- long[] which should be added
-
get
Get long at index fromLongArray
.- Parameters:
index
- index of long which should be returned- Returns:
- long at index
- Throws:
IndexOutOfBoundsException
- if the index is beyond the end.
-
length
public final int length()Get length ofLongArray
.- Returns:
- length of
LongArray
-
consumption
public final long consumption()Get memory consumption ofLongArray
.- Returns:
- memory consumption of
LongArray
-
toArray
public final long[] toArray()ConvertLongArray
to long[]. This operation is the only one where the internal data is copied. It is directly copied to the long[] which is returned, so don't call this method more than once when done.- Returns:
- long[] representing the
LongArray
-