equal
deleted
inserted
replaced
2480 return self._ascending is not None and self._ascending |
2480 return self._ascending is not None and self._ascending |
2481 |
2481 |
2482 def isdescending(self): |
2482 def isdescending(self): |
2483 return self._ascending is not None and not self._ascending |
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 class addset(abstractsmartset): |
2504 class addset(abstractsmartset): |
2486 """Represent the addition of two sets |
2505 """Represent the addition of two sets |
2487 |
2506 |
2488 Wrapper structure for lazily adding two structures without losing much |
2507 Wrapper structure for lazily adding two structures without losing much |
2489 performance on the __contains__ method |
2508 performance on the __contains__ method |