diff options
Diffstat (limited to 'src/main/java/Ic2ExpReactorPlanner')
-rw-r--r-- | src/main/java/Ic2ExpReactorPlanner/BigintStorage.java | 64 | ||||
-rw-r--r-- | src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java | 27 |
2 files changed, 0 insertions, 91 deletions
diff --git a/src/main/java/Ic2ExpReactorPlanner/BigintStorage.java b/src/main/java/Ic2ExpReactorPlanner/BigintStorage.java deleted file mode 100644 index d9d4d62c3c..0000000000 --- a/src/main/java/Ic2ExpReactorPlanner/BigintStorage.java +++ /dev/null @@ -1,64 +0,0 @@ -package Ic2ExpReactorPlanner; - -import java.math.BigInteger; -import java.util.Base64; - -/** - * Stores numbers of varying size inside a BigInteger, expecting each to have a defined limit (which need not be an - * exact power of 2). Numbers are to be extracted in reverse order they were stored, and special values can be used to - * make certain values optional for inclusion (the calling class is responsible for handling this logic, though). - * - * @author Brian McCloud - */ -public class BigintStorage { - - private BigInteger storedValue = BigInteger.ZERO; - - /** - * Stores the specified value. Requires that 0 <= value <= max. - * - * @param value the value to store. - * @param max the expected maximum for the value. - */ - public void store(int value, int max) { - if (value < 0 || value > max) { - throw new IllegalArgumentException(); - } - storedValue = storedValue.multiply(BigInteger.valueOf(max + 1)).add(BigInteger.valueOf(value)); - } - - /** - * Extracts a value based on the specified maximum. - * - * @param max the expected maximum for the value. - * @return the extracted value. - */ - public int extract(int max) { - BigInteger[] values = storedValue.divideAndRemainder(BigInteger.valueOf(max + 1)); - storedValue = values[0]; - return values[1].intValue(); - } - - /** - * Takes input of a Base64 string, and converts it to a BigintStorage. - * - * @param code the Base64-encoded string (presumed to be from @outputBase64) - * @return the converted storage object. - */ - public static BigintStorage inputBase64(String code) { - BigintStorage result = new BigintStorage(); - byte[] temp = Base64.getDecoder().decode(code); - result.storedValue = new BigInteger(temp); - return result; - } - - /** - * Outputs the current value of this BigintStorage as a Base64-encoded string. - * - * @return the Base64-encoded string. - */ - public String outputBase64() { - byte[] temp = storedValue.toByteArray(); - return Base64.getEncoder().encodeToString(temp); - } -} diff --git a/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java b/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java deleted file mode 100644 index 1927275485..0000000000 --- a/src/main/java/Ic2ExpReactorPlanner/TaloniusDecoder.java +++ /dev/null @@ -1,27 +0,0 @@ -package Ic2ExpReactorPlanner; - -import java.math.BigInteger; - -/** - * Pulls values out of codes from Talonius's old reactor planner. - * - * @author Brian McCloud - */ -public class TaloniusDecoder { - - private BigInteger dataStack = null; - - public TaloniusDecoder(final String dataCode) { - dataStack = new BigInteger(dataCode, 36); - } - - public int readInt(final int bits) { - return readBigInteger(bits).intValue(); - } - - private BigInteger readBigInteger(final int bits) { - BigInteger data = dataStack.and(BigInteger.ONE.shiftLeft(bits).subtract(BigInteger.ONE)); - dataStack = dataStack.shiftRight(bits); - return data; - } -} |