Class BlockList<T>

  • Type Parameters:
    T - type of list element.
    All Implemented Interfaces:
    Iterable<T>, Collection<T>, List<T>

    public class BlockList<T>
    extends AbstractList<T>
    Random access list that allocates entries in blocks.

    Unlike ArrayList, this type does not need to reallocate the internal array in order to expand the capacity of the list. Access to any element is constant time, but requires two array lookups instead of one.

    To handle common usages, add(Object) and iterator() use internal code paths to amortize out the second array lookup, making addition and simple iteration closer to one array operation per element processed.

    Similar to ArrayList, adding or removing from any position except the end of the list requires O(N) time to copy all elements between the modification point and the end of the list. Applications are strongly encouraged to not use this access pattern with this list implementation.

    • Constructor Detail

      • BlockList

        public BlockList()
        Initialize an empty list.
      • BlockList

        public BlockList​(int capacity)
        Initialize an empty list with an expected capacity.
        capacity - number of elements expected to be in the list.