Klasse LinkedList<E>

java.lang.Object
ch.nolix.core.container.base.Container<E>
ch.nolix.core.container.linkedlist.LinkedList<E>
Typparameter:
E - is the type of the elements of a LinkedList.
Alle implementierten Schnittstellen:
IContainer<E>, IMappableContainer<E>, ISearchableContainer<E>, IStatisticalConainer<E>, IterableWithCopyableIterator<E>, StoringRequestable<E>, ILinkedList<E>, Copyable<ILinkedList<E>>, Clearable, EmptinessRequestable, MaterializationRequestable, Iterable<E>

public final class LinkedList<E> extends Container<E> implements ILinkedList<E>
A LinkedList is a Container that can add elements at the begin or end. A LinkedList is clearable.
Version:
2016-01-01
Autor:
Silvan Wyss
  • Konstruktordetails

    • LinkedList

      public LinkedList()
  • Methodendetails

    • fromArray

      public static <E2> LinkedList<E2> fromArray(E2[] array)
      Typparameter:
      E2 - is the type of the elements of the given array.
      Parameter:
      array -
      Gibt zurück:
      a new LinkedList with the elements in the given array.
      Löst aus:
      ArgumentIsNullException - if the given array is null.
      ArgumentIsNullException - if one of the elements in the given array is null.
    • fromIterable

      public static <E2> LinkedList<E2> fromIterable(Iterable<E2> container)
      Typparameter:
      E2 - is the type of the elements of the given container.
      Parameter:
      container -
      Gibt zurück:
      a new LinkedList with the elements in the given container.
      Löst aus:
      ArgumentIsNullException - if the given container is null.
      ArgumentIsNullException - if one of the elements in the given container is null.
    • withElement

      public static <E2> LinkedList<E2> withElement(E2 element, E2... elements)
      Typparameter:
      E2 - is the type of the given elements.
      Parameter:
      element -
      elements -
      Gibt zurück:
      a new LinkedList with the given elements.
      Löst aus:
      ArgumentIsNullException - if the given element or one of the given elements is null.
    • addAtBegin

      public void addAtBegin(E element)
      Adds the given element at the begin of the current ILinkedList.
      Angegeben von:
      addAtBegin in Schnittstelle ILinkedList<E>
      Parameter:
      element -
    • addAtBegin

      public void addAtBegin(E element, E... elements)
      Adds the given element and the given elements at the begin of the current ILinkedList. The elements will be added in the given order.
      Angegeben von:
      addAtBegin in Schnittstelle ILinkedList<E>
      Parameter:
      element -
      elements -
    • addAtBegin

      public void addAtBegin(E[] elements)
      The complexity of this implementation is O(n) if n elements are given. Adds the given elements at the begin of the current ILinkedList. The elements will be added in the given order.
      Angegeben von:
      addAtBegin in Schnittstelle ILinkedList<E>
      Parameter:
      elements -
    • addAtBegin

      public void addAtBegin(Iterable<? extends E> elements)
      Adds the given elements at the begin of the current ILinkedList. The elements will be added in the given order.
      Angegeben von:
      addAtBegin in Schnittstelle ILinkedList<E>
      Parameter:
      elements -
    • addAtEnd

      public void addAtEnd(E element)
      The complexity of this implementation is O(1). Adds the given element at the end of the current ILinkedList.
      Angegeben von:
      addAtEnd in Schnittstelle ILinkedList<E>
      Parameter:
      element -
    • addAtEnd

      @SafeVarargs public final void addAtEnd(E element, E... elements)
      The complexity of this implementation is O(n) if n elements are given. Adds the given element and the given elements at the end of the current ILinkedList. The elements will be added in the given order.
      Angegeben von:
      addAtEnd in Schnittstelle ILinkedList<E>
      Parameter:
      element -
      elements -
    • addAtEnd

      public void addAtEnd(E[] elements)
      The complexity of this implementation is O(n) if n elements are given. Adds the given elements at the end of the current ILinkedList. The elements will be added in the given order.
      Angegeben von:
      addAtEnd in Schnittstelle ILinkedList<E>
      Parameter:
      elements -
    • addAtEnd

      public void addAtEnd(Iterable<? extends E> elements)
      Adds the given elements at the end of the current LinkedList. The complexity of this implementation is O(n) if n elements are given.
      Angegeben von:
      addAtEnd in Schnittstelle ILinkedList<E>
      Parameter:
      elements -
      Löst aus:
      ArgumentIsNullException - if one of the given elements is null.
    • clear

      public void clear()
      Removes all elements of the current LinkedList. The complexity of this implementation is O(n) when the current LinkedList contains n elements.
      Angegeben von:
      clear in Schnittstelle Clearable
    • equals

      public boolean equals(Object object)
      An object equals a list if it is a list containing exactly the same elements.
      Setzt außer Kraft:
      equals in Klasse Object
    • getCopy

      public ILinkedList<E> getCopy()
      The complexity of this implementation is O(n) if the current LinkedList contains n elements.
      Angegeben von:
      getCopy in Schnittstelle Copyable<E>
      Gibt zurück:
      a copy of the current Copyable.
    • getStoredAt1BasedIndex

      public E getStoredAt1BasedIndex(int p1BasedIndex)
      The complexity of this implementation is O(n) if the current Container contains n elements.
      Angegeben von:
      getStoredAt1BasedIndex in Schnittstelle ISearchableContainer<E>
      Parameter:
      p1BasedIndex -
      Gibt zurück:
      the element at the given index.
      Löst aus:
      NonPositiveArgumentException - if the given index is not positive.
      ArgumentDoesNotHaveAttributeException - if the current Container does not contain an element at the given index.
    • getStoredLast

      public E getStoredLast()
      The complexity of this implementation is O(1).
      Angegeben von:
      getStoredLast in Schnittstelle ISearchableContainer<E>
      Gibt zurück:
      the last element of the current LinkedList.
      Löst aus:
      EmptyArgumentException - if the current LinkedList is empty.
    • getCount

      public int getCount()
      The complexity of this implementation is O(1).
      Angegeben von:
      getCount in Schnittstelle IStatisticalConainer<E>
      Gibt zurück:
      the number of elements of the current LinkedList.
    • hashCode

      public int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object
    • isMaterialized

      public boolean isMaterialized()
      Angegeben von:
      isMaterialized in Schnittstelle MaterializationRequestable
      Gibt zurück:
      true if the current MaterializationRequestable is materialized, false otherwise.
    • iterator

      public CopyableIterator<E> iterator()
      The complexity of this implementation is O(1).
      Angegeben von:
      iterator in Schnittstelle Iterable<E>
      Angegeben von:
      iterator in Schnittstelle IterableWithCopyableIterator<E>
      Gibt zurück:
      a new iterator of the current LinkedList.
    • removeAll

      public void removeAll(Predicate<E> selector)
      The complexity of this implementation is O(n) if the current LinkedList contains n elements. Removes all elements from the current ILinkedList the given selector selects.
      Angegeben von:
      removeAll in Schnittstelle ILinkedList<E>
      Parameter:
      selector -
    • removeAllOccurrencesOf

      public void removeAllOccurrencesOf(Object element)
      The complexity of this implementation is O(n) if the current LinkedList contains n elements. Removes all occurrences of the given element from the current ILinkedList.
      Angegeben von:
      removeAllOccurrencesOf in Schnittstelle ILinkedList<E>
      Parameter:
      element -
    • removeAndGetStoredFirst

      public E removeAndGetStoredFirst()
      The complexity of this implementation is O(1). Removes and returns the first element of the current ILinkedList.
      Angegeben von:
      removeAndGetStoredFirst in Schnittstelle ILinkedList<E>
      Gibt zurück:
      the first element of the current ILinkedList.
    • removeAndGetStoredFirst

      public E removeAndGetStoredFirst(Predicate<E> selector)
      The complexity of this implementation is O(n) if the current LinkedList contains n elements. Removes and returns the first element the given selector selects from the current ILinkedList.
      Angegeben von:
      removeAndGetStoredFirst in Schnittstelle ILinkedList<E>
      Parameter:
      selector -
      Gibt zurück:
      the first element the given selector selects from the current ILinkedList.
    • removeAndGetStoredLast

      public E removeAndGetStoredLast()
      The complexity of this implementation is O(1). Removes and returns the last element of the current ILinkedList.
      Angegeben von:
      removeAndGetStoredLast in Schnittstelle ILinkedList<E>
      Gibt zurück:
      the last element of the current ILinkedList.
    • removeFirst

      public void removeFirst()
      The complexity of this implementation is O(1). Removes the first element from the current ILinkedList.
      Angegeben von:
      removeFirst in Schnittstelle ILinkedList<E>
    • removeFirstStrictly

      public void removeFirstStrictly()
      The complexity of this implementation is O(1). Removes the first element from the current ILinkedList.
      Angegeben von:
      removeFirstStrictly in Schnittstelle ILinkedList<E>
    • removeFirst

      public void removeFirst(Predicate<E> selector)
      The complexity of this implementation is O(n) if the current LinkedList contains n elements. Removes the first element the given selector selects from the current ILinkedList
      Angegeben von:
      removeFirst in Schnittstelle ILinkedList<E>
      Parameter:
      selector -
    • removeFirstOccurrenceOf

      public void removeFirstOccurrenceOf(Object element)
      The complexity of this implementation is O(n) if the current LinkedList contains n elements. Removes the first occurrence of the given element from the current ILinkedList.
      Angegeben von:
      removeFirstOccurrenceOf in Schnittstelle ILinkedList<E>
      Parameter:
      element -
    • removeLast

      public void removeLast()
      The complexity of this implementation is O(n). Removes the last element from the current ILinkedList.
      Angegeben von:
      removeLast in Schnittstelle ILinkedList<E>
    • removeLastStrictly

      public void removeLastStrictly()
      The complexity of this implementation is O(n). Removes the last element from the current ILinkedList.
      Angegeben von:
      removeLastStrictly in Schnittstelle ILinkedList<E>
    • removeStrictlyFirstOccurrenceOf

      public void removeStrictlyFirstOccurrenceOf(Object element)
      The complexity of this implementation is O(n). Removes the first occurrence of the given element from the current ILinkedList.
      Angegeben von:
      removeStrictlyFirstOccurrenceOf in Schnittstelle ILinkedList<E>
      Parameter:
      element -
    • replaceFirst

      public void replaceFirst(Predicate<E> selector, E element)
      The complexity of this implementation is O(n) if the current LinkedList contains n elements. Replaces the first element the given selector selects from the current ILinkedList with the given element.
      Angegeben von:
      replaceFirst in Schnittstelle ILinkedList<E>
      Parameter:
      selector -
      element -
    • toOrderedList

      public <C extends Comparable<C>> IContainer<E> toOrderedList(Function<E,C> norm)
      This implementation uses the merge sort algorithm. The complexity of this implementation is O(n*log(n)) if the current Container contains n elements.
      Angegeben von:
      toOrderedList in Schnittstelle IContainer<E>
      Typparameter:
      C - is the type of the Comparables the given norm returns.
      Parameter:
      norm -
      Gibt zurück:
      a new IContainer with the elements of the current IContainer ordered from the smallest to the biggest element according to the given norm.
    • toString

      public String toString()
      The complexity of this implementation is O(n) if the current LinkedList contains n elements.
      Setzt außer Kraft:
      toString in Klasse Object
    • createEmptyMutableList

      protected <E2> ILinkedList<E2> createEmptyMutableList(Marker<E2> marker)
      Angegeben von:
      createEmptyMutableList in Klasse Container<E>
      Typparameter:
      E2 - is the type of the elements the created ILinkedList can contain.
      Parameter:
      marker -
      Gibt zurück:
      a new empty ILinkedList.