Class LinkedList<E>
java.lang.Object
ch.nolix.base.datastructure.extendediterable.AbstractExtendedIterable<E>
ch.nolix.base.datastructure.linkedlist.LinkedList<E>
- Type Parameters:
E- the type of the elements of aLinkedList.
- All Implemented Interfaces:
IterableWithCopyableIterator<E>, ExtendedIterable<E>, IterableFilterProvider<E>, IterableFilterViewProvider<E>, IterableGroupProvider<E>, IterableIntervalViewProvider<E>, IterableMappedProvider<E>, IterableMappedViewProvider<E>, IterableOrderProvider<E>, IterableArrayProvider<E>, IterableByExtremumProvider<E>, IterableByIndexProvider<E>, IterableFirstProvider<E>, IterableLastProvider<E>, IterableStringProvider, IterableContainAnyRequestable, IterableContainEqualRequestable<E>, IterableContainMatchingRequestable<E>, IterableContainMultipleRequestable, IterableContainObjectRequestable, IterableOneBasedIndexRequestable<E>, IAppendableList<E>, ILinkedList<E>, AggregationRequestable<E>, BaseCountRequestable, CountRequestable<E>, SingleProvider<E>, Copyable<ILinkedList<E>>, Clearable, EmptinessRequestable, MaterializationRequestable, Iterable<E>
A
LinkedList is a AbstractExtendedIterable that can add
elements at the begin or end. A LinkedList is clearable.- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAtBegin(E element) Adds the given element at the begin of the currentILinkedList.voidaddAtBegin(E... elements) The time complexity of this implementation is O(n) if n elements are given.voidaddAtBegin(Iterable<? extends E> elements) Adds the given elements at the begin of the currentILinkedList.voidThe time complexity of this implementation is O(1).voidAdds the given elements at the end of the currentLinkedList.<T extends E>
voidaddAtEnd(T... elements) The time complexity of this implementation is O(n) if n elements are given.voidclear()The complexity of this implementation is O(n) when the currentLinkedListcontains n elements.static <T> LinkedList<T> booleanAn object equals a list if it is a list containing exactly the same elements.static <T> LinkedList<T> fromArray(T[] array) static <T> LinkedList<T> fromIterable(Iterable<T> container) getCopy()The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.intgetCount()The time complexity of this implementation is O(1).getStoredAtOneBasedIndex(int oneBasedIndex) The time complexity of this implementation is O(n) if the currentAbstractExtendedIterablecontains n elements.inthashCode()booleanThe time complexity of this implementation is O(1).iterator()The time complexity of this implementation is O(1).voidThe time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.voidremoveAllOccurrencesOf(Object element) The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.The time complexity of this implementation is O(1).removeAndGetStoredFirst(Predicate<E> selector) The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.The time complexity of this implementation is O(1).voidThe time complexity of this implementation is O(1).voidremoveFirst(Predicate<E> selector) The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.voidremoveFirstOccurrenceOf(Object element) The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.voidThe time complexity of this implementation is O(1).voidThe time complexity of this implementation is O(n).voidThe time complexity of this implementation is O(n).voidremoveStrictlyFirstOccurrenceOf(Object element) The time complexity of this implementation is O(n).voidreplaceFirst(Predicate<E> selector, E element) The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.toString()The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.static <T> LinkedList<T> withElement(T... element) static <T> LinkedList<T> withElements(T... elements) Methods inherited from class AbstractExtendedIterable
contains, containsAll, containsAll, containsAny, containsAny, containsAny, containsEqual, containsExactlyAllEqualInSameOrder, containsExactlyInSameOrder, containsMatching, containsMatchingOnly, containsNoEqual, containsNoMatching, containsNone, containsNone, containsNonNull, containsOnce, containsOne, containsOneEqual, containsOneMatching, containsOneNoneNull, containsOnly, getAverage, getAverageOrZero, getCount, getCountOf, getMax, getMaxOrZero, getMedian, getMedianOrZero, getMin, getMinOrZero, getOneBasedIndexOfFirst, getOneBasedIndexOfFirstEqualElement, getOneBasedIndexOfFirstOccurrenceOf, getOptionalStoredFirst, getOptionalStoredFirst, getStandardDeviation, getStoredByMax, getStoredByMin, getStoredFirst, getStoredFirst, getStoredFirstNonNull, getStoredFirstOfType, getStoredInGroups, getStoredLast, getStoredOfType, getStoredOthers, getStoredSelected, getStoredSingle, getStoredSingle, getSum, getSumOfInts, getVariance, getViewFromOneBasedStartIndex, getViewFromOneBasedStartIndexToOneBasedEndIndex, getViewOf, getViewOfStoredSelected, getViewToOneBasedEndIndex, getViewWithoutFirst, getViewWithoutFirst, getViewWithoutLast, getViewWithoutLast, isEmpty, to, toArray, toByteArray, toCharArray, toConcatenatedString, toDoubleArray, toIntArray, toLongArray, toMultiples, toNumbers, toOrdered, toReversed, toStringArray, toStrings, toStringWithDelimiter, toStringWithDelimiter, toWithOneBasedIndexMethods inherited from interface AggregationRequestable
getAverage, getAverageOrZero, getMax, getMaxOrZero, getMedian, getMedianOrZero, getMin, getMinOrZero, getStandardDeviation, getSum, getSumOfInts, getVarianceMethods inherited from interface CountRequestable
getCount, getCountOfMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface IterableArrayProvider
toArray, toByteArray, toCharArray, toDoubleArray, toIntArray, toLongArray, toStringArrayMethods inherited from interface IterableByExtremumProvider
getStoredByMax, getStoredByMinMethods inherited from interface IterableContainAnyRequestable
containsAny, containsNonNull, containsOne, containsOneNoneNull, isEmptyMethods inherited from interface IterableContainEqualRequestable
containsEqual, containsNoEqual, containsOneEqualMethods inherited from interface IterableContainMatchingRequestable
containsMatching, containsMatchingOnly, containsNoMatching, containsOneMatchingMethods inherited from interface IterableContainMultipleRequestable
containsAll, containsAll, containsAny, containsAny, containsExactlyAllEqualInSameOrder, containsExactlyInSameOrder, containsNone, containsNoneMethods inherited from interface IterableContainObjectRequestable
contains, containsOnce, containsOnlyMethods inherited from interface IterableFilterProvider
getStoredOfType, getStoredOthers, getStoredSelectedMethods inherited from interface IterableFilterViewProvider
getViewOfStoredSelectedMethods inherited from interface IterableFirstProvider
getOptionalStoredFirst, getOptionalStoredFirst, getStoredFirst, getStoredFirst, getStoredFirstNonNull, getStoredFirstOfTypeMethods inherited from interface IterableGroupProvider
getStoredInGroupsMethods inherited from interface IterableIntervalViewProvider
getViewFromOneBasedStartIndex, getViewFromOneBasedStartIndexToOneBasedEndIndex, getViewToOneBasedEndIndex, getViewWithoutFirst, getViewWithoutFirst, getViewWithoutLast, getViewWithoutLastMethods inherited from interface IterableLastProvider
getStoredLastMethods inherited from interface IterableMappedProvider
to, toMultiples, toNumbers, toStrings, toWithOneBasedIndexMethods inherited from interface IterableMappedViewProvider
getViewOfMethods inherited from interface IterableOneBasedIndexRequestable
getOneBasedIndexOfFirst, getOneBasedIndexOfFirstEqualElement, getOneBasedIndexOfFirstOccurrenceOfMethods inherited from interface IterableOrderProvider
toOrdered, toReversedMethods inherited from interface IterableStringProvider
toConcatenatedString, toStringWithDelimiter, toStringWithDelimiterMethods inherited from interface MaterializationRequestable
isViewMethods inherited from interface SingleProvider
getStoredSingle, getStoredSingle
-
Method Details
-
createEmpty
- Type Parameters:
T- the type of the elements of the createdLinkedList- Returns:
- a new empty
LinkedList.
-
fromArray
- Type Parameters:
T- the type of the elements of the given array- Parameters:
array-- Returns:
- a new
LinkedListwith the elements in the given array - Throws:
RuntimeException- if the given array is nullRuntimeException- if one of the elements in the given array is null
-
fromIterable
- Type Parameters:
T- the type of the elements of the given container- Parameters:
container-- Returns:
- a new
LinkedListwith the elements in the given container - Throws:
RuntimeException- if the given container is nullRuntimeException- if one of the elements in the given container is null.
-
withElement
- Type Parameters:
T- the type of the given element- Parameters:
element-- Returns:
- a new
LinkedListwith the given element - Throws:
RuntimeException- if one of the given element is null
-
withElements
- Type Parameters:
T- the type of the given elements- Parameters:
elements-- Returns:
- a new
LinkedListwith the given elements - Throws:
RuntimeException- if one of the given elements is null
-
addAtBegin
Adds the given element at the begin of the currentILinkedList.- Specified by:
addAtBeginin interfaceILinkedList<E>- Parameters:
element-
-
addAtBegin
The time complexity of this implementation is O(n) if n elements are given. Adds the given elements at the begin of the currentILinkedList. The elements will be added in the given order.- Specified by:
addAtBeginin interfaceILinkedList<E>- Parameters:
elements-
-
addAtBegin
Adds the given elements at the begin of the currentILinkedList. The elements will be added in the given order.- Specified by:
addAtBeginin interfaceILinkedList<E>- Parameters:
elements-
-
addAtEnd
The time complexity of this implementation is O(1). Adds the given element at the end of the currentIAppendableList.- Specified by:
addAtEndin interfaceIAppendableList<E>- Parameters:
element-
-
addAtEnd
Adds the given elements at the end of the currentLinkedList. The complexity of this implementation is O(n) if n elements are given. Adds the given elements at the end of the currentIAppendableList. The elements will be added in the given order.- Specified by:
addAtEndin interfaceIAppendableList<E>- Parameters:
elements-
-
addAtEnd
The time complexity of this implementation is O(n) if n elements are given. Adds the given elements at the end of the currentIAppendableList. The elements will be added in the given order.- Specified by:
addAtEndin interfaceIAppendableList<E>- Type Parameters:
T- the type of the given elements- Parameters:
elements-
-
clear
public void clear()The complexity of this implementation is O(n) when the currentLinkedListcontains n elements. Removes the elements of the currentClearable. -
equals
-
getCopy
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. -
getCount
public int getCount()The time complexity of this implementation is O(1).- Specified by:
getCountin interfaceBaseCountRequestable- Returns:
- the number of elements of the current
LinkedList.
-
getStoredAtOneBasedIndex
The time complexity of this implementation is O(n) if the currentAbstractExtendedIterablecontains n elements.- Specified by:
getStoredAtOneBasedIndexin interfaceIterableByIndexProvider<E>- Parameters:
oneBasedIndex-- Returns:
- the element at the given index
- Throws:
RuntimeException- if the given index is not positiveArgumentDoesNotHaveAttributeException- if the currentAbstractExtendedIterabledoes not contain an element at the given index.
-
hashCode
-
isMaterialized
public boolean isMaterialized()The time complexity of this implementation is O(1).- Specified by:
isMaterializedin interfaceMaterializationRequestable- Returns:
- true if the current
MaterializationRequestableis materialized, false otherwise
-
iterator
The time complexity of this implementation is O(1).- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin interfaceIterableWithCopyableIterator<E>- Returns:
- a new iterator of the current
LinkedList.
-
removeAll
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. Removes all elements from the currentILinkedListthe given selector selects.- Specified by:
removeAllin interfaceILinkedList<E>- Parameters:
selector-
-
removeAllOccurrencesOf
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. Removes all occurrences of the given element from the currentILinkedList.- Specified by:
removeAllOccurrencesOfin interfaceILinkedList<E>- Parameters:
element-
-
removeAndGetStoredFirst
The time complexity of this implementation is O(1). Removes and returns the first element of the currentILinkedList.- Specified by:
removeAndGetStoredFirstin interfaceILinkedList<E>- Returns:
- the first element of the current
ILinkedList
-
removeAndGetStoredFirst
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. Removes and returns the first element the given selector selects from the currentILinkedList.- Specified by:
removeAndGetStoredFirstin interfaceILinkedList<E>- Parameters:
selector-- Returns:
- the first element the given selector selects from the current
ILinkedList
-
removeAndGetStoredLast
The time complexity of this implementation is O(1). Removes and returns the last element of the currentILinkedList.- Specified by:
removeAndGetStoredLastin interfaceILinkedList<E>- Returns:
- the last element of the current
ILinkedList
-
removeFirst
public void removeFirst()The time complexity of this implementation is O(1). Removes the first element from the currentILinkedList- Specified by:
removeFirstin interfaceILinkedList<E>
-
removeFirstStrictly
public void removeFirstStrictly()The time complexity of this implementation is O(1). Removes the first element from the currentILinkedList.- Specified by:
removeFirstStrictlyin interfaceILinkedList<E>
-
removeFirst
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. Removes the first element the given selector selects from the currentILinkedList- Specified by:
removeFirstin interfaceILinkedList<E>- Parameters:
selector-
-
removeFirstOccurrenceOf
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. Removes the first occurrence of the given element from the currentILinkedList.- Specified by:
removeFirstOccurrenceOfin interfaceILinkedList<E>- Parameters:
element-
-
removeLast
public void removeLast()The time complexity of this implementation is O(n). Removes the last element from the currentILinkedList.- Specified by:
removeLastin interfaceILinkedList<E>
-
removeLastStrictly
public void removeLastStrictly()The time complexity of this implementation is O(n). Removes the last element from the currentILinkedList.- Specified by:
removeLastStrictlyin interfaceILinkedList<E>
-
removeStrictlyFirstOccurrenceOf
The time complexity of this implementation is O(n). Removes the first occurrence of the given element from the currentILinkedList.- Specified by:
removeStrictlyFirstOccurrenceOfin interfaceILinkedList<E>- Parameters:
element-
-
replaceFirst
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements. Replaces the first element the given selector selects from the currentILinkedListwith the given element.- Specified by:
replaceFirstin interfaceILinkedList<E>- Parameters:
selector-element-
-
toString
The time complexity of this implementation is O(n) if the currentLinkedListcontains n elements.
-