public class RedCodeArrayList<E>
extends java.util.ArrayList<E>
implements java.util.List<E>, java.util.RandomAccess, java.lang.Cloneable, java.io.Serializable
Instruction,
ArrayList,
Serialized Form| Constructor and Description |
|---|
RedCodeArrayList(int maxcycles,
int maxlength)
This constructor adds absolute variable values which may be referenced within a
RedCode program.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addInstrEmptyDat(int times)
Adds multiple empty (default DAT) lines to the RedCodeArrayList instance.
|
protected void |
addInstrFromString(java.lang.String line)
Adds an Instruction to the List computed from a String element.
|
protected java.lang.String |
addInstrLineParse(RedCodeLineParser parse)
Adds an Instruction to the List computed from a RedCodeLineParser
element.
|
void |
addWarrior(Warrior warrior)
Adds the instruction set of a Warrior to the RedCodeArrayList instance.
|
protected void |
clearInstructionSet()
Sets all values back to empty default.
|
protected void |
finalize()
Performs all possible label computations.
|
int |
getAddr(int id,
int fieldAorB)
Computes the absolute address of the instruction referenced by a field.
|
int |
getAddrAt(int id,
int fieldAorB)
Computes the absolute address of the instruction referenced by a field,
and of that reference again the absolute address.
|
protected java.lang.String |
getErrorLabel()
This Method returns missing labels which must be dealt with, before
running the redCode.
|
protected int |
getErrorLabelLine()
Gets the first found error label line.
|
Instruction |
getInstruction(int id)
Gets Instruction at id.
|
Instruction |
getInstruction(int id,
int fieldAorB)
Computes the absolute address of the instruction referenced by a field
and returns the value of the new found instruction.
|
Instruction |
getInstructionAt(int id,
int fieldAorB)
Computes the absolute address of the instruction referenced by a field,
and of that reference again the absolute address to return its
Instruction.
|
protected boolean |
hasModifier()
Tests if there is at least one modifier within the instruction set.
|
int |
increment(int oldId)
Computes the relative address increment to help prevent out of bound
errors.
|
void |
replace(int idOldElement,
int idNewElement)
Replaces an old Element with a new one by id.
|
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSizeadd, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArraypublic RedCodeArrayList(int maxcycles,
int maxlength)
maxcycles - should be a positive value.maxlength - should be a positive value.protected int getErrorLabelLine()
protected void finalize()
throws java.io.IOException
finalize in class java.lang.Objectjava.io.IOException - In case getInstruction() fails due to error labels.protected java.lang.String getErrorLabel()
protected java.lang.String addInstrLineParse(RedCodeLineParser parse)
parse - must not contain any syntax errors.protected void addInstrFromString(java.lang.String line)
throws java.io.IOException
line - must not contain any syntax errors.java.io.IOException - In case RedCodeLineParser() fails.public void addInstrEmptyDat(int times)
times - must be positive and shows how often a DAT line should be
added.public void addWarrior(Warrior warrior) throws java.io.IOException
warrior - must not contain any errors.java.io.IOException - In case finalize() fails.public void replace(int idOldElement,
int idNewElement)
idOldElement - going to be overwritten.idNewElement - the new instruction value.public int increment(int oldId)
oldId - value which is incrementedpublic Instruction getInstruction(int id) throws java.io.IOException
id - must be within the range of possible IDs and greater zero.java.io.IOException - In case there is an unknown Label.public int getAddr(int id,
int fieldAorB)
throws java.io.IOException
id - must be within the range of possible IDs and greater zero.fieldAorB - must be 0 or 1 (recommended Field.a / Field.b)java.io.IOException - In case there is an unknown Label.public int getAddrAt(int id,
int fieldAorB)
throws java.io.IOException
id - must be within the range of possible IDs and greater zero.fieldAorB - must be 0 or 1 (recommended Field.a / Field.b)java.io.IOException - In case there is an unknown Label.public Instruction getInstruction(int id, int fieldAorB) throws java.io.IOException
id - must be within the range of possible IDs and greater zero.fieldAorB - must be 0 or 1 (recommended Field.a / Field.b)java.io.IOException - In case there is an unknown Label.public Instruction getInstructionAt(int id, int fieldAorB) throws java.io.IOException
id - must be within the range of possible IDs and greater zero.fieldAorB - must be 0 or 1 (recommended Field.a / Field.b)java.io.IOException - In case there is an unknown Label.protected boolean hasModifier()
protected void clearInstructionSet()