Class ArrayModule<T>

  • Type Parameters:
    T - The type of the array.

    public class ArrayModule<T>
    extends Object
    A helper module to work with arrays and especially adding elements to them.
    Author:
    Collin Alpert
    • Constructor Detail

      • ArrayModule

        public ArrayModule​(Class<T> clazz,
                           int chunkSize)
    • Method Detail

      • getArray

        public T[] getArray()
        Gets an array with all the elements that were added to it. Should there be excess slots from when the array was extended to fit more elements, they will be trimmed away.
        Returns:
        An array containing the added elements.
      • addElement

        public void addElement​(T element)
        Adds an element to the array. When the max size of the array is reached, it is extended by the specified chunkSize in the constructor.
        Parameters:
        element - The element to add to the array.