I am trying to read in information about the inputs to each gate in a circuit simulator I'm making. The file information for the input connections looks like this:
// Connections from inputs to gates (inputLabel, gateLabel)
INPUT(A, AND1)
INPUT(B, AND1)
INPUT(B, AND2)
INPUT(C, AND2)
I am trying to create a Map with the key being the gateLabel, and storing the inputLabel information.
I.e. -
Key --- Info
AND1 | A,B
AND2 | B,C
The code I have at the moment is this:
String inputCircuitLabel = params[0];
String inGateLabel = params[1];
if(!iConnM.containsKey(inGateLabel)){
inputCircuitLabels.add(inputCircuitLabel);
iConnM.put(inGateLabel, inputCircuitLabels);
}
else{
inputCircuitLabels.add(inCircuitLabel);
}
I was wondering if there is an intuitive way to make a separate class, and make a call to it something like:
GateInput gi = new GateInput(inGateLabel);
ArrayList<GateInput> al;
In order to get a unique arrayList for each gateLabel. Because at the moment AND2 ends up referencing A,B,B,C instead of just B,C.
Map<String, Set<String>>suffice?Map<String, List<String>>.