0

What is an efficient way to get the number of bits set in a System.Collections.BitArray (like bitset.count in C++ or BitSet.cardinality in Java)?

So far I only found solutions for BitArray smaller than 64 bit, for example: Counting bits set in a .Net BitArray Class

Kali User
  • 105
  • 6
  • There are plenty of solutions in the linked question for `BitArray`s larger than 64 bits. There are also answers in the linked post that say the optimal solution is O(n). Are they not efficient enough for you? In that case please clearly define what "efficient" means, and explain clearly why the answers in the linked question does not answer your question by [edit]ing the question. – Sweeper Apr 24 '21 at 12:25
  • None of the solutions in there where close enough to the Java and C++ alternatives, I answered that question to mention `BitOperations.PopCount`: https://stackoverflow.com/a/67248403/12923324 – Kali User Apr 24 '21 at 23:47

0 Answers0