diff options
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java')
| -rw-r--r-- | BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java | 45 |
1 files changed, 43 insertions, 2 deletions
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 22b869e..056cab4 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java +++ b/BJC-Utils2/src/main/java/bjc/utils/esodata/SingleTape.java @@ -11,11 +11,12 @@ import java.util.ArrayList; * unbounded to the right, but in practice bounded by available memory. * * You can choose whether or not you want the tape to automatically extend - * itself to the right with null elements by specifiying its auto-extension + * itself to the right with null elements by specifying its auto-extension * policy. * - * @param T + * @param <T> * The element type of the tape. + * * @author bjculkin */ public class SingleTape<T> implements Tape<T> { @@ -204,4 +205,44 @@ public class SingleTape<T> implements Tape<T> { public boolean isDoubleSided() { return false; } + + @Override + public int hashCode() { + final int prime = 31; + + int result = 1; + result = prime * result + ((backing == null) ? 0 : backing.hashCode()); + + return result; + } + + @Override + public boolean equals(Object obj) { + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; + + SingleTape<?> other = (SingleTape<?>) obj; + + if(backing == null) { + if(other.backing != null) return false; + } else if(!backing.equals(other.backing)) return false; + + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + + builder.append("SingleTape [backing="); + builder.append(backing); + builder.append(", pos="); + builder.append(pos); + builder.append(", autoExtend="); + builder.append(autoExtend); + builder.append("]"); + + return builder.toString(); + } } |
