Ejemplo n.º 1
0
        public void Insert(OrbitPair orb)
        {
            // 1. If the tree is empty, return a new, single node
            if (tree == null)
            {
                tree.Add(orb.Parent, new List <string> {
                    orb.Child
                });
            }

            // 2. Otherwise, recur down the tree
            InsertRec(orb.Parent, orb.Child);
        }
Ejemplo n.º 2
0
        public void Insert(OrbitPair op)
        {
            if (Bodies.Where(c => c.Name == op.Child).Count() == 1 && Bodies.Where(c => c.Name == op.Parent).Count() == 1)
            {
                SolarBody child  = Bodies.Single(s => s.Name == op.Child);
                SolarBody parent = Bodies.Single(s => s.Name == op.Parent);
                child.Parent = op.Parent;
                parent.Children.Add(child);
            }

            else if (Bodies.Where(c => c.Name == op.Child).Count() == 1)
            {
                SolarBody child  = Bodies.Single(s => s.Name == op.Child);
                SolarBody parent = new SolarBody(op.Parent);
                child.Parent = op.Parent;
                parent.Children.Add(child);
                Bodies.Add(parent);
            }

            else if (Bodies.Where(c => c.Name == op.Parent).Count() == 1)
            {
                SolarBody parent = Bodies.Single(s => s.Name == op.Parent);
                SolarBody child  = new SolarBody(op.Child, op.Parent);
                parent.Children.Add(child);
                Bodies.Add(child);
            }

            else
            {
                SolarBody parent = new SolarBody(op.Parent);
                SolarBody child  = new SolarBody(op.Child, op.Parent);
                parent.Children.Add(child);
                Bodies.Add(child);
                Bodies.Add(parent);
            }
        }