Ejemplo n.º 1
0
        private bool GroupsHaveSameStructure(GroupElement ge1, GroupElement ge2)
        {
            if (!ge2.MatchesRangeOf(ge1))
            {
                return(false);
            }

            // Check for idential substructure
            if (ge1 is Measure && ge2 is Measure)
            {
                return(true);
            }
            if (!(ge1 is Group && ge2 is Group))
            {
                return(false);
            }
            Group g1 = (Group)ge1;
            Group g2 = (Group)ge2;

            if (g1.Count != g2.Count)
            {
                return(false);
            }
            for (int i = 0; i < g1.Count; i++)
            {
                if (!GroupsHaveSameStructure(g1.GroupElements[i], g2.GroupElements[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
 private GroupElement SearchForEquivalentGroupElement(GroupElement target, GroupElement parent)
 {
     if (target.MatchesRangeOf(parent))
     {
         return(parent);
     }
     if (parent is Group)
     {
         Group p = (Group)parent;
         foreach (GroupElement ge in p.GroupElements)
         {
             GroupElement result = SearchForEquivalentGroupElement(target, ge);
             if (result != null)
             {
                 return(result);
             }
         }
     }
     return(null);
 }