def __iter__(self):
        """Iterate over all values in this integer set. Iteration always starts
        by iterating from lowest to highest over the ranges that are bounded.
        After processing these, all ranges that are unbounded (maximum 2) are
        yielded intermixed."""

        ubranges = []
        for r in self._ranges:
            if r[0] is _MININF:
                if r[1] is _MAXINF:
                    ubranges.extend(([0,1],[-1,-1]))
                else:
                    ubranges.append([r[1]-1,-1])
            elif r[1] is _MAXINF:
                ubranges.append([r[0],1])
            else:
                # Little hackish, but bombs out on 32-bit platforms if using
                # xrange.
                val = r[0]
                while val < r[1]:
                    yield val
                    val += 1
        if ubranges:
            while True:
                for ubrange in ubranges:
                    yield ubrange[0]
                    ubrange[0] += ubrange[1]
Iterate over all values in this integer set. Iteration always starts
        by iterating from lowest to highest over the ranges that are bounded.
        After processing these, all ranges that are unbounded (maximum 2) are
        yielded intermixed.
recipes/Python/466286_Integer_set_type/recipe-466286.py