byBinary method

Set<T> byBinary(
  1. int value
)

Converts the binary representation of an enum into enum values.

Implementation

Set<T> byBinary(int value) {
  final result = <T>{};

  var v = value;
  for (var i = 1; i <= length - 1; i++) {
    if (v.isOdd) {
      result.add(this[i]);
    }
    v = v >> 1;
  }

  if (result.isEmpty) {
    result.add(first);
  }

  return result;
}