MoreInternals.Model.Selector.NextSpecialChar C# (CSharp) Method

NextSpecialChar() private static method

private static NextSpecialChar ( IEnumerable alreadyUsed, IEnumerable cantBeIn ) : char
alreadyUsed IEnumerable
cantBeIn IEnumerable
return char
        private static char NextSpecialChar(IEnumerable<char> alreadyUsed, IEnumerable<char> cantBeIn)
        {
            // time for an ugly american-ism
            //   technically any character not in cantBeIn could be used here
            //   but lets start at a "weird" character for easier debugging
            //   we're only tossing away 52-ish characters.
            const char startFrom = 'À';

            var quickLookup = new HashSet<char>(cantBeIn);

            var best = alreadyUsed.Count() > 0 ? (char)(alreadyUsed.Max() + 1) : startFrom;

            while (!char.IsLetter(best) || quickLookup.Contains(best))
            {
                best++;
            }

            return best;
        }