2
私は、次のような問題でこだわっている
:ある使用
List<Object> itemList = ArrayList(ArrayList<Object1, Object2, Double[]>)
Object1
とObject2
:私はこのように定義された項目の動的なリストを持っている
ここでは興味がありませんが、配列番号Double[]
には任意の数のエントリが含まれています。
私のコードでは、外側をくり返すとArrayList
となり、guavaのcartesianProductを計算しようとします。今まで私は(一部...申し訳ありませんが、コードを動作していない)のようなものがあります。
Set<Double> first = ImmutableSet.of(1., 2.);
Set<Double> second = ImmutableSet.of(3., 4.);
Set<List<Double>> result =
Sets.cartesianProduct(ImmutableList.of(first, second));
:
private Set<List<Set<Double>>> getValueCombinations() {
List<Set<Double>> valuesOfInnerArrays = new ArrayList<>();
// Loop over the list of device data sets in the class and add the trim value vectors to a list for further
// processing and cartesian prooduct generation.
for (Integer indexCounter = 0; indexCounter < OuterArrayList.size(); indexCounter++) {
final List<Object> innerDataSet = (List<Object>) OuterArrayList.get(indexCounter);
final Set<Double> innerDoubleArray = ImmutableSet.of(((List<Double>) innerDataSet.get(2)).toArray(new Double[]));
valuesOfInnerArrays.add(innerDoubleArray);
}
ImmutableList<Set<Double>> test = ImmutableList.of(valuesOfInnerArrays)
// generate Cartesian product of all trim vectors = a n x m matrix of all combinations of settings
final Set<List<Set<Double>>> cartesianProduct = Sets.cartesianProduct(ImmutableList.of(valuesOfInnerArrays));
return cartesianProduct;
}
私が見つけたすべての例では、彼らはいつも私が行うことができない既知のセット、との直積集合を呼び出します
私が最後に持っていたいのは、内側のDouble []配列に格納されている数字のすべての組み合わせです。
助けてください。