summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/esodata/Tape.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bjc/esodata/Tape.java')
-rw-r--r--src/main/java/bjc/esodata/Tape.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/bjc/esodata/Tape.java b/src/main/java/bjc/esodata/Tape.java
index 080e216..7d5fd9a 100644
--- a/src/main/java/bjc/esodata/Tape.java
+++ b/src/main/java/bjc/esodata/Tape.java
@@ -132,4 +132,20 @@ public interface Tape<T> {
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.
+ * @param itm The item to append.
+ */
+ default void append(T itm) {
+ int pos = position();
+
+ last();
+
+ insertAfter(itm);
+
+ seekTo(pos);
+ }
}