AsciimationStatistics.Program.GetRepeatedCount C# (CSharp) Method

GetRepeatedCount() static private method

static private GetRepeatedCount ( string str, List repeatedLengths, List notrepeatedLengths ) : void
str string
repeatedLengths List
notrepeatedLengths List
return void
        static void GetRepeatedCount(string str, List<int> repeatedLengths, List<int> notrepeatedLengths)
        {
            int i = 0;
            while (i < str.Length)
            {
                int j = i;
                do
                    j++;
                while (j != str.Length && str[j] == str[i]);

                int repeatCount = j - i;
                if (repeatCount >= 2)
                {
                    repeatedLengths.Add(repeatCount);

                    i = j;
                }
                else
                {
                    while (j != str.Length && str[j] != str[j - 1])
                        j++;

                    int nonrepeatCount = j - i;
                    if (j != str.Length)
                        nonrepeatCount--;

                    notrepeatedLengths.Add(nonrepeatCount);

                    i = j;
                    if (j != str.Length)
                        i--;
                }
            }
        }