Intel

Developer Zone

LinkedList

com.intel.langutil

Class LinkedList<E>

  • java.lang.Object
    • com.intel.langutil.LinkedList<E>


  • public abstract class LinkedList<E>
    extends java.lang.Object
    This class provides an implementation of a generic singly linked list.
    • Method Summary

      Methods
      Modifier and Type Method and Description
      abstract void add(E element)
      Adds an element to the end of the list
      abstract void add(E[] elements)
      Adds an array of elements to the end of the list
      abstract void addFirst(E element)
      Adds an element to the beginning of the list
      abstract void addLast(E element)
      Adds an element to the end of the list
      abstract void clear()
      Removes all elements from the list
      abstract boolean contains(E element)
      Returns true iff the list contains the element
      static <I> LinkedList<I> create()
      Factory method for creating concrete generic linked lists
      abstract E getFirst()
      Returns the first element in the list
      abstract Iterator<E> getIterator()
      Returns an iterator for this LinkedList.
      abstract E getLast()
      Returns the last element in the list
      abstract boolean isEmpty()
      Returns whether the list is empty
      abstract E remove()
      Returns and removes the first element in the list
      abstract int remove(E element)
      Removes all the occurrence of element from the list
      abstract E removeFirst()
      Returns and removes the first element in the list
      abstract E removeLast()
      Returns and removes the last element in the list
      abstract int size()
      Returns the number of elements in the list
      abstract void toArray(E[] array)
      Exports the list to array of elements.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, toString
    • Method Detail

      • create

        public static final <I> LinkedList<I> create()
        Factory method for creating concrete generic linked lists
        Returns:
        a generic LinkedList instance
      • add

        public abstract void add(E element)
        Adds an element to the end of the list
        Parameters:
        element - the element to add to the list
      • addLast

        public abstract void addLast(E element)
        Adds an element to the end of the list
        Parameters:
        element - the element to add to the list
      • addFirst

        public abstract void addFirst(E element)
        Adds an element to the beginning of the list
        Parameters:
        element - the element to add to the list
      • add

        public abstract void add(E[] elements)
        Adds an array of elements to the end of the list
        Parameters:
        elements - an array of elements to add to the list
      • contains

        public abstract boolean contains(E element)
        Returns true iff the list contains the element
        Parameters:
        element - the element to query
      • clear

        public abstract void clear()
        Removes all elements from the list
      • size

        public abstract int size()
        Returns the number of elements in the list
        Returns:
        returns the number of elements in the list
      • isEmpty

        public abstract boolean isEmpty()
        Returns whether the list is empty
        Returns:
        returns true iff the list is empty
      • getFirst

        public abstract E getFirst()
                            throws java.util.NoSuchElementException
        Returns the first element in the list
        Returns:
        returns the first element in the list
        Throws:
        java.util.NoSuchElementException - if the list is empty
      • getLast

        public abstract E getLast()
                           throws java.util.NoSuchElementException
        Returns the last element in the list
        Returns:
        returns the last element in the list
        Throws:
        java.util.NoSuchElementException - if the list is empty
      • remove

        public abstract E remove()
                          throws java.util.NoSuchElementException
        Returns and removes the first element in the list
        Returns:
        returns the first element in the list
        Throws:
        java.util.NoSuchElementException - if the list is empty
      • removeFirst

        public abstract E removeFirst()
                               throws java.util.NoSuchElementException
        Returns and removes the first element in the list
        Returns:
        returns the first element in the list
        Throws:
        java.util.NoSuchElementException - if the list is empty
      • removeLast

        public abstract E removeLast()
                              throws java.util.NoSuchElementException
        Returns and removes the last element in the list
        Returns:
        returns the first element in the list
        Throws:
        java.util.NoSuchElementException - if the list is empty
      • remove

        public abstract int remove(E element)
        Removes all the occurrence of element from the list
        Parameters:
        element - the element to remove
        Returns:
        returns the number of occurrences removed
      • toArray

        public abstract void toArray(E[] array)
        Exports the list to array of elements. The array must have at least size() elements.
        Parameters:
        array - the array for output with the elements from the list
      • getIterator

        public abstract Iterator<E> getIterator()
        Returns an iterator for this LinkedList. If the LinkedList instance is modified during iteration, the Iterator behavior is unexpected.
        Returns:
        the iterator for this LinkedList instance.