Example #1
0
        private bool AfterUnificationAtPosition(Disjunct other, int possiblePos, ref AASetSequence aAASetSequence)
        {
            //This creates the new after string. It will be the unification of other's after string
            //and any of This's after that sticks out beyond the core of other
            int iHowMuchDoesThisStickOut = Math.Max(0, possiblePos + Core.Count + After.Count - other.Core.Count);

            int iHowMuchInCommon = Math.Min(iHowMuchDoesThisStickOut, other.After.Count);

            for (int iCommon = 0; iCommon < iHowMuchInCommon; ++iCommon)
            {
                AASet chThis  = After[After.Count - iHowMuchDoesThisStickOut + iCommon];
                AASet chOther = other.After[iCommon];

                AASet chUnifyOrOptionalEmpty = FlankingUnifyOrOptionalEmpty(chThis, chOther);
                if (chUnifyOrOptionalEmpty == AASet.OptionalEmpty)                 //!!!const
                {
                    return(false);
                }
                aAASetSequence.Append(chUnifyOrOptionalEmpty);
            }

            int iHowMuchLongerDoesOtherStickOutComparedToThis = Math.Max(0, other.After.Count - iHowMuchDoesThisStickOut);

            aAASetSequence.AppendSubsequence(other.After, iHowMuchInCommon, iHowMuchLongerDoesOtherStickOutComparedToThis);
            int iHowMuchLongerDoesThisStickOutComparedToOther = Math.Max(0, iHowMuchDoesThisStickOut - other.After.Count);

            aAASetSequence.AppendSubsequence(After, After.Count - iHowMuchLongerDoesThisStickOutComparedToOther, iHowMuchLongerDoesThisStickOutComparedToOther);
            return(true);
        }