findNode method

FindNodeResult? findNode(
  1. bool f(
    1. NodeOutput
    )
)

Implementation

FindNodeResult? findNode(bool Function(NodeOutput) f) {
  FindNodeResult? result;
  this.s.asMap().entries.any((rowEntry) {
    var y = rowEntry.key;
    var row = rowEntry.value;
    return row.asMap().entries.any((columnEntry) {
      var x = columnEntry.key;
      var cell = columnEntry.value;
      if (cell == null) return false;
      final i = cell.all.indexWhere((c) => f(c));
      if (i != -1) {
        result = FindNodeResult(coords: [x, y], item: cell.all[i]);
        return true;
      }
      return false;
    });
  });
  return result;
}