Show More
@@ -2296,6 +2296,40 b' class generatorset(object):' | |||
|
2296 | 2296 | def set(self): |
|
2297 | 2297 | return self |
|
2298 | 2298 | |
|
2299 | class ascgeneratorset(generatorset): | |
|
2300 | """ Same structure as generatorset but stops iterating after it goes past | |
|
2301 | the value when asked for membership and the element is not contained | |
|
2302 | """ | |
|
2303 | def __contains__(self, x): | |
|
2304 | if x in self._cache: | |
|
2305 | return self._cache[x] | |
|
2306 | ||
|
2307 | for l in self: | |
|
2308 | if l == x: | |
|
2309 | return True | |
|
2310 | if l > x: | |
|
2311 | break | |
|
2312 | ||
|
2313 | self._cache[x] = False | |
|
2314 | return False | |
|
2315 | ||
|
2316 | class descgeneratorset(generatorset): | |
|
2317 | """ Same structure as generatorset but stops iterating after it goes past | |
|
2318 | the value when asked for membership and the element is not contained | |
|
2319 | """ | |
|
2320 | def __contains__(self, x): | |
|
2321 | if x in self._cache: | |
|
2322 | return self._cache[x] | |
|
2323 | ||
|
2324 | for l in self: | |
|
2325 | if l == x: | |
|
2326 | return True | |
|
2327 | if l < x: | |
|
2328 | break | |
|
2329 | ||
|
2330 | self._cache[x] = False | |
|
2331 | return False | |
|
2332 | ||
|
2299 | 2333 | class spanset(object): |
|
2300 | 2334 | """Duck type for baseset class which represents a range of revisions and |
|
2301 | 2335 | can work lazily and without having all the range in memory |
General Comments 0
You need to be logged in to leave comments.
Login now