summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/esodata/TapeChanger.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-10-11 13:41:07 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2017-10-11 13:41:07 -0300
commit946cab444bc301d8a7c756a1bab039558288de89 (patch)
tree419f27c39a509bcd83cae0e6630be8eb7ff95a30 /base/src/main/java/bjc/utils/esodata/TapeChanger.java
parentc82e3b3b2de0633317ec8fc85925e91422820597 (diff)
Cleanup work
Diffstat (limited to 'base/src/main/java/bjc/utils/esodata/TapeChanger.java')
-rw-r--r--base/src/main/java/bjc/utils/esodata/TapeChanger.java108
1 files changed, 20 insertions, 88 deletions
diff --git a/base/src/main/java/bjc/utils/esodata/TapeChanger.java b/base/src/main/java/bjc/utils/esodata/TapeChanger.java
index dc885bc..08f56c1 100644
--- a/base/src/main/java/bjc/utils/esodata/TapeChanger.java
+++ b/base/src/main/java/bjc/utils/esodata/TapeChanger.java
@@ -10,15 +10,15 @@ package bjc.utils.esodata;
* either return null/false.
*
* @param <T>
- * The element type of the tapes.
+ * The element type of the tapes.
*/
public class TapeChanger<T> implements Tape<T> {
- private Tape<Tape<T>> tapes;
- private Tape<T> currentTape;
+ /* Our list of tapes. */
+ private Tape<Tape<T>> tapes;
+ /* The current tape. */
+ private Tape<T> currentTape;
- /**
- * Create a new empty tape changer.
- */
+ /** Create a new empty tape changer. */
public TapeChanger() {
tapes = new SingleTape<>();
}
@@ -27,9 +27,10 @@ public class TapeChanger<T> implements Tape<T> {
* Create a new tape changer with the specified tapes.
*
* @param current
- * The tape to mount first.
+ * The tape to mount first.
+ *
* @param others
- * The tapes to put in this tape changer.
+ * The tapes to put in this tape changer.
*/
@SafeVarargs
public TapeChanger(final Tape<T> current, final Tape<T>... others) {
@@ -46,11 +47,6 @@ public class TapeChanger<T> implements Tape<T> {
currentTape = tapes.item();
}
- /**
- * Get the item the tape is currently on.
- *
- * @return The item the tape is on.
- */
@Override
public T item() {
if (currentTape == null) return null;
@@ -58,12 +54,6 @@ public class TapeChanger<T> implements Tape<T> {
return currentTape.item();
}
- /**
- * Set the item the tape is currently on.
- *
- * @param itm
- * The new value for the tape item.
- */
@Override
public void item(final T itm) {
if (currentTape == null) return;
@@ -71,11 +61,6 @@ public class TapeChanger<T> implements Tape<T> {
currentTape.item(itm);
}
- /**
- * Get the current number of elements in the tape.
- *
- * @return The current number of elements in the tape.
- */
@Override
public int size() {
if (currentTape == null) return 0;
@@ -90,12 +75,6 @@ public class TapeChanger<T> implements Tape<T> {
return currentTape.position();
}
- /**
- * Insert an element before the current item.
- *
- * @param itm
- * The item to add.
- */
@Override
public void insertBefore(final T itm) {
if (currentTape == null) return;
@@ -103,9 +82,6 @@ public class TapeChanger<T> implements Tape<T> {
currentTape.insertBefore(itm);
}
- /**
- * Insert an element after the current item.
- */
@Override
public void insertAfter(final T itm) {
if (currentTape == null) return;
@@ -113,14 +89,6 @@ public class TapeChanger<T> implements Tape<T> {
currentTape.insertAfter(itm);
}
- /**
- * 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() {
if (currentTape == null) return null;
@@ -128,9 +96,6 @@ public class TapeChanger<T> implements Tape<T> {
return currentTape.remove();
}
- /**
- * Move the cursor to the left-most position.
- */
@Override
public void first() {
if (currentTape == null) return;
@@ -138,9 +103,6 @@ public class TapeChanger<T> implements Tape<T> {
currentTape.first();
}
- /**
- * Move the cursor the right-most position.
- */
@Override
public void last() {
if (currentTape == null) return;
@@ -148,29 +110,11 @@ public class TapeChanger<T> implements Tape<T> {
currentTape.last();
}
- /**
- * Move the cursor one space left.
- *
- * The cursor can't go past zero.
- *
- * @return True if the cursor was moved left.
- */
@Override
public boolean left() {
return left(1);
}
- /**
- * Move the cursor the specified amount left.
- *
- * The cursor can't go past zero. Attempts to move the cursor by amounts
- * that would exceed zero don't move the cursor at all.
- *
- * @param amt
- * The amount to attempt to move the cursor left.
- *
- * @return True if the cursor was moved left.
- */
@Override
public boolean left(final int amt) {
if (currentTape == null) return false;
@@ -178,28 +122,11 @@ public class TapeChanger<T> implements Tape<T> {
return currentTape.left(amt);
}
- /**
- * Move the cursor one space right.
- *
- * Moving the cursor right will auto-extend the tape if that is enabled.
- *
- * @return Whether the cursor was moved right.
- */
@Override
public boolean right() {
return right(1);
}
- /**
- * Move the cursor the specified amount right.
- *
- * Moving the cursor right will auto-extend the tape if that is enabled.
- *
- * @param amt
- * The amount to move the cursor right by.
- *
- * @return Whether the cursor was moved right.
- */
@Override
public boolean right(final int amt) {
if (currentTape == null) return false;
@@ -233,7 +160,8 @@ public class TapeChanger<T> implements Tape<T> {
/**
* Check if a tape is currently loaded.
*
- * @return Whether or not a tape is loaded.
+ * @return
+ * Whether or not a tape is loaded.
*/
public boolean isLoaded() {
return currentTape != null;
@@ -245,7 +173,8 @@ public class TapeChanger<T> implements Tape<T> {
* Attempting to load a tape that isn't there won't eject the current
* tape.
*
- * @return Whether or not the next tape was loaded.
+ * @return
+ * Whether or not the next tape was loaded.
*/
public boolean nextTape() {
final boolean succ = tapes.right();
@@ -263,7 +192,8 @@ public class TapeChanger<T> implements Tape<T> {
* Attempting to load a tape that isn't there won't eject the current
* tape.
*
- * @return Whether or not the previous tape was loaded.
+ * @return
+ * Whether or not the previous tape was loaded.
*/
public boolean prevTape() {
final boolean succ = tapes.left();
@@ -283,7 +213,7 @@ public class TapeChanger<T> implements Tape<T> {
* The specified tape is loaded.
*
* @param tp
- * The tape to insert and load.
+ * The tape to insert and load.
*/
public void insertTape(final Tape<T> tp) {
tapes.insertAfter(tp);
@@ -299,7 +229,8 @@ public class TapeChanger<T> implements Tape<T> {
*
* Loads the previous tape, if there is one.
*
- * @return The removed tape.
+ * @return
+ * The removed tape.
*/
public Tape<T> removeTape() {
if (currentTape == null) return null;
@@ -322,7 +253,8 @@ public class TapeChanger<T> implements Tape<T> {
/**
* Get how many tapes are currently in the changer.
*
- * @return How many tapes are currently in the changer.
+ * @return
+ * How many tapes are currently in the changer.
*/
public int tapeCount() {
return tapes.size();