【发布时间】:2014-10-28 11:56:39
【问题描述】:
我正在构建一个逻辑来遍历下面提到的树状结构:-
A: Missing
|
|-B: missing
| |
| |
| |
| |C: real email
|
| D: Real Email
|
|
|
|E: Missing
|
|
|
| F: Missing
|
|
|
| G: Real
|
|H: Missing
|
|
| I : real email
|
|
| J : real email
我必须使用递归来做到这一点,每个节点都是一个 IEnumerable 集合。
任何帮助将不胜感激
我试过下面提到的代码:-
private List<RTAEMailCluster> getClustersForBetaEstimations(RTAEMailCluster childCluster, ref int depth)
{
//still working on this...
if (childCluster.RTAEMailClusters.Count > 0)
{
for (int i = 0; i < childCluster.RTAEMailClusters.Count; i++)
{
if (!_filteredClusters.Contains(childCluster.RTAEMailClusters[i]))
{
_filteredClusters.Add(childCluster);
getClustersForBetaEstimations(childCluster.RTAEMailClusters[i], ref depth);
}
}
depth++;
}
return _filteredClusters;
}
【问题讨论】:
-
也许您可以向我们展示您编写的代码,然后我们可以给您一些指导
-
我在最后一次编辑后投票决定重新打开它。我假设
depth用于返回达到的最大深度? -
@MatthewWatson- 正是深度的使用是为了返回最大深度,因为它将用于进一步的计算