use of searcher.pack.connections.StreamColumnFieldConnections in project solution-finder by knewjade.
the class ConnectionsToStreamCallable method over.
private Stream<RecursiveMinoField> over(ColumnField columnField, ColumnField outerColumnField, List<SeparableMino> minos, SeparableMinos separableMinos, RecursiveMinoField result) {
Stream.Builder<RecursiveMinoField> builder = Stream.builder();
builder.accept(result);
StreamColumnFieldConnections connections = new StreamColumnFieldConnections(minos, columnField, calculator.getSizedBit());
Stream<RecursiveMinoField> stream = connections.getConnectionStream().filter(connection -> {
ColumnField nextOuterField = connection.getOuterField();
SeparableMino mino = connection.getMino();
return // 次に埋めるべき場所を埋めてある
!needFilledField.canMerge(mino.getField()) && // 次のフィールドの制限範囲と重なっていない
nextOuterField.canMerge(limitOuterField) && // 次のフィールドにあるブロックと重なっていない
nextOuterField.canMerge(outerColumnField);
}).flatMap(connection -> {
// 使用されるブロックを算出
ColumnField usingBlock = connection.getOuterField().freeze(calculator.getHeight());
usingBlock.merge(outerColumnField);
RecursiveMinoField t = new RecursiveMinoField(connection.getMino(), result, usingBlock, separableMinos);
List<SeparableMino> allMinos = separableMinos.getMinos();
List<SeparableMino> minos2 = allMinos.subList(separableMinos.toIndex(connection.getMino()) + 1, allMinos.size());
return over(connection.getInnerField(), usingBlock, minos2, separableMinos, t);
});
return Stream.concat(Stream.of(result), stream);
}
Aggregations