use of common.iterable.CombinationIterable in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedOnDemandTest method createUsingBlockAndValidKeyMementoFilter.
// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
HashSet<Long> validBlockCounters = new HashSet<>();
for (PieceCounter counter : counters) {
List<Piece> usingPieces = counter.getBlocks();
for (int size = 1; size <= usingPieces.size(); size++) {
CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
for (List<Piece> pieces : combinationIterable) {
PieceCounter newCounter = new PieceCounter(pieces);
validBlockCounters.add(newCounter.getCounter());
}
}
}
LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
use of common.iterable.CombinationIterable in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedTest method createUsingBlockAndValidKeyMementoFilter.
// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
HashSet<Long> validBlockCounters = new HashSet<>();
for (PieceCounter counter : counters) {
List<Piece> usingPieces = counter.getBlocks();
for (int size = 1; size <= usingPieces.size(); size++) {
CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
for (List<Piece> pieces : combinationIterable) {
PieceCounter newCounter = new PieceCounter(pieces);
validBlockCounters.add(newCounter.getCounter());
}
}
}
LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
Aggregations