From 504ca816530efdff06bc202e0432ebd354aec304 Mon Sep 17 00:00:00 2001 From: EVE Date: Tue, 14 Mar 2017 12:07:14 -0400 Subject: Cleanup --- .../main/java/bjc/utils/esodata/DoubleTape.java | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java index 85abbdc..6e256b6 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java @@ -16,7 +16,7 @@ package bjc.utils.esodata; * * All operations that refer to the tape refer to the currently active side of * the tape, except for flip. - * + * * Flip refers to the entire tape for 'obvious' reasons. * * @param T @@ -24,8 +24,8 @@ package bjc.utils.esodata; * @author bjculkin */ public class DoubleTape implements Tape { - private Tape front; - private Tape back; + private Tape front; + private Tape back; /** * Create a new empty double-sided tape that doesn't autoextend. @@ -52,6 +52,7 @@ public class DoubleTape implements Tape { * * @return The item the tape is on. */ + @Override public T item() { return front.item(); } @@ -62,6 +63,7 @@ public class DoubleTape implements Tape { * @param itm * The new value for the tape item. */ + @Override public void item(T itm) { front.item(itm); } @@ -71,6 +73,7 @@ public class DoubleTape implements Tape { * * @return The current number of elements in the tape. */ + @Override public int size() { return front.size(); } @@ -81,6 +84,7 @@ public class DoubleTape implements Tape { * @param itm * The item to add. */ + @Override public void insertBefore(T itm) { front.insertBefore(itm); back.insertAfter(null); @@ -89,6 +93,7 @@ public class DoubleTape implements Tape { /** * Insert an element after the current item. */ + @Override public void insertAfter(T itm) { front.insertAfter(itm); back.insertBefore(itm); @@ -96,12 +101,13 @@ public class DoubleTape implements Tape { /** * Remove the current element. - * + * * Also moves the cursor back one step if possible to maintain relative * position, and removes the corresponding item from the non-active side * * @return The removed item from the active side. */ + @Override public T remove() { back.remove(); @@ -111,6 +117,7 @@ public class DoubleTape implements Tape { /** * Move the cursor to the left-most position. */ + @Override public void first() { front.first(); back.last(); @@ -119,6 +126,7 @@ public class DoubleTape implements Tape { /** * Move the cursor the right-most position. */ + @Override public void last() { front.last(); back.first(); @@ -131,6 +139,7 @@ public class DoubleTape implements Tape { * * @return True if the cursor was moved left. */ + @Override public boolean left() { return left(1); } @@ -146,11 +155,13 @@ public class DoubleTape implements Tape { * * @return True if the cursor was moved left. */ + @Override public boolean left(int amt) { boolean succ = front.left(amt); - if (succ) + if(succ) { back.right(amt); + } return succ; } @@ -162,6 +173,7 @@ public class DoubleTape implements Tape { * * @return Whether the cursor was moved right. */ + @Override public boolean right() { return right(1); } @@ -176,11 +188,13 @@ public class DoubleTape implements Tape { * * @return Whether the cursor was moved right. */ + @Override public boolean right(int amt) { boolean succ = front.right(amt); - if (succ) + if(succ) { back.left(amt); + } return succ; } -- cgit v1.2.3