Interface IterableFirstProvider<E>
- Type Parameters:
E- the type of the elements aIterableFirstProvider
- All Known Subinterfaces:
ExtendedIterable<E>, IAppendableList<E>, IArrayList<E>, ILinkedList<E>, IMatrix<E>, IMatrixColumn<E>, IMatrixRow<E>, ISqlRecord
- All Known Implementing Classes:
AbstractExtendedIterable, ArrayExtendedIterableView, ArrayList, ExtendedIterableFilterView, ExtendedIterableIntervalView, ExtendedIterableMapperView, ExtendedIterableView, ImmutableList, IterableExtendedIterableView, LinkedList, Matrix, MatrixColumn, MatrixRow, MultiExtendedIterableView, SqlRecord
public interface IterableFirstProvider<E>
- Author:
- Silvan Wyss
-
Method Summary
Modifier and TypeMethodDescriptionThe time complexity of this method is O(1).getOptionalStoredFirst(Predicate<? super E> selector) The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.The time complexity of this method is O(1).getStoredFirst(Predicate<? super E> selector) The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.<T extends E>
TgetStoredFirstOfType(Class<T> type) The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.
-
Method Details
-
getOptionalStoredFirst
The time complexity of this method is O(1).- Returns:
- a
Optionalwith the first element of the currentIterableFirstProviderif the currentIterableFirstProvideris not empty and if the first element of the currentIterableFirstProvideris not null, an emptyOptionalotherwise
-
getOptionalStoredFirst
The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.- Parameters:
selector- can select elements, is considered not to select any element when is null- Returns:
- a new
Optionalwith the first element the given selector selects from the currentIterableFirstProviderif the currentIterableFirstProvidercontains an element the given selector selects, an emptyOptionalotherwise, ignoring null elements
-
getStoredFirst
E getStoredFirst()The time complexity of this method is O(1).- Returns:
- the first element of the current
IterableFirstProvider - Throws:
RuntimeException- if the currentIterableFirstProvideris empty
-
getStoredFirst
The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.- Parameters:
selector- can select elements, is considered not to select any element when is null- Returns:
- the first element the given selector selects from the current
IterableFirstProvider, ignoring null elements - Throws:
RuntimeException- if the currentIterableFirstProviderdoes not contain an element the given selector selects
-
getStoredFirstNonNull
E getStoredFirstNonNull()The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.- Returns:
- the first non-null element of the current
IterableFirstProvider - Throws:
RuntimeException- if the currentIterableFirstProviderdoes not contain a non-null element
-
getStoredFirstOfType
The time complexity of this method is O(n) if the currentIterableFirstProvidercontains n elements.- Type Parameters:
T- the modeled type of the given type- Parameters:
type-- Returns:
- the first element from the current
IterableFirstProviderthat is of the given type - Throws:
RuntimeException- if the given type is nullRuntimeException- if the currentIterableFirstProviderdoes not contain an element of the given type
-