count method

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

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

Implementation

int count([bool Function(KtMapEntry<K, V>)? predicate]) {
  if (predicate == null) {
    return size;
  }
  var count = 0;
  final KtIterator<KtMapEntry<K, V>> i = iterator();
  while (i.hasNext()) {
    if (predicate(i.next())) {
      count++;
    }
  }
  return count;
}