Class FastList<T>

    • Constructor Detail

      • FastList

        public FastList​(Class<?> clazz)
        Construct a FastList with a default size of 32.
        Parameters:
        clazz - the Class stored in the collection
      • FastList

        public FastList​(Class<?> clazz,
                        int capacity)
        Construct a FastList with a specified size.
        Parameters:
        clazz - the Class stored in the collection
        capacity - the initial size of the FastList
    • Method Detail

      • add

        public boolean add​(T element)
        Add an element to the tail of the FastList.
        Specified by:
        add in interface Collection<T>
        Specified by:
        add in interface List<T>
        Parameters:
        element - the element to add
      • get

        public T get​(int index)
        Get the element at the specified index.
        Specified by:
        get in interface List<T>
        Parameters:
        index - the index of the element to get
        Returns:
        the element, or ArrayIndexOutOfBounds is thrown if the index is invalid
      • removeLast

        public T removeLast()
        Remove the last element from the list. No bound check is performed, so if this method is called on an empty list and ArrayIndexOutOfBounds exception will be thrown.
        Returns:
        the last element of the list
      • remove

        public boolean remove​(Object element)
        This remove method is most efficient when the element being removed is the last element. Equality is identity based, not equals() based. Only the first matching element is removed.
        Specified by:
        remove in interface Collection<T>
        Specified by:
        remove in interface List<T>
        Parameters:
        element - the element to remove
      • clear

        public void clear()
        Clear the FastList.
        Specified by:
        clear in interface Collection<T>
        Specified by:
        clear in interface List<T>
      • size

        public int size()
        Get the current number of elements in the FastList.
        Specified by:
        size in interface Collection<T>
        Specified by:
        size in interface List<T>
        Returns:
        the number of current elements
      • set

        public T set​(int index,
                     T element)
        Specified by:
        set in interface List<T>
      • remove

        public T remove​(int index)
        Specified by:
        remove in interface List<T>
      • addAll

        public boolean addAll​(int index,
                              Collection<? extends T> c)
        Specified by:
        addAll in interface List<T>
      • add

        public void add​(int index,
                        T element)
        Specified by:
        add in interface List<T>
      • subList

        public List<T> subList​(int fromIndex,
                               int toIndex)
        Specified by:
        subList in interface List<T>