Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #17665: add bitset_are_disjoint to bitset_t
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoudert committed Jan 24, 2015
1 parent 1a9851f commit 0524fda
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/sage/data_structures/bitset.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,20 @@ cdef inline bint bitset_issuperset(bitset_t a, bitset_t b):
"""
return bitset_issubset(b, a)


cdef inline bint bitset_are_disjoint(bitset_t a, bitset_t b):
"""
Tests whether ``a`` and ``b`` have an empty intersection.
We assume ``a.limbs == b.limbs``.
"""
cdef mp_size_t i
for i from 0 <= i < a.limbs:
if (a.bits[i]&b.bits[i]) != 0:
return False
return True


#############################################################################
# Bitset Bit Manipulation
#############################################################################
Expand Down

0 comments on commit 0524fda

Please sign in to comment.