'Clean ranges list, combining adjacent ranges'

def clean(self):

    ranges = sorted(_swapAllPairs(self.ranges, that=self._infinity, ifIs=None))
    mergedRanges = [(float('-inf'), float('-inf'))]
    for (low, high) in ranges:
        (previousLow, previousHigh) = mergedRanges[(-1)]
        if (previousHigh < (low - 1)):
            mergedRanges.append((low, high))
            continue
        mergedRanges[(-1)] = (min(previousLow, low), max(previousHigh, high))
    self.ranges = _swapAllPairs(mergedRanges[1:], that=None, ifIs=self._infinity)
