##// END OF EJS Templates
filteredset: implement `first` and `last`
Pierre-Yves David -
r22813:5a96df26 default
parent child Browse files
Show More
@@ -2482,6 +2482,25 b' class filteredset(abstractsmartset):'
2482 2482 def isdescending(self):
2483 2483 return self._ascending is not None and not self._ascending
2484 2484
2485 def first(self):
2486 for x in self:
2487 return x
2488 return None
2489
2490 def last(self):
2491 it = None
2492 if self._ascending is not None:
2493 if self._ascending:
2494 it = self.fastdesc
2495 else:
2496 it = self.fastasc
2497 if it is None:
2498 # slowly consume everything. This needs improvement
2499 it = lambda: reversed(list(self))
2500 for x in it():
2501 return x
2502 return None
2503
2485 2504 class addset(abstractsmartset):
2486 2505 """Represent the addition of two sets
2487 2506
General Comments 0
You need to be logged in to leave comments. Login now