Class EfficientList<E>

    • Constructor Summary

      Constructors 
      Constructor Description
      EfficientList()
      Constructor for this class.
      EfficientList​(int capacity)
      Constructor for this class.
      EfficientList​(E[] data)
      Constructor for this class.
      EfficientList​(java.util.List<E> data)
      Constructor for this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E element)
      Adds an element to the list.
      void clear()
      Clears the list.
      boolean contains​(E element)
      Checks if an element is in the list or not.
      E get​(int index)
      Gets an element from the list.
      int indexOf​(E element)
      Gets the index of an element in the list.
      boolean isEmpty()
      Checks if the list is empty or not.
      boolean remove​(E element)
      Removes an existing element from the list.
      boolean set​(int index, E element)
      Sets an existing element in the list to something else.
      int size()
      Gets the current size of the list.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EfficientList

        public EfficientList​(int capacity)
        Constructor for this class. Initiates list with capacity.
        Parameters:
        capacity - The initial capacity of the list.
      • EfficientList

        public EfficientList​(E[] data)
        Constructor for this class. Initiates list with data.
        Parameters:
        data - The initial data for the list.
      • EfficientList

        public EfficientList​(java.util.List<E> data)
        Constructor for this class. Initiates list with data.
        Parameters:
        data - The initial data for the list.
      • EfficientList

        public EfficientList()
        Constructor for this class. No initiate data or capacity.
    • Method Detail

      • size

        public int size()
        Gets the current size of the list.
        Specified by:
        size in interface InterfaceList<E>
        Returns:
        The size of the list.
      • isEmpty

        public boolean isEmpty()
        Checks if the list is empty or not.
        Specified by:
        isEmpty in interface InterfaceList<E>
        Returns:
        Whether or not the list is empty.
      • add

        public boolean add​(E element)
        Adds an element to the list.
        Specified by:
        add in interface InterfaceList<E>
        Parameters:
        element - The element to add to the list.
        Returns:
        Whether or not the element has been successfully added to the list.
      • clear

        public void clear()
        Clears the list.
        Specified by:
        clear in interface InterfaceList<E>
      • get

        public E get​(int index)
        Gets an element from the list.
        Specified by:
        get in interface InterfaceList<E>
        Parameters:
        index - The index of the element in the list.
        Returns:
        The element from the list.
      • set

        public boolean set​(int index,
                           E element)
        Sets an existing element in the list to something else.
        Specified by:
        set in interface InterfaceList<E>
        Parameters:
        index - The index of the existing element in the list.
        element - The new element to replace the existing one with.
        Returns:
        Whether or not the element has been successfully set.
      • remove

        public boolean remove​(E element)
        Removes an existing element from the list.
        Specified by:
        remove in interface InterfaceList<E>
        Parameters:
        element - The existing element from the list.
        Returns:
        Whether or not the element has been successfully removed.
      • indexOf

        public int indexOf​(E element)
        Gets the index of an element in the list.
        Specified by:
        indexOf in interface InterfaceList<E>
        Parameters:
        element - The element to look for in the list.
        Returns:
        The index of the element in the list.
      • contains

        public boolean contains​(E element)
        Checks if an element is in the list or not.
        Specified by:
        contains in interface InterfaceList<E>
        Parameters:
        element - The element to check.
        Returns:
        Whether or not the element is in the list.