Class ArrayLongBig


  • public final class ArrayLongBig
    extends java.lang.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
      ArrayLongBig()
      Create an LongArray.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(long element)
      Add long to LongArray.
      void addAll​(long[] elements)
      Add long[] to LongArray.
      long consumption()
      Get memory consumption of LongArray.
      long get​(int index)
      Get long at index from LongArray.
      int length()
      Get length of LongArray.
      long[] toArray()
      Convert LongArray to long[].
      • Methods inherited from class java.lang.Object

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

      • ArrayLongBig

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

      • 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 java.lang.IndexOutOfBoundsException
        Get long at index from LongArray.
        Parameters:
        index - index of long which should be returned
        Returns:
        long at index
        Throws:
        java.lang.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