Search in sources :

Example 1 with WrapperLayer

use of com.simiacryptus.mindseye.layers.java.WrapperLayer in project MindsEye by SimiaCryptus.

the class DAGNetwork method visitLayers.

/**
 * Visit layers.
 *
 * @param visitor the visitor
 */
public void visitLayers(@Nonnull final Consumer<Layer> visitor) {
    layersById.values().forEach(layer -> {
        Layer unwrapped = layer;
        while (unwrapped instanceof WrapperLayer) {
            unwrapped = ((WrapperLayer) unwrapped).getInner();
        }
        if (unwrapped instanceof DAGNetwork) {
            ((DAGNetwork) unwrapped).visitLayers(visitor);
        }
        visitor.accept(layer);
        while (layer instanceof WrapperLayer) {
            Layer inner = ((WrapperLayer) layer).getInner();
            visitor.accept(inner);
            layer = inner;
        }
    });
}
Also used : WrapperLayer(com.simiacryptus.mindseye.layers.java.WrapperLayer) Layer(com.simiacryptus.mindseye.lang.Layer) WrapperLayer(com.simiacryptus.mindseye.layers.java.WrapperLayer)

Example 2 with WrapperLayer

use of com.simiacryptus.mindseye.layers.java.WrapperLayer in project MindsEye by SimiaCryptus.

the class DAGNetwork method visitNodes.

/**
 * Visit nodes.
 *
 * @param visitor the visitor
 */
public void visitNodes(@Nonnull final Consumer<DAGNode> visitor) {
    nodesById.values().forEach(node -> {
        Layer layer = node.getLayer();
        while (layer instanceof WrapperLayer) {
            layer = ((WrapperLayer) layer).getInner();
        }
        if (layer instanceof DAGNetwork) {
            ((DAGNetwork) layer).visitNodes(visitor);
        }
        visitor.accept(node);
    });
}
Also used : WrapperLayer(com.simiacryptus.mindseye.layers.java.WrapperLayer) Layer(com.simiacryptus.mindseye.lang.Layer) WrapperLayer(com.simiacryptus.mindseye.layers.java.WrapperLayer)

Aggregations

Layer (com.simiacryptus.mindseye.lang.Layer)2 WrapperLayer (com.simiacryptus.mindseye.layers.java.WrapperLayer)2