public bool Equals(IndexingNode node) { if (node == null) { return(false); } //If root IndexingNode?parent = node.GetParent(); if (_parent == null) { return(parent == null); } else if (parent == null) { return(_parent == null); } else if (_parent.ToString().Equals(parent.ToString(), StringComparison.InvariantCultureIgnoreCase)) { return(ToString().Equals(node.ToString(), StringComparison.InvariantCultureIgnoreCase)); } return(false); }
//Step 2: Insert node only in Tree 2 without conflicts public static void Insert(IndexingNode curNode, IndexingNode insertNode) { IndexingNode parent = insertNode.GetParent(); if (parent == null) { throw new Exception(); } if (curNode.NameSHA256.Equals(parent.NameSHA256, StringComparison.InvariantCulture)) { IndexingNode temp = new IndexingNode(insertNode.NameSHA256, insertNode.ContentSHA256, curNode); foreach (IndexingNode n in curNode.Children) { //Same name, different content if (n.NameSHA256.Equals(insertNode.NameSHA256, StringComparison.InvariantCulture) && !n.ContentSHA256.Equals(insertNode.ContentSHA256, StringComparison.InvariantCulture)) { UpdateNodeIn1.Add(n); UpdateNodeIn2.Add(temp); return; } if (n.NameSHA256.Equals(insertNode.NameSHA256, StringComparison.InvariantCulture) && n.ContentSHA256.Equals(insertNode.ContentSHA256, StringComparison.InvariantCulture)) { return; } } curNode.AddChild(temp); ResultIndexingNodes.Add(temp); return; } foreach (IndexingNode n in curNode.Children) { Insert(n, insertNode); } }