Class ArrayList<E>

Type Parameters:
E - is the type of the elements of a ArrayList.
All Implemented Interfaces:
Filterable<E>, Groupable<E>, IContainer<E>, IFilteringContainerViewProvider<E>, IIntervallContainerViewProvider<E>, IMappingContainerViewProvider<E>, Mappable<E>, AggregationRequestable<E>, ArrayMappable<E>, CountRequestable<E>, IndexRequestable<E>, IterableWithCopyableIterator<E>, SingleSearchable<E>, StoringRequestable<E>, StringMappable, IArrayList<E>, Copyable<IArrayList<E>>, Clearable, EmptinessRequestable, MaterializationRequestable, Iterable<E>

public final class ArrayList<E> extends AbstractExtendedContainer<E> implements IArrayList<E>
Author:
Silvan Wyss
  • Method Details

    • createEmpty

      public static <T> ArrayList<T> createEmpty()
      Type Parameters:
      T - is the type of the elements of the ArrayList.
      Returns:
      a new empty ArrayList.
    • withElements

      @SafeVarargs public static <T> ArrayList<T> withElements(T... elements)
      The time complexity of this implementation is O(n) when n elements are given.
      Type Parameters:
      T - is the type of the given elements.
      Parameters:
      elements -
      Returns:
      a new ArrayList with the given elements.
      Throws:
      RuntimeException - if the given elements is null.
      RuntimeException - if one of the given elements is null.
    • withInitialCapacity

      public static <T> ArrayList<T> withInitialCapacity(int initialCapacity)
      The time complexity of this implementation is O(1).
      Type Parameters:
      T - is the type of the elements of the created ArrayList.
      Parameters:
      initialCapacity -
      Returns:
      a new ArrayList with the given initialCapacity
      Throws:
      RuntimeException - if the given initialCapacity is negative.
    • withInitialCapacityFromSizeOfContainer

      public static <T> ArrayList<T> withInitialCapacityFromSizeOfContainer(CountRequestable<?> container)
      The time complexity of this implementation is O(1).
      Type Parameters:
      T - is the type of the elements of the created ArrayList.
      Parameters:
      container -
      Returns:
      a new ArrayList with a initialCapacity that is the size of the given container.
      Throws:
      NullPointerException - if the given container is null.
    • addAtEnd

      public void addAtEnd(E element)
      The time complexity of this implementation is O(n) when the current ArrayList contains n elements. Adds the given element at the end of the current IArrayList.
      Specified by:
      addAtEnd in interface IArrayList<E>
      Parameters:
      element -
    • addAtEnd

      public <T extends E> void addAtEnd(T... elements)
      The time complexity of this implementation is O(n+m) when the current ArrayList contains n elements and m elements are given. Adds the given elements at the end of the current IArrayList. The elements will be added in the given order.
      Specified by:
      addAtEnd in interface IArrayList<E>
      Type Parameters:
      T - is the type of the given elements.
      Parameters:
      elements -
    • addAtEnd

      public void addAtEnd(Iterable<? extends E> elements)
      The time complexity of this implementation is O(n+m) when the current ArrayList contains n elements and m elements are given. Adds the given elements at the end of the current IArrayList. The elements will be added in the given order.
      Specified by:
      addAtEnd in interface IArrayList<E>
      Parameters:
      elements -
    • clear

      public void clear()
      The time complexity of this implementation is O(1). Removes the elements of the current Clearable.
      Specified by:
      clear in interface Clearable
    • getCopy

      public IArrayList<E> getCopy()
      The time complexity of this implementation is O(n) when the current ArrayList contains n elements.
      Specified by:
      getCopy in interface Copyable<E>
      Returns:
      a new copy of the current Copyable.
    • getCount

      public int getCount()
      The time complexity of this implementation is O(1).
      Specified by:
      getCount in interface CountRequestable<E>
      Returns:
      the number of elements of the current CountRequestable.
    • getStoredAtOneBasedIndex

      public E getStoredAtOneBasedIndex(int oneBasedIndex)
      The time complexity of this implementation is O(1).
      Specified by:
      getStoredAtOneBasedIndex in interface SingleSearchable<E>
      Parameters:
      oneBasedIndex -
      Returns:
      the element at the given oneBasedIndex. The element can be null.
    • insertAtOneBasedIndex

      public void insertAtOneBasedIndex(int oneBasedIndex, E element)
      The time complexity of this implementation is O(n) if the given oneBasedIndex is bigger than the number of the elements of the current ArrayList and the current ArrayList contains n elements. The time complexity of this implementation is O(1) if the given oneBasedIndex is not bigger than the number of the elements of the current ArrayList. Adds the given element at the given oneBasedIndex
      Specified by:
      insertAtOneBasedIndex in interface IArrayList<E>
      Parameters:
      oneBasedIndex -
      element -
    • isMaterialized

      public boolean isMaterialized()
      The time complexity of this implementation is O(1).
      Specified by:
      isMaterialized in interface MaterializationRequestable
      Returns:
      true if the current MaterializationRequestable is materialized, false otherwise.
    • iterator

      public CopyableIterator<E> iterator()
      The time complexity of this implementation is O(1).
      Specified by:
      iterator in interface Iterable<E>
      Specified by:
      iterator in interface IterableWithCopyableIterator<E>
    • toString

      public String toString()
      The time complexity of this implementation is O(n) if the current ArrayList contains n elements.
      Overrides:
      toString in class Object