diff options
| author | Jacob McDonnell <jacob@simplelittledream.com> | 2023-02-08 12:04:23 -0500 |
|---|---|---|
| committer | Jacob McDonnell <jacob@simplelittledream.com> | 2023-02-08 12:04:23 -0500 |
| commit | b50daa28690852a0093d600b6831e0d9a2047d89 (patch) | |
| tree | 2288984058a737de157434fad3a6811ac6133f44 /hw2 | |
| parent | 7c2c40dbc93266b210c00495c046108338bda934 (diff) | |
Finshed up to map
Diffstat (limited to 'hw2')
| -rw-r--r-- | hw2/__pycache__/assignment_lists_sp23.cpython-310.pyc | bin | 0 -> 7427 bytes | |||
| -rw-r--r-- | hw2/assignment_lists_sp23.py | 17 |
2 files changed, 11 insertions, 6 deletions
diff --git a/hw2/__pycache__/assignment_lists_sp23.cpython-310.pyc b/hw2/__pycache__/assignment_lists_sp23.cpython-310.pyc Binary files differnew file mode 100644 index 0000000..cac7ac9 --- /dev/null +++ b/hw2/__pycache__/assignment_lists_sp23.cpython-310.pyc diff --git a/hw2/assignment_lists_sp23.py b/hw2/assignment_lists_sp23.py index 57147d9..a339f1f 100644 --- a/hw2/assignment_lists_sp23.py +++ b/hw2/assignment_lists_sp23.py @@ -67,20 +67,25 @@ class DoublyLinkedList(object): def __iter__(self): """Standard python iterator method""" + self.__current = None return self def __next__(self): """Standard python iterator method""" - if self.current is None: - raise StopIteration() + if self.__current is self.__trailer: + raise StopIteration + + if self.__current is None: + self.__current = self.__header - result = self.current.data - self.current = self.current.next - return result + self.__current = self.__current.next_node + return self.__current def map(self, function): """Run function on every element in the list""" - pass + for n in self: + n.element = function(n.element) + def size(self): """Returns the number of elements in the list""" return self.__size |
