Ejemplo n.º 1
0
        private SelfRefObject <string>[] GetTestData()
        {
            var employees = new SelfRefObject <string> [246];

            employees [0] = new SelfRefObject <string>("Lv0");

            for (int i = 0; i < 5; i++)
            {
                employees[1 + i] = new SelfRefObject <string>("Lv1_" + i)
                {
                    Parent = employees[0]
                };
            }

            for (int i = 0; i < 40; i++)
            {
                employees[6 + i] = new SelfRefObject <string>("LV2_" + i)
                {
                    Parent = employees[1 + i % 4]
                };
            }

            for (int i = 0; i < 200; i++)
            {
                employees[46 + i] = new SelfRefObject <string>("LV3" + i)
                {
                    Parent = employees[6 + i % 30]
                };
            }

            return(employees);
        }
Ejemplo n.º 2
0
        private static void CheckParent(SelfRefObject <string> node, HashSet <SelfRefObject <string> > leaf,
                                        HashSet <SelfRefObject <string> > parent)
        {
            while (node.Parent != null && !parent.Contains(node.Parent))
            {
                if (leaf.Contains(node.Parent))
                {
                    leaf.Remove(node.Parent);
                }

                parent.Add(node.Parent);
            }
        }