Chars16Parser constructor

Chars16Parser(
  1. List<int> cs
)

Implementation

Chars16Parser(List<int> cs) {
  if (cs.isEmpty) {
    throw ArgumentError.value(cs, 'cs', 'Must not be empty');
  }

  final temp = cs.toList();
  if (temp.toSet().length != cs.length) {
    throw ArgumentError.value(
        cs, 'chars', 'Must not not contain duplicate elements');
  }

  for (var i = 0; i < cs.length; i++) {
    final c = cs[i];
    if (c >= 0xd800 && c <= 0xdfff) {
      throw RangeError.value(c, 'c', 'Not a valid UTF-16 character');
    }
  }

  temp.sort();
  _cs = Uint32List.fromList(temp);
  _maxChar = _cs.last;
}