Class SimpleArrayList<T>

  • Type Parameters:
    T - the type of elements in this list
    All Implemented Interfaces:
    ISimpleList<T>

    public class SimpleArrayList<T>
    extends java.lang.Object
    implements ISimpleList<T>
    Portable implementation of ArrayList.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.ArrayList<T> list  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int index, T element)
      Adds an element to the list at the specified index.
      void add​(T element)
      Adds an element to the end of the list.
      T get​(int index)
      Returns the element at the specified index.
      int indexOf​(java.lang.Object element)
      Returns the index of the first occurrence of the specified element in the list, or -1 if the list does not contain the element.
      boolean isEmpty()
      Returns true if the list contains no elements, false otherwise.
      void remove​(int index)
      Removes the element at the specified index.
      T set​(int index, T element)
      Replaces the element at the specified index with the specified element.
      int size()
      Returns the number of elements in the list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • list

        private final java.util.ArrayList<T> list
    • Constructor Detail

      • SimpleArrayList

        public SimpleArrayList()
        Creates a new instance of SimpleArrayList.
      • SimpleArrayList

        public SimpleArrayList​(int initialCapacity)
        Creates a new instance of SimpleArrayList with the specified initial capacity.
        Parameters:
        initialCapacity - the initial capacity of the list
    • Method Detail

      • add

        public void add​(T element)
        Adds an element to the end of the list.
        Specified by:
        add in interface ISimpleList<T>
        Parameters:
        element - the element to add
      • add

        public void add​(int index,
                        T element)
        Adds an element to the list at the specified index.
        Specified by:
        add in interface ISimpleList<T>
        Parameters:
        index - the index at which to add the element
        element - the element to add
      • get

        public T get​(int index)
        Returns the element at the specified index.
        Specified by:
        get in interface ISimpleList<T>
        Parameters:
        index - the index of the element to return
        Returns:
        the element at the specified index
      • set

        public T set​(int index,
                     T element)
        Replaces the element at the specified index with the specified element.
        Specified by:
        set in interface ISimpleList<T>
        Parameters:
        index - the index of the element to replace
        element - the element to be stored at the specified index
        Returns:
        the element previously at the specified index
      • indexOf

        public int indexOf​(java.lang.Object element)
        Returns the index of the first occurrence of the specified element in the list, or -1 if the list does not contain the element.
        Specified by:
        indexOf in interface ISimpleList<T>
        Parameters:
        element - the element to search for
        Returns:
        the index of the first occurrence of the specified element in the list, or -1 if the list does not contain the element
      • remove

        public void remove​(int index)
        Removes the element at the specified index.
        Specified by:
        remove in interface ISimpleList<T>
        Parameters:
        index - the index of the element to be removed
      • size

        public int size()
        Returns the number of elements in the list.
        Specified by:
        size in interface ISimpleList<T>
        Returns:
        the number of elements in the list
      • isEmpty

        public boolean isEmpty()
        Returns true if the list contains no elements, false otherwise.
        Specified by:
        isEmpty in interface ISimpleList<T>
        Returns:
        true if the list contains no elements, false otherwise