Class LazyOrderIterable<T,TComparable>
java.lang.Object
de.renebergelt.quiterables.iterators.LazyOrderIterable<T,TComparable>
- Type Parameters:
T- Type of the elements in this Iterable
- All Implemented Interfaces:
Iterable<T>
AN Iterable which sorts its elements before returning an iterator
- Author:
- René Bergelt
-
Constructor Summary
ConstructorsConstructorDescriptionLazyOrderIterable(Iterable<T> _wrapped, ItemFunc<T,Comparable> valueFunc, SortOrder sortOrder)Creates a LazyOrderIterable which uses the default ComparatorLazyOrderIterable(Iterable<T> _wrapped, ItemFunc<T,TComparable> valueFunc, Comparator comparator, SortOrder sortOrder)Create a new lazy order iterable which wraps the given iterable -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSecondaryOrderFunction(ItemFunc<T,Comparable> func, SortOrder sortOrder)Adds a secondary ordering function which is used to compare elements for which all previous ordering functions return "equal"<TComparable>
voidaddSecondaryOrderFunction(ItemFunc<T,TComparable> func, Comparator<TComparable> comparator, SortOrder sortOrder)Add a secondary ordering function which is used to compare elements for which all previous ordering functions return "equal"iterator()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LazyOrderIterable
public LazyOrderIterable(Iterable<T> _wrapped, ItemFunc<T,TComparable> valueFunc, Comparator comparator, SortOrder sortOrder)Create a new lazy order iterable which wraps the given iterable- Type Parameters:
TComparable- Type of the values to compare- Parameters:
_wrapped- The wrapped iterablevalueFunc- Function to retrieve the value to order bycomparator- Comparator to use for comparing valuessortOrder- The sort order
-
LazyOrderIterable
public LazyOrderIterable(Iterable<T> _wrapped, ItemFunc<T,Comparable> valueFunc, SortOrder sortOrder)Creates a LazyOrderIterable which uses the default Comparator- Parameters:
_wrapped- The iterable which will be wrapped (and sorted)valueFunc- The function to retrieve the values to comparesortOrder- The sort order
-
-
Method Details
-
addSecondaryOrderFunction
Adds a secondary ordering function which is used to compare elements for which all previous ordering functions return "equal"- Parameters:
func- The function to retrieve the values to comparesortOrder- The sort order
-
addSecondaryOrderFunction
public <TComparable> void addSecondaryOrderFunction(ItemFunc<T,TComparable> func, Comparator<TComparable> comparator, SortOrder sortOrder)Add a secondary ordering function which is used to compare elements for which all previous ordering functions return "equal"- Type Parameters:
TComparable- Type of the values to compare- Parameters:
func- The function to retrieve the values to comparecomparator- Custom comparatorsortOrder- The sort order
-
iterator
-