From 74eb1490e1d19d030981e9ef1554018526c16df2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 23 Jan 2014 11:27:07 +0100 Subject: whoops + add array sentinel linked lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/datastructures/linkedlists/template | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/datastructures/linkedlists/template') diff --git a/src/datastructures/linkedlists/template b/src/datastructures/linkedlists/template index c2ff722..d2f6c84 100644 --- a/src/datastructures/linkedlists/template +++ b/src/datastructures/linkedlists/template @@ -164,16 +164,18 @@ public Node removeAfter(Node predecessor) { Node node = predecessor.next; - if (node == null) + if (node != null) + { predecessor.next = node.next; £>if (( with_prev )); then - else if (node.next != null) - node.next.previous = predecessor; + if (node.next != null) + node.next.previous = predecessor; £>fi £>if (( with_tail )); then - if (this.tail == node) - this.tail = predecessor; + if (this.tail == node) + this.tail = predecessor; £>fi + } return node; } @@ -209,14 +211,16 @@ public Node removeBefore(Node successor) { Node node = successor.previous; - if (node == null) + if (node != null) + { successor.previous = node.previous; - else if (node.previous != null) - node.previous.next = successor; + if (node.previous != null) + node.previous.next = successor; £>if (( with_head )); then - if (this.head == node) - this.head = successor; + if (this.head == node) + this.head = successor; £>fi + } return node; } -- cgit v1.2.3-70-g09d2