summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/esodata
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java b/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java
new file mode 100644
index 0000000..4ead829
--- /dev/null
+++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/Tape.java
@@ -0,0 +1,44 @@
+package bjc.utils.esodata;
+
+import java.util.ArrayList;
+
+public class Tape<T> {
+ private ArrayList<T> backing;
+ private int pos;
+
+ public Tape() {
+ backing = new ArrayList<>();
+ }
+
+ public T item() {
+ return backing.get(pos);
+ }
+
+ public boolean left() {
+ if(pos == 0) return false;
+
+ pos -= 1;
+ return true;
+ }
+
+ public boolean left(int amt) {
+ if((pos - amt) < 0) return false;
+
+ pos -= amt;
+ return true;
+ }
+
+ public boolean right() {
+ if(pos == (backing.size() - 1)) return false;
+
+ pos += 1;
+ return true;
+ }
+
+ public boolean right(int amt) {
+ if((pos + amt) >= (backing.size() - 1)) return false;
+
+ pos += amt;
+ return true;
+ }
+}