示例#1
0
文件: Program.cs 项目: mstepanyak/Mct
        static string Substract(string from, string value)
        {
            var bsd = new Bst <char>();

            foreach (var ch in value)
            {
                bsd.AddUnique(ch);
            }

            var builder = new StringBuilder();

            foreach (var ch in from)
            {
                if (!bsd.Contains(ch))
                {
                    builder.Append(ch);
                }
            }

            return(builder.ToString());
        }
示例#2
0
        private static bool HasDublicates(int[] array)
        {
            if (array == null)
            {
                throw new ArgumentNullException();
            }
            if (array.Length == 0)
            {
                return(false);
            }

            var bsd = new Bst <int>();

            for (var i = 1; i < array.Length; i++)
            {
                if (!bsd.AddUnique(array[i]))
                {
                    return(true);
                }
            }

            return(false);
        }