flushUpdates method

Set flushUpdates()

Flush the results of solver. The set of all context objects associated with variables in the Solver is returned. If a Variable does not contain an associated context, its updates are ignored.

The addition and removal of constraints and edit variables to and from the Solver as well as the application of suggestions to the added edit variables leads to the modification of values on a lot of other variables. External entities that rely on the values of the variables within the Solver can read these updates in one shot by "flushing" out these updates.

Implementation

Set<dynamic> flushUpdates() {
  final updates = HashSet<dynamic>();

  for (final variable in _vars.keys) {
    final symbol = _vars[variable];
    final row = _rows[symbol];

    final updatedValue = row == null ? 0.0 : row.constant;

    if (variable.applyUpdate(updatedValue) && variable.owner != null) {
      final context = variable.owner!.context;
      if (context != null) {
        updates.add(context);
      }
    }
  }

  return updates;
}