X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2FUtil.java;h=6aec8844c7b115eff2f5958566169363038ee43d;hb=830af2a47f501b4d31f68663b609d225eae603cd;hp=6bca6d0ef9c542d2789e66fd36392c83a135cbda;hpb=d67ded9f20c85280a044d94d8278897ca6c49384;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 {