aboutsummaryrefslogtreecommitdiffstats
path: root/src/datastructures/linkedlists/template
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-01-23 11:27:07 +0100
committerMattias Andrée <maandree@operamail.com>2014-01-23 11:27:07 +0100
commit74eb1490e1d19d030981e9ef1554018526c16df2 (patch)
tree48901557639c1e3d82e6d5c3d7934ea62e60135b /src/datastructures/linkedlists/template
parentm (diff)
downloadalgorithms-and-data-structures-74eb1490e1d19d030981e9ef1554018526c16df2.tar.gz
algorithms-and-data-structures-74eb1490e1d19d030981e9ef1554018526c16df2.tar.bz2
algorithms-and-data-structures-74eb1490e1d19d030981e9ef1554018526c16df2.tar.xz
whoops + add array sentinel linked lists
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/datastructures/linkedlists/template24
1 files changed, 14 insertions, 10 deletions
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;
}