forEach method

void forEach(
  1. void callback(
    1. int index,
    2. T value
    )
)

Iterates over each value in the vector. Skips over default values, which can be done very efficiently on sparse vectors.

Implementation

void forEach(void Function(int index, T value) callback) {
  for (var index = 0; index < count; index++) {
    final value = getUnchecked(index);
    if (value != dataType.defaultValue) {
      callback(index, value);
    }
  }
}