Module mhlib :: Class IntSet
[hide private]
[frames] | no frames]

Class IntSet

Class implementing sets of integers.

This is an efficient representation for sets consisting of several
continuous ranges, e.g. 1-100,200-400,402-1000 is represented
internally as a list of three pairs: [(1,100), (200,400),
(402,1000)].  The internal representation is always kept normalized.

The constructor has up to three arguments:
- the string used to initialize the set (default ''),
- the separator between ranges (default ',')
- the separator between begin and end of a range (default '-')
The separators must be strings (not regexprs) and should be different.

The tostring() function yields a string that can be passed to another
IntSet constructor; __repr__() is a valid IntSet constructor itself.

Instance Methods [hide private]
 
__init__(self, data=None, sep=',', rng='-')
 
reset(self)
 
__cmp__(self, other)
 
__hash__(self)
 
__repr__(self)
 
normalize(self)
 
tostring(self)
 
tolist(self)
 
fromlist(self, list)
 
clone(self)
 
min(self)
 
max(self)
 
contains(self, x)
 
append(self, x)
 
addpair(self, xlo, xhi)
 
fromstring(self, data)