Skip to content
Snippets Groups Projects
Commit 228b0aaf authored by Pierre-Yves David's avatar Pierre-Yves David
Browse files

smartset: add first and last methods

In multiple places in the code, we use `someset[0]` or `someset[-1]`. This
works only because the `someset` is usually a baseset. For the same reason we
introduce a `first` and `last` methods to be implemented for all smartset
classes.
parent cd43195e
No related branches found
No related tags found
No related merge requests found
......@@ -2262,6 +2262,18 @@
raise ValueError('arg is an empty sequence')
return max(self)
def first(self):
"""return the first element in the set (user iteration perspective)
Return None if the set is empty"""
raise NotImplementedError()
def last(self):
"""return the last element in the set (user iteration perspective)
Return None if the set is empty"""
raise NotImplementedError()
def reverse(self):
"""reverse the expected iteration order"""
raise NotImplementedError()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment