Class ArrayList<E>
java.lang.Object
ch.nolix.base.datastructure.extendediterable.AbstractExtendedIterable<E>
ch.nolix.base.datastructure.arraylist.ArrayList<E>
- Type Parameters:
E- the type of the elements of aArrayList
- 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>, IArrayList<E>, AggregationRequestable<E>, BaseCountRequestable, CountRequestable<E>, SingleProvider<E>, Copyable<IArrayList<E>>, Clearable, EmptinessRequestable, MaterializationRequestable, Iterable<E>
- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionvoidThe time complexity of this implementation is O(n) when the currentArrayListcontains n elements.voidThe time complexity of this implementation is O(n+m) when the currentArrayListcontains n elements and m elements are given.<T extends E>
voidaddAtEnd(T... elements) The time complexity of this implementation is O(n+m) when the currentArrayListcontains n elements and m elements are given.voidclear()The time complexity of this implementation is O(1).static <T> ArrayList<T> getCopy()The time complexity of this implementation is O(n) when the currentArrayListcontains n elements.intgetCount()The time complexity of this implementation is O(1).getStoredAtOneBasedIndex(int oneBasedIndex) The time complexity of this implementation is O(1).voidinsertAtOneBasedIndex(int oneBasedIndex, E element) booleanThe time complexity of this implementation is O(1).iterator()The time complexity of this implementation is O(1).Object[]toArray()The time complexity of this implementation is O(n) if the currentAbstractExtendedIterablecontains n elements.toString()The time complexity of this implementation is O(n) if the currentArrayListcontains n elements.static <T> ArrayList<T> withElements(T... elements) The time complexity of this implementation is O(n) when n elements are given.static <T> ArrayList<T> withInitialCapacity(int initialCapacity) The time complexity of this implementation is O(1).static <T> ArrayList<T> withInitialCapacityFromSizeOfContainer(CountRequestable<?> container) The time complexity of this implementation is O(1).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, 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
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
-
withElements
The time complexity of this implementation is O(n) when n elements are given.- Type Parameters:
T- the type of the given elements- Parameters:
elements-- Returns:
- a new
ArrayListwith the given elements - Throws:
RuntimeException- if the given elements is nullRuntimeException- if one of the given elements is null
-
withInitialCapacity
The time complexity of this implementation is O(1).- Type Parameters:
T- the type of the elements of the createdArrayList- Parameters:
initialCapacity-- Returns:
- a new
ArrayListwith the given initialCapacity - Throws:
RuntimeException- if the given initialCapacity is negative
-
withInitialCapacityFromSizeOfContainer
public static <T> ArrayList<T> withInitialCapacityFromSizeOfContainer(CountRequestable<?> container) The time complexity of this implementation is O(1).- Type Parameters:
T- the type of the elements of the createdArrayList- Parameters:
container-- Returns:
- a new
ArrayListwith a initialCapacity that is the size of the given container - Throws:
NullPointerException- if the given container is null
-
addAtEnd
The time complexity of this implementation is O(n) when the currentArrayListcontains n elements. Adds the given element at the end of the currentIAppendableList.- Specified by:
addAtEndin interfaceIAppendableList<E>- Parameters:
element-
-
addAtEnd
The time complexity of this implementation is O(n+m) when the currentArrayListcontains n elements and m 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+m) when the currentArrayListcontains n elements and m 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
-
getCopy
-
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
BaseCountRequestable
-
getStoredAtOneBasedIndex
The time complexity of this implementation is O(1).- Specified by:
getStoredAtOneBasedIndexin interfaceIterableByIndexProvider<E>- Parameters:
oneBasedIndex-- Returns:
- the element at the given oneBasedIndex from the current
IterableByIndexProvider
-
insertAtOneBasedIndex
The time complexity of this implementation is O(n) if the given oneBasedIndex is bigger than the number of the elements of the currentArrayListand the currentArrayListcontains n elements. The time complexity of this implementation is O(1) if the given oneBasedIndex is not bigger than the number of the elements of the currentArrayListAdds the given element at the given oneBasedIndex- Specified by:
insertAtOneBasedIndexin interfaceIArrayList<E>- Parameters:
oneBasedIndex-element-
-
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). -
toArray
The time complexity of this implementation is O(n) if the currentAbstractExtendedIterablecontains n elements. The time complexity of this method is O(n) if the currentIterableArrayProvidercontains n elements.- Specified by:
toArrayin interfaceIterableArrayProvider<E>- Overrides:
toArrayin classAbstractExtendedIterable<E>- Returns:
- a new array with the elements of the current
IterableArrayProvider
-
toString
-