Class Storage<T>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<T>, Collection<T>, List<T>, RandomAccess, SequencedCollection<T>

public class Storage<T> extends ArrayList<T>
A storage utility class which extends java.util.ArrayList with C++-like operations.
See Also:
  • Constructor Details

    • Storage

      public Storage()
      Creates a storage with initially empty storage.
    • Storage

      public Storage(int size)
      Creates a storage with a given size. This doesn't actually populate those elements; the size reported will be zero until the elements are populated by the calling application.
      Parameters:
      size - initial allocation size.
    • Storage

      public Storage(List<T> storage)
      Copies a given storage. Populates the new storage with each element in the source storage.
      Parameters:
      storage - source storage.
  • Method Details

    • setSize

      public void setSize(int size)
      Sets the size to the given. This method may truncate the storage if the new size is smaller or pad the storage with null values if the new size is larger. This method will affect the size reported by the size() method.
      Parameters:
      size - new size for the storage.
    • last

      public T last()
      Returns the last element in the storage.
      Returns:
      the last element in the storage; null if the storage is empty.
    • removeLast

      public void removeLast()
      Removes the last element from the storage.
      Specified by:
      removeLast in interface List<T>
      Specified by:
      removeLast in interface SequencedCollection<T>
      Overrides:
      removeLast in class ArrayList<T>