equal
deleted
inserted
replaced
2252 boolean. |
2252 boolean. |
2253 |
2253 |
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 |
2260 revset |
2291 revset |
2261 """ |
2292 """ |