Package org.aksw.commons.util.math
Class Lehmer
java.lang.Object
org.aksw.commons.util.math.Lehmer
Class for computing the lehmer code and value for a given set of items w.r.t. a comparator.
The lehmer code is a basis for numbering permutations. The (decimal) value
of a lehmer code for n items ranges from 0 to n!.
The value is 0 for a sorted sequence of items and n! for a reverse-sorted one.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> int[]lehmerCode(Collection<T> items, Comparator<T> comparator) For a given collection of unique items with a defined total ordering (via comparator) compute the natural number that correspends to n-th permutation w.r.t.static <T> BigIntegerlehmerValue(Collection<T> items, Comparator<T> comparator) static BigIntegervalueOfLehmerCode(int[] lehmer)
-
Constructor Details
-
Lehmer
public Lehmer()
-
-
Method Details
-
lehmerValue
-
lehmerCode
For a given collection of unique items with a defined total ordering (via comparator) compute the natural number that correspends to n-th permutation w.r.t. the lehmer code. This implementation adds the provided items into a LinkedHashSet - so only their first occurrence matters.- Type Parameters:
T-- Parameters:
items-comparator-- Returns:
-
valueOfLehmerCode
-