Package org.eclipse.mat.collect
Class ArrayLongBig
- java.lang.Object
-
- org.eclipse.mat.collect.ArrayLongBig
-
public final class ArrayLongBig extends Object
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 withtoArray()
the data is copied to the result long[].
-
-
Constructor Summary
Constructors Constructor Description ArrayLongBig()
Create anLongArray
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(long element)
Add long toLongArray
.void
addAll(long[] elements)
Add long[] toLongArray
.long
consumption()
Get memory consumption ofLongArray
.long
get(int index)
Get long at index fromLongArray
.int
length()
Get length ofLongArray
.long[]
toArray()
ConvertLongArray
to long[].
-
-
-
Method Detail
-
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
public final long get(int index) throws IndexOutOfBoundsException
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
-
-