X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2FUtil.java;h=0cd4b8241a7c50a5a0d4b83648b40155da234785;hb=0024bdbfe7aab8e6366d6225cb506b2dbdd2b3f9;hp=6bca6d0ef9c542d2789e66fd36392c83a135cbda;hpb=49f569b513c36e8ad421fd5a547bf34bd830652a;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..0cd4b824 100644 --- a/era.mi/src/era/mi/logic/Util.java +++ b/era.mi/src/era/mi/logic/Util.java @@ -84,9 +84,25 @@ public final class Util } return out; } + + /** + * uses the {@link Bit#combineWith(Bit)} method, does not create a new array, + * the result is stored in the first 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 { - Bit execute(Bit a, Bit b); + Bit execute(Bit a, Bit b); } }