Class AbstractArrayStorage<T>

java.lang.Object
net.mtrop.doom.struct.vector.AbstractArrayStorage<T>
Type Parameters:
T - the value type that this contains.
Direct Known Subclasses:
AbstractVector

public abstract class AbstractArrayStorage<T> extends Object
This class contains the base for all data structures that make use of a contiguous memory structure.
Author:
Matthew Tropiano
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default capacity for a new array.
    protected Object[]
    Underlying object array.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Initializes the array with the default storage capacity.
    protected
    AbstractArrayStorage(int capacity)
    Initializes the array with a particular storage capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected T
    get(int index)
    Gets data at a particular index in the array.
    protected void
    set(int index, T object)
    Sets the data at a particular index in the array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CAPACITY

      public static final int DEFAULT_CAPACITY
      Default capacity for a new array.
      See Also:
    • storageArray

      protected Object[] storageArray
      Underlying object array.
  • Constructor Details

    • AbstractArrayStorage

      protected AbstractArrayStorage()
      Initializes the array with the default storage capacity.
    • AbstractArrayStorage

      protected AbstractArrayStorage(int capacity)
      Initializes the array with a particular storage capacity.
      Parameters:
      capacity - the desired capacity.
  • Method Details

    • get

      protected T get(int index)
      Gets data at a particular index in the array.
      Parameters:
      index - the desired index.
      Returns:
      the data at a particular index in the array.
      Throws:
      ArrayIndexOutOfBoundsException - if the index falls outside of the array bounds.
    • set

      protected void set(int index, T object)
      Sets the data at a particular index in the array.
      Parameters:
      index - the desired index.
      object - the object to set.
      Throws:
      ArrayIndexOutOfBoundsException - if the index falls outside of the array bounds.