Interface CustomList<T>

Type Parameters:
T - the type of elements stored in the list
All Known Implementing Classes:
CustomArrayList

public interface CustomList<T>
This interface represents a custom list data structure that can store elements of type T. It provides methods to add, remove, access, and manipulate elements within the list. This interface is implemented by the CustomArrayClass.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int index, T element)
    Inserts the specified element at the specified index in the list.
    boolean
    add(T element)
    Adds the specified element to the end of the list.
    boolean
    addAll(T[] elements)
    Adds all the elements in the specified array to the end of the list.
    void
    Removes all elements from the list, leaving it empty.
    boolean
    contains(T element)
    Checks if the list contains the specified element.
    get(int index)
    Returns the element at the specified index in the list.
    int
    indexOf(T element)
    Returns the index of the first occurrence of the specified element in the list.
    remove(int index)
    Removes the element at the specified index in the list.
    boolean
    remove(T element)
    Removes the first occurrence of the specified element from the list.
    set(int index, T element)
    Replaces the element at the specified index with the specified element.
    int
    Returns the number of elements in the list.
  • Method Details

    • size

      int size()
      Returns the number of elements in the list.
      Returns:
      the number of elements in the list
    • get

      T get(int index)
      Returns the element at the specified index in the list.
      Parameters:
      index - the index of the element to retrieve
      Returns:
      the element at the specified index
    • add

      boolean add(T element)
      Adds the specified element to the end of the list.
      Parameters:
      element - the element to be added to the list
      Returns:
      true if the element was successfully added, false otherwise
    • add

      void add(int index, T element)
      Inserts the specified element at the specified index in the list.
      Parameters:
      index - the index at which to insert the element
      element - the element to be inserted
    • addAll

      boolean addAll(T[] elements)
      Adds all the elements in the specified array to the end of the list.
      Parameters:
      elements - the array of elements to be added to the list
      Returns:
      true if all elements were successfully added, false otherwise
    • remove

      T remove(int index)
      Removes the element at the specified index in the list.
      Parameters:
      index - the index of the element to be removed
      Returns:
      the removed element
    • remove

      boolean remove(T element)
      Removes the first occurrence of the specified element from the list.
      Parameters:
      element - the element to be removed
      Returns:
      true if the element was successfully removed, false otherwise
    • contains

      boolean contains(T element)
      Checks if the list contains the specified element.
      Parameters:
      element - the element to check for in the list
      Returns:
      true if the element is found in the list, false otherwise
    • set

      T set(int index, T element)
      Replaces the element at the specified index with the specified element.
      Parameters:
      index - the index of the element to replace
      element - the new element to set at the specified index
      Returns:
      the element previously at the specified index
    • indexOf

      int indexOf(T element)
      Returns the index of the first occurrence of the specified element in the list.
      Parameters:
      element - the element to search for in the list
      Returns:
      the index of the element, or -1 if the element is not found
    • clear

      void clear()
      Removes all elements from the list, leaving it empty.