示例#1
0
        private static IntBoolString GetIntersection(string super, string candidate)
        {
            IntBoolString result = new IntBoolString();
            result.stringValue = candidate;

            int i = 0;

            while (candidate.Length > i)
            {
                int testlen = candidate.Length - i;
                string leftcan = candidate.Substring(0, testlen);
                string rightcan = candidate.Substring(i, testlen);
                string leftsuper = super.Substring(0, testlen);
                string rightsuper = super.Substring(super.Length - testlen, testlen);

                if (leftcan == rightsuper || rightcan == leftsuper)
                {
                    result.boolValue = (leftcan == rightsuper) ? true : false;
                    result.intValue = testlen;
                    return result;
                }

                i++;
            }

            return result;
        }
示例#2
0
        private static string CombineIntoSuper(string superstring, IntBoolString chosen)
        {
            string toAppend = string.Empty;
            int lenToAppend = chosen.stringValue.Length - chosen.intValue;

            toAppend = (chosen.boolValue == true) ?
                chosen.stringValue.Substring(chosen.stringValue.Length - lenToAppend, lenToAppend) :
                chosen.stringValue.Substring(0, lenToAppend);

            superstring = (chosen.boolValue == true) ?
                superstring + toAppend :
                toAppend + superstring;

            return superstring;
        }