Search in sources :

Example 1 with StreamColumnFieldConnections

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);
}
Also used : OperationWithKey(common.datastore.OperationWithKey) StreamColumnFieldConnections(searcher.pack.connections.StreamColumnFieldConnections) RecursiveMinoFields(searcher.pack.mino_fields.RecursiveMinoFields) ColumnField(core.column_field.ColumnField) Callable(java.util.concurrent.Callable) RecursiveMinoField(searcher.pack.mino_field.RecursiveMinoField) Objects(java.util.Objects) List(java.util.List) Field(core.field.Field) Stream(java.util.stream.Stream) SeparableMino(searcher.pack.separable_mino.SeparableMino) SeparableMinos(searcher.pack.SeparableMinos) ColumnFieldConnection(searcher.pack.connections.ColumnFieldConnection) ColumnFieldConnections(searcher.pack.connections.ColumnFieldConnections) SeparableMino(searcher.pack.separable_mino.SeparableMino) ColumnField(core.column_field.ColumnField) RecursiveMinoField(searcher.pack.mino_field.RecursiveMinoField) Stream(java.util.stream.Stream) StreamColumnFieldConnections(searcher.pack.connections.StreamColumnFieldConnections)

Aggregations

OperationWithKey (common.datastore.OperationWithKey)1 ColumnField (core.column_field.ColumnField)1 Field (core.field.Field)1 List (java.util.List)1 Objects (java.util.Objects)1 Callable (java.util.concurrent.Callable)1 Stream (java.util.stream.Stream)1 SeparableMinos (searcher.pack.SeparableMinos)1 ColumnFieldConnection (searcher.pack.connections.ColumnFieldConnection)1 ColumnFieldConnections (searcher.pack.connections.ColumnFieldConnections)1 StreamColumnFieldConnections (searcher.pack.connections.StreamColumnFieldConnections)1 RecursiveMinoField (searcher.pack.mino_field.RecursiveMinoField)1 RecursiveMinoFields (searcher.pack.mino_fields.RecursiveMinoFields)1 SeparableMino (searcher.pack.separable_mino.SeparableMino)1