query<C extends T> method

List<C> query<C extends T>()

Allow you to find a subset of this set with all the elements e for which the condition e is C is true. This is equivalent to

  orderedSet.whereType<C>()

except that it is O(0).

Note: you must call register for every type C you desire to use before calling this, or set strictMode to false.

Implementation

List<C> query<C extends T>() {
  final result = _cache[C];
  if (result == null) {
    if (strictMode) {
      throw 'Cannot query unregistered query $C';
    } else {
      register<C>();
      return query<C>();
    }
  }
  return result.data as List<C>;
}