deepCatchesSetValues<T> function

List deepCatchesSetValues<T>(
  1. Set? set,
  2. ValueFilter filter, [
  3. List? result
])

Catches deeply set values that matches filter.

Returns a List of the matched values

Implementation

List deepCatchesSetValues<T>(Set? set, ValueFilter filter, [List? result]) {
  result ??= [];

  if (set == null || set.isEmpty) return result;

  for (var val in set) {
    if (filter(set, null, val)) {
      result.add(val);
    } else {
      deepCatchesValues(val, filter, result);
    }
  }

  return result;
}