Class BaseList<T>

    • Constructor Detail

      • BaseList

        protected BaseList()
        Creates an empty BaseList object.
      • BaseList

        protected BaseList​(BaseList<T> original)
        Copy constructor.
        Parameters:
        original - the original object to duplicate (can be null).
    • Method Detail

      • size

        public int size()
        Gets the number of objects in this list.
        Returns:
        the number of objects in this list.
      • isEmpty

        public boolean isEmpty()
        Indicates if this list is empty.
        Returns:
        true if there is no object in this list, false if there is one or more.
      • clear

        public void clear()
        Removes all objects in this list.
      • add

        public T add​(T object)
        Adds an object to this list.
        Parameters:
        object - the object to add.
        Returns:
        the object that was added.
      • remove

        public void remove​(int index)
        Removes from this list the object at the given index position.
        Parameters:
        index - the index position.
        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • remove

        public void remove​(T object)
        Removes a given object from this list. If the object is not in the list nothing changes.
        Parameters:
        object - the object to remove.
      • get

        public T get​(int index)
        Gets the object at a given index position.
        Parameters:
        index - the index position.
        Returns:
        the object at the given index.
        Throws:
        IndexOutOfBoundsException - if the index is invalid.
      • set

        public T set​(int index,
                     T object)
        Replaces an existing object by a new one at a given index position.
        Parameters:
        index - the index position.
        object - the new object to set.
        Returns:
        the object that was set.
        Throws:
        IndexOutOfBoundsException - if the index is invalid.