Package lepl :: Package regexp :: Module interval :: Class Intervals
[hide private]
[frames] | no frames]

Class Intervals

source code


A set of possible values for a character, described as a collection of intervals. Each interval is [a, b] (ie a <= x <= b, where x is a character code). We use open bounds to avoid having to specify an "out of range" value, making it easier to work with a variety of alphabets.

The intervals are stored in a list, ordered by a, joining overlapping intervals as necessary.

Instance Methods [hide private]
 
__init__(self, intervals, alphabet)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
append(self, interval)
Add an interval to the range.
source code
 
__build_index(self)
Pre-construct the index used for bisection.
source code
 
__append(self, interval)
Add an interval to the existing intervals.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
len(self)
The number of intervals in the range.
source code
 
__getitem__(self, index) source code
 
__iter__(self) source code
 
__contains__(self, c)
Does the value lie within the intervals?
source code
 
__hash__(self)
hash(x)
source code
 
__eq__(self, other) source code

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, intervals, alphabet)
(Constructor)

source code 
x.__init__(...) initializes x; see help(type(x)) for signature
Overrides: object.__init__
(inherited documentation)

__append(self, interval)

source code 

Add an interval to the existing intervals.

This maintains self.__intervals in the normalized form described above.

__str__(self)
(Informal representation operator)

source code 
str(x)
Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 
repr(x)
Overrides: object.__repr__
(inherited documentation)

__hash__(self)
(Hashing function)

source code 
hash(x)
Overrides: object.__hash__
(inherited documentation)