comparison mercurial/revset.py @ 22810:7f97cb12782f

addset: implement first and last methods The implementation is non-lazy for now. One may want to make it more lazy in the future.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 06 Oct 2014 11:57:59 -0700
parents 88dad916c008
children c1fd827e1ae0
comparison
equal deleted inserted replaced
22809:88dad916c008 22810:7f97cb12782f
2616 def reverse(self): 2616 def reverse(self):
2617 self._list.reverse() 2617 self._list.reverse()
2618 if self._ascending is not None: 2618 if self._ascending is not None:
2619 self._ascending = not self._ascending 2619 self._ascending = not self._ascending
2620 2620
2621 def first(self):
2622 if self:
2623 return self._list.first()
2624 return None
2625
2626 def last(self):
2627 if self:
2628 return self._list.last()
2629 return None
2630
2621 class generatorset(abstractsmartset): 2631 class generatorset(abstractsmartset):
2622 """Wrap a generator for lazy iteration 2632 """Wrap a generator for lazy iteration
2623 2633
2624 Wrapper structure for generators that provides lazy membership and can 2634 Wrapper structure for generators that provides lazy membership and can
2625 be iterated more than once. 2635 be iterated more than once.