Class IterableSearcher
java.lang.Object
ch.nolix.base.commontype.iterablesearcher.IterableSearcher
- All Implemented Interfaces:
IIterableCountSearcher, IIterableFirstElementSearcher, IIterableSearcher
- Author:
- Silvan Wyss
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint<E> intintgetCountOf(Iterable<?> iterable, Object object) <E> EgetStoredAtOneBasedIndex(Iterable<E> iterable, int oneBasedIndex) <E> EgetStoredFirst(Iterable<E> iterable, Predicate<? super E> selector) The time complexity of this method is O(n) if the given iterable contains n elements.<E> EgetStoredFirstNonNull(Iterable<E> iterable) The time complexity of this method is O(n) if the given iterable contains n elements.<E, T extends E>
TgetStoredFirstOfType(Iterable<E> iterable, Class<T> type) The time complexity of this method is O(n) if the given iterable contains n elements.
-
Constructor Details
-
IterableSearcher
public IterableSearcher()
-
-
Method Details
-
getCount
- Specified by:
getCountin interfaceIIterableCountSearcher- Parameters:
iterable- the examinedIterable, is considered to be empty when is null- Returns:
- the number of elements of the given iterable
-
getCount
- Specified by:
getCountin interfaceIIterableCountSearcher- Type Parameters:
E- the type of the elements of the given iterable- Parameters:
iterable- the examinedIterable, is considered to be empty when is nullselector- can select elements, ignores null elements, is considered not to select any element when is null- Returns:
- the number of elements the given selector selects from the given iterable
-
getCountOf
- Specified by:
getCountOfin interfaceIIterableCountSearcher- Parameters:
iterable- the examinedIterable, is considered to be empty when is nullobject-- Returns:
- the number of occurrences of the given object in the given iterable
-
getStoredAtOneBasedIndex
- Specified by:
getStoredAtOneBasedIndexin interfaceIIterableSearcher- Type Parameters:
E- the type of the elements of the given iterable- Parameters:
iterable- the searchedIterable, is considered to be empty when is nulloneBasedIndex- the one-based index at which an element is requested- Returns:
- the element at the given oneBasedIndexed from the given iterable
-
getStoredFirstNonNull
The time complexity of this method is O(n) if the given iterable contains n elements.- Specified by:
getStoredFirstNonNullin interfaceIIterableFirstElementSearcher- Type Parameters:
E- the type of the elements of the given iterable- Parameters:
iterable- the searched iterable, is considered to be empty when is null- Returns:
- the first non-null element of the given iterable
-
getStoredFirst
The time complexity of this method is O(n) if the given iterable contains n elements.- Specified by:
getStoredFirstin interfaceIIterableFirstElementSearcher- Type Parameters:
E- the type of the elements of the given iterable- Parameters:
iterable- the searched iterable, is considered to be empty when is nullselector- can select elements, is considered not to select any element when is null- Returns:
- the first element the given selector selects of the given
Iterable, ignoring null elements
-
getStoredFirstOfType
The time complexity of this method is O(n) if the given iterable contains n elements.- Specified by:
getStoredFirstOfTypein interfaceIIterableFirstElementSearcher- Type Parameters:
E- the type of the elements of the given iterableT- the modeled type of the given type- Parameters:
iterable- the searched iterable, is considered to be empty when is nulltype-- Returns:
- the first element of the given iterable that is of the given type
-