'How to fast get an array of the bit positions within a bit array(or bitmap、bit vector)?

How to fast get an array of the bit positions within a bit array(or bitmap、bit vector) ?example: the bitmap or bit array(only have 0 or 1) is [0,0,0,1,1,0,1,0,0], I want to get the bit positions array: [3,4,6].



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source