Exemplo n.º 1
0
 private DataTree ConformList(DataTree t)
 {
     return(RequestNewSizeRepeatLast(t.Count));
 }
Exemplo n.º 2
0
        private static void CrossRefTree(DataTree t1, DataTree t2, out DataTree first, out DataTree second)
        {
            first  = t1.RequestCrossRefRepetition(t2.Count, t2.Count);
            second = t2.RequestCrossRefRepetition(t1.Count, 1);

            if (first.IsTree || second.IsTree)
            {
                if (!first.IsTree)
                {
                    first.GraftTree();
                }
                if (!second.IsTree)
                {
                    second.GraftTree();
                }
                for (int i = 0; i < first.Count; i++)
                {
                    //int val = (first.Data[i] as DataTree).Count * (second.Data[i] as DataTree).Count;
                    //int c1 = (first.Data[i])
                    //first.Data[i].Replace((first.Data[i] as DataTree).RequestCrossRefRepetition(val, true));
                    //second.Data[i].Replace((second.Data[i] as DataTree).RequestCrossRefRepetition(val, false));
                    CrossRefTree(first.Data[i] as DataTree, second.Data[i] as DataTree, out DataTree f1, out DataTree f2);
                    first.ReplaceBranch(f1, i);
                    second.ReplaceBranch(f2, i);
                }
            }
        }
Exemplo n.º 3
0
        public static void ConformTrees(DataTree t1, DataTree t2, DataGroupingModes mode, out DataTree firstTree, out DataTree secondTree, int primary = 0)
        {
            int ind = -1;

            if (mode == DataGroupingModes.Shortest)
            {
                ind = t1.Count <= t2.Count ? 0 : 1;
            }
            else if (mode == DataGroupingModes.Longest)
            {
                ind = t1.Count >= t2.Count ? 0 : 1;
            }
            else if (mode == DataGroupingModes.Primary)
            {
                firstTree  = primary == 0 ? t1 : t1.ConformTree(t2);
                secondTree = primary == 0 ? t2.ConformTree(t1) : t2;
                return;
            }

            if (ind != -1)
            {
                if (ind == 0)
                {
                    firstTree = t1; secondTree = t2.ConformList(t1);
                }
                else
                {
                    firstTree = t1.ConformList(t2); secondTree = t2;
                }
                bool test = ind == 0 ? firstTree.IsTree : secondTree.IsTree;
                if (test)
                {
                    if (ind == 0 && !secondTree.IsTree)
                    {
                        secondTree.GraftTree();
                    }
                    else if (ind == 1 && !firstTree.IsTree)
                    {
                        firstTree.GraftTree();
                    }
                    for (int i = 0; i < firstTree.Count; i++)
                    {
                        ConformTrees(firstTree[i] as DataTree, secondTree[i] as DataTree, mode, out DataTree f1, out DataTree f2, primary);
                        firstTree.Data[i].Replace(f1);
                        secondTree.Data[i].Replace(f2);
                    }
                }
            }
            else
            {
                CrossRefTree(t1, t2, out firstTree, out secondTree);
            }
        }