def iter_ones(self): n = q = 0 while n < self.cardinality: byte = self.data[q] if byte & 0x55: r = 0 while r < 8 and n < self.cardinality: output = (byte >> r) & self.MASK if output & 1: yield boolfunc.num2point(n, self.inputs) r += self.WIDTH n += 1 else: n += 8 q += 1
def satisfy_one(self): n = q = 0 while n < self.cardinality: byte = self.data[q] if byte & 0x55: r = 0 while r < 8 and n < self.cardinality: output = (byte >> r) & self.MASK if output & 1: return boolfunc.num2point(n, self.inputs) r += self.WIDTH n += 1 else: n += 8 q += 1 return None
def _iter_restrict(self, point): inputs = list(self.inputs) unmapped = dict() for i, v in enumerate(self.inputs): if v in point: inputs[i] = point[v] else: unmapped[v] = i vs = sorted(unmapped.keys()) for n in range(1 << len(vs)): for v, val in boolfunc.num2point(n, vs).items(): inputs[unmapped[v]] = val index = sum((val << i) for i, val in enumerate(inputs)) q, r = divmod(index * self.WIDTH, 8) yield (self.data[q] >> r) & self.MASK