Commit be4c25fa authored by Matthias Braun's avatar Matthias Braun
Browse files

add rbitsets_have_common function

[r26325]
parent d20e8214
...@@ -348,6 +348,26 @@ static inline int rbitset_equal(const unsigned *bitset1, ...@@ -348,6 +348,26 @@ static inline int rbitset_equal(const unsigned *bitset1,
return memcmp(bitset1, bitset2, BITSET_SIZE_BYTES(size)) == 0; return memcmp(bitset1, bitset2, BITSET_SIZE_BYTES(size)) == 0;
} }
/**
* Tests wether 2 bitsets wether at least 1 bit is set in both.
*
* @param bitset1 the first bitset
* @param bitset2 the second bitset
* @param size size of both bitsets
*/
static inline int rbitsets_have_common(const unsigned *bitset1,
const unsigned *bitset2, size_t size)
{
unsigned i;
unsigned n = BITSET_SIZE_ELEMS(size);
for (i = 0; i < n; ++i) {
if ((bitset1[i] & bitset2[i]) != 0)
return 1;
}
return 0;
}
/** /**
* Copy a raw bitset into another. * Copy a raw bitset into another.
* *
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment