encodeTo method

  1. @override
void encodeTo(
  1. List<String> value,
  2. Output output
)
override

Convert self to a slice and append it to the destination.

Implementation

@override
void encodeTo(List<String> value, Output output) {
  assertion(bitLength % 2 == 0, 'bitLength should be multiple of 2.');
  assertion(bitLength > 0, 'bitLength should be greater than 0.');
  assertion(bitLength <= 256, 'bitLength should be less than 256.');

  final codec = Registry().getSimpleCodecs('U$bitLength');
  assertion(codec != null, 'codec should not be null.');

  var setIndex = 0;
  for (var index = 0; index < values.length; index++) {
    final item = values[index];
    if (value.contains(item)) {
      setIndex += 1 << index;
    }
  }
  codec!.encodeTo(setIndex, output);
}