Class PreAllocatedArray<T>

  • All Implemented Interfaces:
    Iterable<T>

    public class PreAllocatedArray<T>
    extends Object
    implements Iterable<T>
    An ArrayList implementation that represents a type-safe pre-allocated array. This should be used exactly like an array, but helps avoid type-safety issues when mixing arrays with generics. The iterator is unmodifiable.
    • Field Detail

      • length

        public final int length
    • Constructor Detail

      • PreAllocatedArray

        public PreAllocatedArray​(int capacity)
        Creates an instance of the given capacity, with all elements initialized to null
    • Method Detail

      • set

        public T set​(int index,
                     T element)
        Set the element at the specified index, and return the old value.
      • get

        public T get​(int index)
        Get the item stored at the specified index.