##// END OF EJS Templates
revset: added addset class with its basic methods...
Lucas Moscovicz -
r20694:621c9437 default
parent child Browse files
Show More
@@ -2314,6 +2314,35 b' class orderedlazyset(lazyset):'
2314 self._subset.reverse()
2314 self._subset.reverse()
2315 self._ascending = not self._ascending
2315 self._ascending = not self._ascending
2316
2316
2317 class addset(object):
2318 """Wrapper structure for lazily adding two structures without losing much
2319 performance on the __contains__ method
2320 """
2321 def __init__(self, revs1, revs2):
2322 self._r1 = revs1
2323 self._r2 = revs2
2324 self._iter = None
2325
2326 def _iterator(self):
2327 if not self._iter:
2328 def gen():
2329 for r in self._r1:
2330 yield r
2331 s = self._r1.set()
2332 for r in self._r2:
2333 if r not in s:
2334 yield r
2335 self._iter = generatorset(gen())
2336
2337 return self._iter
2338
2339 def __iter__(self):
2340 for r in self._iterator():
2341 yield r
2342
2343 def __contains__(self, x):
2344 return x in self._r1 or x in self._r2
2345
2317 class generatorset(object):
2346 class generatorset(object):
2318 """Wrapper structure for generators that provides lazy membership and can
2347 """Wrapper structure for generators that provides lazy membership and can
2319 be iterated more than once.
2348 be iterated more than once.
General Comments 0
You need to be logged in to leave comments. Login now