public void Merge(GetFirst other)
 {
     if (other.OrderBy < OrderBy)
     {
         Value   = other.Value;
         OrderBy = other.OrderBy;
     }
 }
Пример #2
0
        public static bool IsBefore(Node node1, Node node2)
        {
            //Return true if node1 is before node2
            if (node1 == node2)
            {
                return(false);
            }
            //Find nearest common ancestor
            List <Node> node1List = new List <Node>();
            Node        n         = node1;

            while (n != null)
            {
                node1List.Add(n);
                n = n.Parent();
            }
            node1List.Reverse();
            List <Node> node2List = new List <Node>();

            n = node2;
            while (n != null)
            {
                node2List.Add(n);
                n = n.Parent();
            }
            node2List.Reverse();
            for (int i = 1; i < Math.Min(node1List.Count, node2List.Count); i++)
            {
                if (node1List[i] != node2List[i])
                {
                    Node     parent   = node1List[i - 1];
                    Node     child1   = node1List[i];
                    Node     child2   = node2List[i];
                    GetFirst getFirst = new GetFirst(parent, child1, child2);
                    parent.Apply(getFirst);
                    return(getFirst.FirstChild == child1);
                }
            }
            return(node1List.Count < node2List.Count);
        }