Class BigArrayList<T>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    java.lang.Iterable<T>

    public final class BigArrayList<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>

    Simple implementation of a list that can have more than Integer.MAX_VALUE values. Works as a normal ArrayList until the size gets bigger than Integer.MAX_VALUE. After that, it works as a List of ArrayLists, so get(long) will be a little bit more expensive.

    For now, only add(Object), get(long), and size() are supported.

    Since:
    2.0
    Version:
    2.0
    Author:
    Pedro Oliveira
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_MAX_SIZE
      The default max size a List can have
    • Constructor Summary

      Constructors 
      Constructor Description
      BigArrayList()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(T element)
      Appends the specified element to the end of this list.
      void clear()  
      static <T> BigArrayList<T> create()  
      static <T> BigArrayList<T> create​(int maxSize)  
      T get​(long index)
      Returns the element at the specified position in this list.
      java.util.Iterator<T> iterator()  
      T set​(long theIndex, T theElem)
      Set the value of the index
      long size()
      Returns the number of elements in this list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • DEFAULT_MAX_SIZE

        public static final int DEFAULT_MAX_SIZE
        The default max size a List can have
        See Also:
        Constant Field Values
    • Constructor Detail

      • BigArrayList

        public BigArrayList()
    • Method Detail

      • create

        public static <T> BigArrayList<T> create​(int maxSize)
      • get

        public T get​(long index)
        Returns the element at the specified position in this list.
        Parameters:
        index -
        Returns:
      • set

        public T set​(long theIndex,
                     T theElem)
        Set the value of the index
        Parameters:
        theIndex - the index
        theElem - the element to set at the index
        Returns:
        the value
      • add

        public boolean add​(T element)
        Appends the specified element to the end of this list.
        Parameters:
        element -
        Returns:
      • size

        public long size()
        Returns the number of elements in this list.
        Returns:
      • clear

        public void clear()
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>