// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 4071226864956577717L;
// 
// 	public RegisterOverflowException(){
// 		super("Register size exceeded!");
// 	}
// }
// 
// Path: quantum/src/main/java/com/ars/quantum/utils/QRegisterOperations.java
// public class QRegisterOperations {
// 	private static final QRegisterOperations INSTANCE = new QRegisterOperations();
// 
// 	private QRegisterOperations() {
// 	}
// 
// 	public static QRegisterOperations getInstance() {
// 		return INSTANCE;
// 	}
// 
// 	public List<Qubit> fillWith(List<Qubit> list,
// 			Supplier<Qubit> qubitSupplier, int size) {
// 		list = Stream.generate(qubitSupplier).limit(size)
// 				.collect(Collectors.toList());
// 		return list;
// 	}
// 
// 	public QRegister fillWith(QRegister reg, Supplier<Qubit> qubitSupplier) {
// 		reg.setQubits(Stream.generate(qubitSupplier).limit(reg.size())
// 				.collect(Collectors.toList()));
// 		return reg;
// 	}
// 
// 	public QRegister fillWithPattern(String pattern)
// 			throws RegisterOverflowException {
// 		QRegister qreg = new QRegister(pattern.length()).initialize();
// 		for (int i = 0; i < pattern.length(); i++) {
// 			if (pattern.charAt(i) == '1') {
// 				qreg.change(i, new QubitOne());
// 			} else {
// 				qreg.change(i, new QubitZero());
// 			}
// 		}
// 		return qreg;
// 	}
// 
// 	/**
// 	 * Perform the tensor product between two or more qubits. Example, for three
// 	 * qubits |0>, |0> and |1>, the result will be |001>.
// 	 * 
// 	 * @param quantumRegister
// 	 * @return qubit the tensor product of the two qubits.
// 	 */
// 	public Qubit entangle(QRegister quantumRegister) {
// 		if (quantumRegister.size() < 2) {
// 			return null;
// 		}
// 		Qubit bufferQubit = quantumRegister.get(0);
// 		for (int i = 1; i < quantumRegister.size(); i++) {
// 			bufferQubit = QuantumOperations.entangle(bufferQubit,
// 					quantumRegister.get(i));
// 
// 		}
// 		return bufferQubit;
// 	}
// 
// }


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ars.quantum.exception.RegisterOverflowException;
import com.ars.quantum.utils.QRegisterOperations;
package com.ars.qubits;




public class QRegister implements Iterable<Qubit> {
	private List<Qubit>	qubitRegister;
	private int			registerSize;

	public QRegister(int size) {
		this.registerSize = size;
		qubitRegister = new ArrayList<>(size);

	}

	public QRegister initialize() {
		qubitRegister = QRegisterOperations.getInstance().fillWith(qubitRegister, QubitZero::new, registerSize);
		return this;
	}

	public int size() {
		return registerSize;
	}

// Path: quantum/src/main/java/com/ars/quantum/exception/RegisterOverflowException.java
// public class RegisterOverflowException extends Exception {
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 4071226864956577717L;
// 
// 	public RegisterOverflowException(){
// 		super("Register size exceeded!");
// 	}
// }
// 
// Path: quantum/src/main/java/com/ars/quantum/utils/QRegisterOperations.java
// public class QRegisterOperations {
// 	private static final QRegisterOperations INSTANCE = new QRegisterOperations();
// 
// 	private QRegisterOperations() {
// 	}
// 
// 	public static QRegisterOperations getInstance() {
// 		return INSTANCE;
// 	}
// 
// 	public List<Qubit> fillWith(List<Qubit> list,
// 			Supplier<Qubit> qubitSupplier, int size) {
// 		list = Stream.generate(qubitSupplier).limit(size)
// 				.collect(Collectors.toList());
// 		return list;
// 	}
// 
// 	public QRegister fillWith(QRegister reg, Supplier<Qubit> qubitSupplier) {
// 		reg.setQubits(Stream.generate(qubitSupplier).limit(reg.size())
// 				.collect(Collectors.toList()));
// 		return reg;
// 	}
// 
// 	public QRegister fillWithPattern(String pattern)
// 			throws RegisterOverflowException {
// 		QRegister qreg = new QRegister(pattern.length()).initialize();
// 		for (int i = 0; i < pattern.length(); i++) {
// 			if (pattern.charAt(i) == '1') {
// 				qreg.change(i, new QubitOne());
// 			} else {
// 				qreg.change(i, new QubitZero());
// 			}
// 		}
// 		return qreg;
// 	}
// 
// 	/**
// 	 * Perform the tensor product between two or more qubits. Example, for three
// 	 * qubits |0>, |0> and |1>, the result will be |001>.
// 	 * 
// 	 * @param quantumRegister
// 	 * @return qubit the tensor product of the two qubits.
// 	 */
// 	public Qubit entangle(QRegister quantumRegister) {
// 		if (quantumRegister.size() < 2) {
// 			return null;
// 		}
// 		Qubit bufferQubit = quantumRegister.get(0);
// 		for (int i = 1; i < quantumRegister.size(); i++) {
// 			bufferQubit = QuantumOperations.entangle(bufferQubit,
// 					quantumRegister.get(i));
// 
// 		}
// 		return bufferQubit;
// 	}
// 
// }


// Path: quantum/src/main/java/com/ars/qubits/QRegister.java
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ars.quantum.exception.RegisterOverflowException;
import com.ars.quantum.utils.QRegisterOperations;

package com.ars.qubits;




public class QRegister implements Iterable<Qubit> {
	private List<Qubit>	qubitRegister;
	private int			registerSize;

	public QRegister(int size) {
		this.registerSize = size;
		qubitRegister = new ArrayList<>(size);

	}

	public QRegister initialize() {
		qubitRegister = QRegisterOperations.getInstance().fillWith(qubitRegister, QubitZero::new, registerSize);
		return this;
	}

	public int size() {
		return registerSize;
	}

	public void add(Qubit e) throws RegisterOverflowException {