count method

int count()

Counts the total number of bits set to true.

Implementation

int count() {
  int total = 0;
  for (int word in _words) {
    // Kernighan's bit counting or JS-safe loop
    int w = word;
    while (w != 0) {
      w &= (w - 1);
      total++;
    }
  }
  return total;
}