diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-01-04 14:37:13 +0200 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-03-08 14:04:00 +0200 |
commit | d6a88ab22e1ca1939c09f8b9de7e5ea804ed55d5 (patch) | |
tree | f99491bbb0ae6f9496c76af891b054a65206cd9d | |
parent | 9751f0f839a9f76be2406c23f62e4853c26c5958 (diff) | |
download | git-buildpackage-d6a88ab22e1ca1939c09f8b9de7e5ea804ed55d5.tar.gz git-buildpackage-d6a88ab22e1ca1939c09f8b9de7e5ea804ed55d5.tar.bz2 git-buildpackage-d6a88ab22e1ca1939c09f8b9de7e5ea804ed55d5.zip |
rpm/LinkedList.delete: return the previous node
The preceding node of the deleted node. However, return the next (i.e.
the new first node) of the list if deleting the first node, and, return
None if the list is empty after deletion.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/rpm/linkedlist.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gbp/rpm/linkedlist.py b/gbp/rpm/linkedlist.py index f1321776..ca000453 100644 --- a/gbp/rpm/linkedlist.py +++ b/gbp/rpm/linkedlist.py @@ -189,23 +189,26 @@ class LinkedList(collections.Iterable): >>> node3 = list.insert_before(node2, 'baz') >>> [str(data) for data in list] ['foo', 'baz', 'bar'] - >>> list.delete(node3) + >>> str(list.delete(node3)) + 'foo' >>> [str(data) for data in list] ['foo', 'bar'] >>> print "%s" % node3 <BLANKLINE> - >>> list.delete(node1) + >>> str(list.delete(node1)) + 'bar' >>> [str(data) for data in list] ['bar'] >>> list.delete(node2) >>> [str(data) for data in list] [] """ + ret = node.prev if node is self._first: - self._first = self._first.next + ret = self._first = self._first.next if node is self._last: self._last = self._last.prev node.delete() - + return ret # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |