\r
import java.util.Arrays;\r
\r
-public final class Util {\r
+public final class Util\r
+{\r
\r
@SuppressWarnings("unchecked")\r
- public static <T> T[] concat(T[]... arrays) {\r
+ public static <T> T[] concat(T[]... arrays)\r
+ {\r
if (arrays.length == 0)\r
throw new IllegalArgumentException("Cannot concatenate 0 arrays.");\r
\r
\r
T[] newArray = Arrays.copyOf(arrays[0], length);\r
int appendIndex = arrays[0].length;\r
- for (int i = 1; i < arrays.length; i++) {\r
+ for (int i = 1; i < arrays.length; i++)\r
+ {\r
System.arraycopy(arrays[i], 0, newArray, appendIndex, arrays[i].length);\r
appendIndex += arrays[i].length;\r
}\r
// return (T[][]) newArray;\r
// }\r
\r
- public static Bit[] and(Bit[] a, Bit[] b) {\r
+ public static Bit[] and(Bit[] a, Bit[] b)\r
+ {\r
return binBitOp(a, b, (bA, bB) -> Bit.and(bA, bB));\r
}\r
\r
- public static Bit[] or(Bit[] a, Bit[] b) {\r
+ public static Bit[] or(Bit[] a, Bit[] b)\r
+ {\r
return binBitOp(a, b, (bA, bB) -> Bit.or(bA, bB));\r
}\r
\r
- public static Bit[] xor(Bit[] a, Bit[] b) {\r
+ public static Bit[] xor(Bit[] a, Bit[] b)\r
+ {\r
return binBitOp(a, b, (bA, bB) -> Bit.xor(bA, bB));\r
}\r
\r
- private static Bit[] binBitOp(Bit[] a, Bit[] b, BitOp op) {\r
+ private static Bit[] binBitOp(Bit[] a, Bit[] b, BitOp op)\r
+ {\r
if (a.length != b.length)\r
throw new IllegalArgumentException("Bit Arrays were not of equal length.");\r
Bit[] out = new Bit[a.length];\r
- for (int i = 0; i < a.length; i++) {\r
+ for (int i = 0; i < a.length; i++)\r
+ {\r
out[i] = op.execute(a[i], b[i]);\r
}\r
return out;\r
}\r
\r
- public static Bit[] not(Bit[] a) {\r
+ public static Bit[] not(Bit[] a)\r
+ {\r
Bit[] out = new Bit[a.length];\r
- for (int i = 0; i < a.length; i++) {\r
+ for (int i = 0; i < a.length; i++)\r
+ {\r
out[i] = a[i].not();\r
}\r
return out;\r
* \r
* @author Christian Femers\r
*/\r
- public static Bit[] combineInto(Bit[] dest, Bit[] addition) {\r
+ public static Bit[] combineInto(Bit[] dest, Bit[] addition)\r
+ {\r
if (dest.length != addition.length)\r
throw new IllegalArgumentException("Bit Arrays were not of equal length.");\r
- for (int i = 0; i < addition.length; i++) {\r
+ for (int i = 0; i < addition.length; i++)\r
+ {\r
dest[i] = dest[i].combineWith(addition[i]);\r
}\r
return dest;\r
}\r
\r
- interface BitOp {\r
+ interface BitOp\r
+ {\r
Bit execute(Bit a, Bit b);\r
}\r
}\r