diff options
Diffstat (limited to 'BJC-Utils2')
5 files changed, 43 insertions, 0 deletions
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 0faaabf..5c463c6 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/DoubleTape.java @@ -78,6 +78,11 @@ public class DoubleTape<T> implements Tape<T> { return front.size(); } + @Override + public int position() { + return front.position(); + } + /** * Insert an element before the current item. * diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java index a3e5462..c50be92 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java @@ -26,6 +26,19 @@ public class SingleTape<T> implements Tape<T> { protected boolean autoExtend; /** + * Create a new tape with the specified contents that doesn't + * autoextend. + */ + public SingleTape(T... vals) { + autoExtend = false; + + backing = new ArrayList(vals.length); + + for(T val : vals) { + backing.add(val); + } + } + /** * Create a new empty tape that doesn't autoextend. */ public SingleTape() { @@ -77,6 +90,11 @@ public class SingleTape<T> implements Tape<T> { return backing.size(); } + @Override + public int position() { + return pos; + } + /** * Insert an element before the current item. * diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java index 5f4c3a5..b6a2c01 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java @@ -36,6 +36,13 @@ public interface Tape<T> { int size(); /** + * Get the position of the current item. + * + * @return The position of the current item. + */ + int position(); + + /** * Insert an element before the current item. * * @param itm diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java index 8b8613f..dc885bc 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeChanger.java @@ -83,6 +83,13 @@ public class TapeChanger<T> implements Tape<T> { return currentTape.size(); } + @Override + public int position() { + if (currentTape == null) return 0; + + return currentTape.position(); + } + /** * Insert an element before the current item. * diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeLibrary.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeLibrary.java index 4a5add6..2dbc70b 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeLibrary.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/TapeLibrary.java @@ -63,6 +63,12 @@ public class TapeLibrary<T> implements Tape<T> { return currentTape.size(); } + @Override + public int position() { + if (currentTape == null) return 0; + + return currentTape.position(); + } /** * Insert an element before the current item. * |
