3 ms·
If you're handed a bit mask of events or flags then it can be used to iterate through the bits that are set, rather than all the bits. while flags!=0:
by RiderOfGiraffes 16y ago
If you're handed a bit mask of events or flags then it can be used to iterate through the bits that are set, rather than all the bits.
while flags!=0:
right_most = flags & (-flags)
process(right_most)
flags &= ~right_most