Package net.hydromatic.morel.util
Class Ord<E>
java.lang.Object
net.hydromatic.morel.util.Ord<E>
- Type Parameters:
E- Element type
Pair of an element and an ordinal.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceConsumer that receives an ordinal, a key, and a value.private static classList ofOrdbacked by an array of elements.private static classList ofOrdbacked by a list of elements.private static classList ofOrdbacked by a random-access list of elements. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <E> voidforEach(List<E> list, ObjIntConsumer<E> consumer) Performs the given action for each element of theList.static <E> voidforEachIndexed(Iterable<E> iterable, ObjIntConsumer<E> consumer) Performs the given action for each element of theIterable.static <K,V> void forEachIndexed(Map<K, V> map, Ord.IntObjObjConsumer<K, V> consumer) Performs the given action for each entry of aMap.getKey()getValue()static <E> Ord<E> of(int n, E e) Creates an Ord.reverse(E... elements) Iterates over an array in reverse order.Iterates over a list in reverse order.zip(E[] elements) Returns a numbered list based on an array.Creates an iterable ofOrds over an iterable.Creates an iterator ofOrds over an iterator.Returns a numbered list.
-
Field Details
-
i
public final int i -
e
-
-
Constructor Details
-
Ord
Creates an Ord.
-
-
Method Details
-
of
Creates an Ord. -
zip
Creates an iterable ofOrds over an iterable. -
zip
Creates an iterator ofOrds over an iterator. -
zip
Returns a numbered list based on an array. -
zip
Returns a numbered list. -
forEachIndexed
Performs the given action for each element of theIterable. -
forEach
Performs the given action for each element of theList.More efficient than
forEachIndexed(Iterable, ObjIntConsumer)if the list implementsRandomAccess. -
forEachIndexed
Performs the given action for each entry of aMap. -
reverse
Iterates over an array in reverse order.Given the array ["a", "b", "c"], returns (2, "c") then (1, "b") then (0, "a").
-
reverse
Iterates over a list in reverse order.Given the list ["a", "b", "c"], returns (2, "c") then (1, "b") then (0, "a").
-
getKey
-
getValue
-
setValue
-