count method

int count([
  1. bool predicate(
    1. MapEntry<K, V>
    )?
])

Returns the number of entries matching the given predicate or the number of entries when predicate = null.

Implementation

int count([bool Function(MapEntry<K, V>)? predicate]) {
  if (predicate == null) {
    return length;
  }
  var count = 0;

  final i = entries.iterator;
  while (i.moveNext()) {
    if (predicate(i.current)) {
      count++;
    }
  }
  return count;
}