Show More
@@ -2270,24 +2270,13 b' class generatorset(object):' | |||||
2270 | self._genlist = baseset([]) |
|
2270 | self._genlist = baseset([]) | |
2271 | self._iterated = False |
|
2271 | self._iterated = False | |
2272 |
|
2272 | |||
2273 | def _nextitem(self): |
|
|||
2274 | l = self._iter.next() |
|
|||
2275 | self._cache[l] = True |
|
|||
2276 | self._genlist.append(l) |
|
|||
2277 | return l |
|
|||
2278 |
|
||||
2279 | def __contains__(self, x): |
|
2273 | def __contains__(self, x): | |
2280 | if x in self._cache: |
|
2274 | if x in self._cache: | |
2281 | return self._cache[x] |
|
2275 | return self._cache[x] | |
2282 |
|
2276 | |||
2283 | self._iterated = True |
|
2277 | for l in self: | |
2284 | while True: |
|
2278 | if l == x: | |
2285 |
|
|
2279 | return True | |
2286 | l = self._nextitem() |
|
|||
2287 | if l == x: |
|
|||
2288 | return True |
|
|||
2289 | except (StopIteration): |
|
|||
2290 | break |
|
|||
2291 |
|
2280 | |||
2292 | self._cache[x] = False |
|
2281 | self._cache[x] = False | |
2293 | return False |
|
2282 | return False | |
@@ -2296,18 +2285,13 b' class generatorset(object):' | |||||
2296 | if self._iterated: |
|
2285 | if self._iterated: | |
2297 | for l in self._genlist: |
|
2286 | for l in self._genlist: | |
2298 | yield l |
|
2287 | yield l | |
2299 | while True: |
|
|||
2300 | try: |
|
|||
2301 | item = self._nextitem() |
|
|||
2302 | yield item |
|
|||
2303 | except (StopIteration): |
|
|||
2304 | break |
|
|||
2305 | else: |
|
2288 | else: | |
2306 | self._iterated = True |
|
2289 | self._iterated = True | |
2307 | for item in self._gen: |
|
2290 | ||
2308 | self._cache[item] = True |
|
2291 | for item in self._gen: | |
2309 | self._genlist.append(item) |
|
2292 | self._cache[item] = True | |
2310 | yield item |
|
2293 | self._genlist.append(item) | |
|
2294 | yield item | |||
2311 |
|
2295 | |||
2312 | def set(self): |
|
2296 | def set(self): | |
2313 | return self |
|
2297 | return self |
General Comments 0
You need to be logged in to leave comments.
Login now