public class SequentialStrategy
extends java.lang.Object
implements java.util.function.Function<int[],int[][]>
Class implements PairWising strategy as "index mapping" function (int[] -> int[][])
according to IndexShuffle
Strategy sets speed as it's primary goal, so it may provide "untrue" pairwising, meaning that
it might miss some pairs. But the strategy is extremely useful in terms of time-value ratio,
especially for larger sets of data, when production of the "perfect" collection becomes almost impossible.
(See documentation to the PairWise class, on the subject of "true" pairwising and "perfect" collection).
To minimize number of pair comparisons required to filter out all the "invalid" rows this strategy performs filter operation after multiplying each next column, rather than building the whole multiplication table, and filtering it once. Example:
// input "sizes array" shows that we have 4 columns with 2 possible elements each
int[] sizes = [2,2,2,2]
// strategy creates "full multiplication" of the first column:
int[][] rows = [
[0],
[1],
]
// then strategy takes each next column, and performs "full multiplication" with existing rows
// also performing filter operation on each multiplication.
int[][] rows = [
[0, 0],
[0, 1],
[1, 0],
[1, 1],
]
// All pairs are unique - nothing is filtered out. Next column:
int[][] rows = [
[0, 0, 0],
[0, 1, 1],
[1, 0, 1],
[1, 1, 0],
]
// Next column:
int[][] rows = [
[0, 0, 0, 0],
[0, 0, 0, 1],
[0, 1, 1, 0],
[0, 1, 1, 1],
[1, 0, 1, 1],
[1, 1, 0, 0],
]
In this example result map represents "true" pairwise, where all possible combinations are present for any
selected pair of indexes. And it's pretty close to an "ideal" orthogonal array.| Modifier and Type | Field and Description |
|---|---|
static SequentialStrategy |
INSTANCE
Just an instance of the class.
|
| Constructor and Description |
|---|
SequentialStrategy() |
| Modifier and Type | Method and Description |
|---|---|
int[][] |
apply(int[] sizes) |
public static final SequentialStrategy INSTANCE