count method

int count([
  1. bool predicate(
    1. T
    )?
])

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

Implementation

int count([bool Function(T)? predicate]) {
  if (predicate == null && this is KtCollection) {
    return (this as KtCollection).size;
  }
  var count = 0;
  final Iterator<T> i = iter.iterator;
  while (i.moveNext()) {
    if (predicate == null) {
      count++;
    } else {
      if (predicate(i.current)) {
        count++;
      }
    }
  }
  return count;
}