X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2FUtil.java;h=6aec8844c7b115eff2f5958566169363038ee43d;hb=4aab0c0fc739b8710af599ae0701568ecd5ab44f;hp=6bca6d0ef9c542d2789e66fd36392c83a135cbda;hpb=8bcbbc8e3c1cf04dd051b354b1b0ddf07c3f9ae1;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/Util.java b/era.mi/src/era/mi/logic/Util.java index 6bca6d0e..6aec8844 100644 --- a/era.mi/src/era/mi/logic/Util.java +++ b/era.mi/src/era/mi/logic/Util.java @@ -84,6 +84,29 @@ public final class Util } return out; } + + public static Bit[] arrayOfZ(int length) + { + Bit[] out = new Bit[length]; + Arrays.fill(out, Bit.Z); + return out; + } + + /** + * uses the {@link Bit#combineWith(Bit)} method, does not create a new array, + * the result is stored in the fist array. + * + * @author Christian Femers + */ + public static Bit[] combineInto(Bit[] dest, Bit[] addition) + { + if (dest.length != addition.length) + throw new IllegalArgumentException("Bit Arrays were not of equal length."); + for (int i = 0; i < addition.length; i++) { + dest[i] = dest[i].combineWith(addition[i]); + } + return dest; + } interface BitOp {