我对填充结构的递归方法有疑问LinkedHashMap<String,LinkedHashMap<String, Integer>>
。我不知道最后一次返回中的函数调用是否在正确的位置 - 我现在尝试将它放在三个不同的位置:
public static LinkedHashMap<String, LinkedHashMap<String, Integer>> GetXMLRegularExpression(
Node node, LinkedHashMap<String, LinkedHashMap<String, Integer>> a) {
List<Element> children = getChildren(node);
List<String> childrenString = ConversionString(children);
List<String> Clear = RemoveDuplicate(children);
LinkedHashMap<String, Integer> lhm = new LinkedHashMap<String, Integer>();
// System.out.println(childrenString);
if (!isLeaf(node)) {
for (int i = 0; i < Clear.size(); i++) {
int count = NumberOfAppear(childrenString, Clear.get(i));
lhm.put(Clear.get(i), count);
}
a.put(node.getNodeName(), lhm);
return a;
} else {
lhm.put(node.getNodeName(), 0);
a.put(node.getNodeName(), lhm);
return a;
}
for (int j = 0; j < children.size(); j++) {
return GetXMLRegularExpression(children.get(j), a);
}
}