有一个三叉树形结构
每一个节点都有左 中 右三个子节点
子节点里面有fatherId 即它的父节点
现在给一个节点 求出它的所有子节点个数。
我现在是这样做的 求优化。
private int findCountByCode(String Code) {
int count=0;
List users= userService.queryList("from UserInfo where fatherID=?", loginCode);
count=users.size();
for(UserInfo user:users){
count=count+findCountByLoginCode(user.getLoginCode());
}
return count;
}