Class LinkedArrayList



  • public class LinkedArrayList
    extends Object
    A list implementation which combines an ArrayList with a LinkedList to avoid copying values when the capacity needs to be increased.

    The class is non final to allow embedding it directly and thus saving on object allocation.

    • Constructor Summary

      Constructors

      Constructor and Description
      LinkedArrayList(int capacityHint)
      Constructor with the capacity hint of each array segment.
    • Method Summary

      Modifier and Type Method and Description
      void add(Object o)
      Adds a new element to this list.
      int capacityHint()
      Returns the capacity hint that indicates the capacity of each buffer segment.
      Object[] head()
      Returns the head buffer segment or null if the list is empty.
      int indexInTail()
      Returns the index of the next slot in the tail buffer segment.
      int size()
      Returns the total size of the list.
      Object[] tail()
      Returns the tail buffer segment or null if the list is empty.
      String toString()
       
    • Constructor Detail

      • LinkedArrayList

        public LinkedArrayList(int capacityHint)
        Constructor with the capacity hint of each array segment.
        Parameters:
        capacityHint -
    • Method Detail

      • add

        public void add(Object o)
        Adds a new element to this list.
        Parameters:
        o - the object to add, nulls are accepted
      • head

        public Object[] head()
        Returns the head buffer segment or null if the list is empty.
        Returns:
      • tail

        public Object[] tail()
        Returns the tail buffer segment or null if the list is empty.
        Returns:
      • size

        public int size()
        Returns the total size of the list.
        Returns:
      • indexInTail

        public int indexInTail()
        Returns the index of the next slot in the tail buffer segment.
        Returns:
      • capacityHint

        public int capacityHint()
        Returns the capacity hint that indicates the capacity of each buffer segment.
        Returns:
      • toString

        public String toString()