Class Iterables
java.lang.Object
de.bsommerfeld.pathetic.engine.util.Iterables
Utility class that provides methods for working with Iterables. This is a replacement for
Google's Iterables API.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Iterable<T>Returns an iterable that concatenates two iterables.static <T> TReturns the last element of the specified iterable.static <T> Iterable<T>Returns an iterable that contains the firstlimitSizeelements of the specified iterable.static intReturns the number of elements in the specified iterable.
-
Method Details
-
size
Returns the number of elements in the specified iterable.- Parameters:
iterable- the iterable to count elements in- Returns:
- the number of elements in the iterable
-
getLast
Returns the last element of the specified iterable.- Type Parameters:
T- the type of elements in the iterable- Parameters:
iterable- the iterable to get the last element from- Returns:
- the last element of the iterable
- Throws:
NoSuchElementException- if the iterable is empty
-
limit
Returns an iterable that contains the firstlimitSizeelements of the specified iterable.- Type Parameters:
T- the type of elements in the iterable- Parameters:
iterable- the iterable to limitlimitSize- the maximum number of elements to include- Returns:
- an iterable containing at most
limitSizeelements from the input iterable
-
concat
Returns an iterable that concatenates two iterables.- Type Parameters:
T- the type of elements in the iterables- Parameters:
a- the first iterableb- the second iterable- Returns:
- an iterable containing all elements from both input iterables
-