private static int GetFamilyLevel(IGenealogy firstGenealogy, int maximum) { if (firstGenealogy == null) { return(0); } List <Pair <IGenealogy, int> > list = new List <Pair <IGenealogy, int> >(); list.Add(new Pair <IGenealogy, int>(firstGenealogy, 0)); int maxDepth = 0; int index = 0; while (index < list.Count) { Pair <IGenealogy, int> gene = list[index]; index++; if (maxDepth < gene.Second) { maxDepth = gene.Second; } if (maxDepth >= maximum) { return(maxDepth); } if (gene.First.IChildren != null) { foreach (IGenealogy child in gene.First.IChildren) { if (child == null) { continue; } list.Add(new Pair <IGenealogy, int>(child, gene.Second + 1)); } } } return(maxDepth); }
private static int GetFamilyLevel(IGenealogy firstGenealogy, int maximum) { if (firstGenealogy == null) return 0; List<Pair<IGenealogy, int>> list = new List<Pair<IGenealogy, int>>(); list.Add(new Pair<IGenealogy, int>(firstGenealogy, 0)); int maxDepth = 0; int index = 0; while (index < list.Count) { Pair<IGenealogy, int> gene = list[index]; index++; if (maxDepth < gene.Second) { maxDepth = gene.Second; } if (maxDepth >= maximum) { return maxDepth; } if (gene.First.IChildren != null) { foreach (IGenealogy child in gene.First.IChildren) { if (child == null) continue; list.Add(new Pair<IGenealogy, int>(child, gene.Second + 1)); } } } return maxDepth; }
public static int GetFamilyLevel(IGenealogy firstGenealogy) { return GetFamilyLevel(firstGenealogy, int.MaxValue); }
public static int GetFamilyLevel(IGenealogy firstGenealogy) { return(GetFamilyLevel(firstGenealogy, int.MaxValue)); }