removeRepeatRuns static method

void removeRepeatRuns(
  1. List<int> chars
)

Removes runs of repeated characters from the chars provided.

Implementation

static void removeRepeatRuns(final List<int> chars) {
  var writeIndex = 1;
  for (var i = writeIndex; i < chars.length; i++) {
    if (chars[i] != chars[i - 1]) {
      chars[writeIndex++] = chars[i];
    }
  }

  chars.removeRange(writeIndex, chars.length);
}