From f51f6da7319787348c38b875652b5c0e9f88c8aa Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:43:13 -0400 Subject: Cleanup pass Pass to do some cleanups --- src/main/java/bjc/esodata/Tape.java | 39 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/main/java/bjc/esodata/Tape.java') diff --git a/src/main/java/bjc/esodata/Tape.java b/src/main/java/bjc/esodata/Tape.java index 7d5fd9a..134ba62 100644 --- a/src/main/java/bjc/esodata/Tape.java +++ b/src/main/java/bjc/esodata/Tape.java @@ -8,7 +8,7 @@ package bjc.esodata; * unbounded to the right, but in practice bounded by available memory. * * @param - * The element type of the tape. + * The element type of the tape. * * @author bjculkin */ @@ -24,7 +24,7 @@ public interface Tape { * Set the item the tape is currently on. * * @param itm - * The new value for the tape item. + * The new value for the tape item. */ void item(T itm); @@ -46,7 +46,7 @@ public interface Tape { * Insert an element before the current item. * * @param itm - * The item to add. + * The item to add. */ void insertBefore(T itm); @@ -54,7 +54,7 @@ public interface Tape { * Insert an element after the current item. * * @param itm - * The item to insert. + * The item to insert. */ void insertAfter(T itm); @@ -86,11 +86,11 @@ public interface Tape { /** * 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. + * 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. + * The amount to attempt to move the cursor left. * * @return True if the cursor was moved left. */ @@ -107,7 +107,7 @@ public interface Tape { * Move the cursor the specified amount right. * * @param amt - * The amount to move the cursor right by. + * The amount to move the cursor right by. * * @return Whether the cursor was moved right. */ @@ -115,37 +115,40 @@ public interface Tape { /** * Seek to an absolute position on the tape. - * + * * @param pos - * The position to seek to. + * The position to seek to. * @return Whether or not the tape successfully seeked to that position. */ boolean seekTo(int pos); /** * Check if this tape is at its end. - * + * * Equivalent to checking if position() == size(). - * + * * @return Whether or not the tape is at its end. */ default boolean atEnd() { return position() == size(); } - + /** * Append an item to the tape. + * + * By default, uses a fairly non-performant implementation. Should be overidden + * in subclasses to be more performant. * - * By default, uses a fairly non-performant implementation. Should be overidden in subclasses to be more performant. - * @param itm The item to append. + * @param itm + * The item to append. */ default void append(T itm) { int pos = position(); - + last(); - + insertAfter(itm); - + seekTo(pos); } } -- cgit v1.2.3