'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.'

def __iter__(self):

    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:
            for val in xrange(r[0], r[1]):
                (yield val)
    if ubranges:
        while True:
            for ubrange in ubranges:
                (yield ubrange[0])
                ubrange[0] += ubrange[1]
