diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-04-12 13:13:42 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-04-12 13:13:42 -0400 |
| commit | 9052ed6da37af23ea82588d248f409e60a33c6cb (patch) | |
| tree | e816d2032e0a550754712bbae836cdb11383e291 /src/main/java/bjc/esodata | |
| parent | 13aec7074fb0583a72112376df7b8764b0823ce0 (diff) | |
Finish up extraction
This applies the changes that were necessary to complete the extraction
of these packages from bjc-utils
Diffstat (limited to 'src/main/java/bjc/esodata')
| -rw-r--r-- | src/main/java/bjc/esodata/SingleTape.java | 5 | ||||
| -rw-r--r-- | src/main/java/bjc/esodata/Tape.java | 16 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/bjc/esodata/SingleTape.java b/src/main/java/bjc/esodata/SingleTape.java index 28dca2a..c2957a6 100644 --- a/src/main/java/bjc/esodata/SingleTape.java +++ b/src/main/java/bjc/esodata/SingleTape.java @@ -181,6 +181,11 @@ public class SingleTape<T> implements Tape<T> { } @Override + public void append(T itm) { + backing.add(itm); + } + + @Override public int hashCode() { final int prime = 31; 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); + } } |
