}
boolean updateTheOutSet(Node parentNode, Node currentNode) {
- HashMap<Transition, ArrayList<NameValuePair>> setSet = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap();
+ HashMap<Transition, ArrayList<NameValuePair>> setSets = parentNode.getOutgoingEdges().get(currentNode).getSetSetMap();
HashSet<String> updatedVarNames = new HashSet<String>();
Edge currentEdge = parentNode.getOutgoingEdges().get(currentNode);
HashMap<String, Integer> lastWriter = currentEdge.getLastWriter();
HashMap<String, String> lastValue = currentEdge.getLastValue();
+ HashMap<String, Integer> outSetVarMap = new HashMap<String, Integer>();
boolean isChanged = false;
- for (Map.Entry mapElement : setSet.entrySet()) {
- ArrayList<NameValuePair> value = (ArrayList<NameValuePair>)mapElement.getValue();
+ for (Map.Entry mapElement : setSets.entrySet()) {
+ ArrayList<NameValuePair> setSet = (ArrayList<NameValuePair>)mapElement.getValue();
- for (int i = 0;i < value.size();i++) {
- updatedVarNames.add(value.get(i).getVarName());
+ for (int i = 0;i < setSet.size();i++) {
+ updatedVarNames.add(setSet.get(i).getVarName());
}
}
for (NameValuePair i : parentNode.getOutSet()) {
+ outSetVarMap.put(i.getVarName(), i.getAppNum());
if (!updatedVarNames.contains(i.getVarName()))
isChanged |= currentNode.getOutSet().add(i);
}
- for (Map.Entry mapElement : setSet.entrySet()) {
- ArrayList<NameValuePair> value = (ArrayList<NameValuePair>)mapElement.getValue();
+ for (Map.Entry mapElement : setSets.entrySet()) {
+ ArrayList<NameValuePair> setSet = (ArrayList<NameValuePair>)mapElement.getValue();
- for (int i = 0;i < value.size();i++) {
- if (value.get(i).getAppNum().equals(lastWriter.get(value.get(i).getVarName()))
- && value.get(i).getValue().equals(lastValue.get(value.get(i).getVarName()))) {
- isChanged |= currentNode.getOutSet().add(value.get(i));
+ for (int i = 0;i < setSet.size();i++) {
+ String varName = setSet.get(i).getVarName();
+ Integer writer = lastWriter.get(varName);
+ String value = lastValue.get(varName);
+
+ if (setSet.get(i).getAppNum().equals(writer)
+ && setSet.get(i).getValue().equals(value)) {
+ if (outSetVarMap.containsKey(varName)) {
+ Integer hashCode = outSetVarMap.get(varName).hashCode() * 31 +
+ varName.hashCode();
+ currentNode.getOutSet().remove(hashCode);
+ }
+ isChanged |= currentNode.getOutSet().add(setSet.get(i));
}
}
}