diff options
author | 2021-07-29 19:55:46 +0200 | |
---|---|---|
committer | 2021-07-29 19:55:46 +0200 | |
commit | 4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413 (patch) | |
tree | d69e8e5c9c7f621b3109c28939091d07982d91dc /model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java | |
parent | Add new data structure for backend (diff) | |
download | refinery-4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413.tar.gz refinery-4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413.tar.zst refinery-4c04a8c8e1aedbca02b3ba8fd484c26e8b6e2413.zip |
Data structure cleanup with Sonar
Diffstat (limited to 'model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java')
-rw-r--r-- | model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java b/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java deleted file mode 100644 index 0f7b4642..00000000 --- a/model-data/src/test/java/org/eclipse/viatra/solver/data/map/tests/smoke/utils/TestPermuter.java +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | package org.eclipse.viatra.solver.data.map.tests.smoke.utils; | ||
2 | |||
3 | import java.util.LinkedList; | ||
4 | import java.util.List; | ||
5 | import java.util.stream.Stream; | ||
6 | |||
7 | import org.junit.jupiter.params.provider.Arguments; | ||
8 | |||
9 | public class TestPermuter { | ||
10 | static List<List<Object>> permutationInternal(int from, Object[]... valueOption) { | ||
11 | if (valueOption.length == from) { | ||
12 | return List.of(List.of()); | ||
13 | } else { | ||
14 | Object[] permuteThis = valueOption[from]; | ||
15 | List<List<Object>> otherCombination = permutationInternal(from + 1, valueOption); | ||
16 | List<List<Object>> result = new LinkedList<>(); | ||
17 | for (Object permuteThisElement : permuteThis) { | ||
18 | for (List<Object> otherCombinationList : otherCombination) { | ||
19 | List<Object> newResult = new LinkedList<>(); | ||
20 | newResult.add(permuteThisElement); | ||
21 | newResult.addAll(otherCombinationList); | ||
22 | result.add(newResult); | ||
23 | } | ||
24 | } | ||
25 | return result; | ||
26 | } | ||
27 | } | ||
28 | |||
29 | public static Stream<Arguments> permutation(Object[]... valueOption) { | ||
30 | List<List<Object>> permutations = permutationInternal(0, valueOption); | ||
31 | return permutations.stream().map(x -> Arguments.of(x.toArray())); | ||
32 | } | ||
33 | |||
34 | public static Stream<Arguments> permutationWithSize(Object[]... valueOption) { | ||
35 | int size = 1; | ||
36 | for (int i = 0; i < valueOption.length; i++) { | ||
37 | size *= valueOption[i].length; | ||
38 | } | ||
39 | Object[][] newValueOption = new Object[valueOption.length + 1][]; | ||
40 | newValueOption[0] = new Object[] { size }; | ||
41 | for (int i = 1; i < newValueOption.length; i++) { | ||
42 | newValueOption[i] = valueOption[i - 1]; | ||
43 | } | ||
44 | return permutation(newValueOption); | ||
45 | } | ||
46 | } | ||