efficiently compare two BitArrays of the same length

Posted by BobTurbo on Stack Overflow See other posts from Stack Overflow or by BobTurbo
Published on 2011-01-13T05:34:40Z Indexed on 2011/01/13 5:53 UTC
Read the original article Hit count: 171

Filed under:

How would I do this? I am trying to count when both arrays have the same value of TRUE/1 at the same index. As you can see, my code has multiple bitarrays and is looping through each one and comparing them with a comparisonArray with another loop. It doesn't seem to be very efficient and I need it to be.

foreach (bitArrayTuple in bitarryList) { 
    for (int i = 0; i < arrayLength; i++)
        if (bArrayTuple.Item2[i] && comparisonArray[i])
            bitArrayTuple.Item1++;
}

where Item1 is the count and Item2 is a bitarray.

© Stack Overflow or respective owner

Related posts about c#