Package snap.util

Class ObjectArray<T>

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

public class ObjectArray<T> extends AbstractList<T> implements Cloneable
This class manages an array of object values.
  • Field Details

    • _array

      protected T[] _array
    • _size

      protected int _size
  • Constructor Details

    • ObjectArray

      public ObjectArray(Class<T> aClass)
      Constructor.
    • ObjectArray

      public ObjectArray(Class<T> aClass, int length)
      Constructor.
    • ObjectArray

      public ObjectArray(T[] anArray)
      Constructor.
  • Method Details

    • size

      public final int size()
      Returns the length.
      Specified by:
      size in interface Collection<T>
      Specified by:
      size in interface List<T>
      Specified by:
      size in class AbstractCollection<T>
    • setLength

      public void setLength(int aValue)
      Sets the length.
    • get

      public T get(int anIndex)
      Returns the Object value at index.
      Specified by:
      get in interface List<T>
      Specified by:
      get in class AbstractList<T>
    • set

      public T set(int anIndex, T aValue)
      Sets the String value at index.
      Specified by:
      set in interface List<T>
      Overrides:
      set in class AbstractList<T>
    • add

      public void add(int anIndex, T aValue)
      Adds the value at index.
      Specified by:
      add in interface List<T>
      Overrides:
      add in class AbstractList<T>
    • remove

      public T remove(int anIndex)
      Removes the item at index.
      Specified by:
      remove in interface List<T>
      Overrides:
      remove in class AbstractList<T>
    • isEmpty

      public boolean isEmpty()
      Returns whether array is empty.
      Specified by:
      isEmpty in interface Collection<T>
      Specified by:
      isEmpty in interface List<T>
      Overrides:
      isEmpty in class AbstractCollection<T>
    • getArray

      public T[] getArray()
      Returns the simple array (trimmed to length).
    • getLast

      public T getLast()
      Returns the last item.
    • getComponentClass

      public Class<T> getComponentClass()
      Returns the component class.
    • clear

      public void clear()
      Clears the list.
      Specified by:
      clear in interface Collection<T>
      Specified by:
      clear in interface List<T>
      Overrides:
      clear in class AbstractList<T>
    • clone

      protected ObjectArray<T> clone()
      Standard clone implementation.
      Overrides:
      clone in class Object
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class AbstractCollection<T>
    • toStringProps

      public String toStringProps()
      Standard toStringProps implementation.