Esempio n. 1
0
        public bool GetIsAnagramTo(Anagram anagram)
        {
            bool isAnagram = true;

            if (AnagramCharDict.Count != anagram.AnagramCharDict.Count)
            {
                return(!isAnagram);
            }

            var anagramCharDictEnumerator = AnagramCharDict.GetEnumerator();

            while (isAnagram && anagramCharDictEnumerator.MoveNext())
            {
                char        chr         = anagramCharDictEnumerator.Current.Key;
                AnagramChar anagramChar = anagramCharDictEnumerator.Current.Value;

                isAnagram = isAnagram &&
                            anagram.AnagramCharDict.ContainsKey(chr) &&
                            anagramChar.EqualsTo(anagram.AnagramCharDict.GetValueOrDefault(chr));
            }

            return(isAnagram);
        }