##// END OF EJS Templates
revset: added _orderedsetmixin class...
Lucas Moscovicz -
r20749:c3e49b12 default
parent child Browse files
Show More
@@ -2254,6 +2254,37 b' class baseset(list):'
2254 This is part of the mandatory API for smartset."""
2254 This is part of the mandatory API for smartset."""
2255 return lazyset(self, condition)
2255 return lazyset(self, condition)
2256
2256
2257 class _orderedsetmixin(object):
2258 """Mixin class with utility methods for smartsets
2259
2260 This should be extended by smartsets which have the isascending(),
2261 isdescending() and reverse() methods"""
2262
2263 def _first(self):
2264 """return the first revision in the set"""
2265 for r in self:
2266 return r
2267 return None
2268
2269 def _last(self):
2270 """return the last revision in the set"""
2271 self.reverse()
2272 m = self._first()
2273 self.reverse()
2274 return m
2275
2276 def min(self):
2277 """return the smallest element in the set"""
2278 if self.isascending():
2279 return self._first()
2280 return self._last()
2281
2282 def max(self):
2283 """return the largest element in the set"""
2284 if self.isascending():
2285 return self._last()
2286 return self._first()
2287
2257 class lazyset(object):
2288 class lazyset(object):
2258 """Duck type for baseset class which iterates lazily over the revisions in
2289 """Duck type for baseset class which iterates lazily over the revisions in
2259 the subset and contains a function which tests for membership in the
2290 the subset and contains a function which tests for membership in the
General Comments 0
You need to be logged in to leave comments. Login now