- /**
- *
- * @param union The output of merging n {@link WireArray}s into one. Must have
- * length = a1.length() + a2.length() + ... + an.length().
- * @param inputs The inputs to be merged into the union
- */
- public Merger(WireArray union, WireArray... inputs)
- {
- this.inputs = inputs;
- this.outI = union.createInput();
- this.beginningIndex = new int[inputs.length];
+ int length = 0;
+ for (int i = 0; i < inputs.length; i++)
+ {
+ beginningIndex[i] = length;
+ length += inputs[i].length();
+ inputs[i].addObserver(this);
+ }
+
+ if (length != union.length())
+ throw new IllegalArgumentException(
+ "The output of merging n WireArrays into one must have length = a1.length() + a2.length() + ... + an.length().");
+ }