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 with toArray() the data is copied to the result long[].
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an LongArray.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    add(long element)
    Add long to LongArray.
    final void
    addAll(long[] elements)
    Add long[] to LongArray.
    final long
    Get memory consumption of LongArray.
    final long
    get(int index)
    Get long at index from LongArray.
    final int
    Get length of LongArray.
    final long[]
    Convert LongArray to long[].

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ArrayLongBig

      public ArrayLongBig()
      Create an LongArray. Memory consumption is equal to creating a new ArrayList.
  • Method Details

    • add

      public final void add(long element)
      Add long to LongArray.
      Parameters:
      element - long which should be added
    • addAll

      public final void addAll(long[] elements)
      Add long[] to LongArray.
      Parameters:
      elements - long[] which should be added
    • get

      public final long get(int index) throws IndexOutOfBoundsException
      Get long at index from LongArray.
      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 of LongArray.
      Returns:
      length of LongArray
    • consumption

      public final long consumption()
      Get memory consumption of LongArray.
      Returns:
      memory consumption of LongArray
    • toArray

      public final long[] toArray()
      Convert LongArray 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