Class SimplificationWorker
java.lang.Object
tech.units.indriya.internal.simplify.SimplificationWorker
Worker for the Simplifier.
- Since:
- 2.0
- Version:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AbstractConverter[]
private final BinaryOperator<AbstractConverter>
private final BiPredicate<AbstractConverter,
AbstractConverter> -
Constructor Summary
ConstructorsConstructorDescriptionSimplificationWorker
(BiPredicate<AbstractConverter, AbstractConverter> simpleComposeTest, BinaryOperator<AbstractConverter> simpleComposeAction) -
Method Summary
Modifier and TypeMethodDescriptionprivate static AbstractConverter
sequenceToConverter
(AbstractConverter[] sequence) Description of a brute-force approach:private static void
sortToNormalFormOrder
(AbstractConverter[] arrayOfConverters) private int
-
Field Details
-
simpleComposeTest
-
simpleComposeAction
-
arrayOfConverters
-
-
Constructor Details
-
SimplificationWorker
public SimplificationWorker(BiPredicate<AbstractConverter, AbstractConverter> simpleComposeTest, BinaryOperator<AbstractConverter> simpleComposeAction)
-
-
Method Details
-
simplify
Description of a brute-force approach:Given 'conversionSteps' a list of converters, where order matters, we form a permutation group of all allowed permutations 'reachable' through 'allowed' swapping. Swapping is allowed for 2 consecutive converters that are both multiply transformations (x.isLinear()==true). We search this permutation group for any sequence of converters, that allows simplification:
For every pair of consecutive converters within a sequence, check whether a simplification is possible (a.isSimpleCompositionWith(b)), then apply simplification and start over.
Finally sort according to normal-form order.- Parameters:
conversionSteps
-- Returns:
-
trySimplify
private int trySimplify() -
sortToNormalFormOrder
-
sequenceToConverter
-