public static void RunAlphaNumericTests()
        {
            var decimalDigits = "0123456789";
            var decimals      = decimalDigits.ToCharArray();
            var alphaNumeric  = new List <char>();

            for (var c = 'A'; c <= 'Z'; c++)
            {
                alphaNumeric.Add(c);
            }
            for (var c = 'a'; c <= 'z'; c++)
            {
                alphaNumeric.Add(c);
            }
            alphaNumeric.AddRange(decimals);

            for (var depth = 4; depth <= 8; depth++)
            {
                var   sw      = Stopwatch.StartNew();
                ulong counted = 0;
                var   jagged  = new EnumerableJaggedArray <char>(alphaNumeric, depth);
                foreach (var item in jagged)
                {
                    counted++;
                }
                Console.WriteLine($"Depth {depth}: Counted {counted} in {sw.Elapsed}");
            }
        }
 public JaggedArrayEnumerator(EnumerableJaggedArray <T> enumerableJaggedArray)
 {
     this.arrays = enumerableJaggedArray.JaggedArrays.Select(x => x.ToArray()).ToArray();
     lengths     = arrays.Select(x => x.Length).ToArray();
     indexes     = lengths.Select(x => 0).ToArray();
     indexes[indexes.Length - 1] = -1;
     Current = arrays.Select(x => x.First()).ToArray();
 }
        public SeriesEnumerator(SeriesIterator <T> seriesIterator)
        {
            this.BaseSeries   = seriesIterator.BaseSeries;
            this.IterationSet = seriesIterator.IterationSet;

            this.maskEnumerator = new SeriesMaskEnumerator(seriesIterator.BaseSeries.Length, seriesIterator.Depth);
            maskEnumerator.MoveNext();
            BaseSeriesElements         = BaseSeries.Select(x => new[] { x }).ToArray();
            jaggedElements             = (T[][])BaseSeriesElements.Clone();
            this.jaggedArray           = new EnumerableJaggedArray <T>(jaggedElements);
            this.jaggedArrayEnumerator = jaggedArray.GetEnumerator();
        }
        public static IEnumerable <char[]> GetWordListFractals(IEnumerable <string> wordList)
        {
            var fractalbases = AlphaFractalBases;

            foreach (var word in wordList)
            {
                var wordPermuations = word.Select(x => fractalbases[x]).ToList();
                var jaggedSingle    = new EnumerableJaggedArray <char>(wordPermuations.ToArray());
                foreach (var perm in jaggedSingle)
                {
                    yield return(perm);
                }
            }
        }
        public static void RunTests()
        {
            var decimalDigits = "0123456789";
            var hexDigits     = decimalDigits + "abcdef";
            var digits        = decimalDigits.ToArray();
            var hex           = hexDigits.ToArray();
            var t1            = "123".ToCharArray();
            var t2            = "12".ToCharArray();
            var jagged        = new EnumerableJaggedArray <char>(hex, hex);

            foreach (var item in jagged)
            {
                var s = new string(item);
                Console.WriteLine(s);
            }



            var jagged8 = new EnumerableJaggedArray <char>(hex, 8);


            var sw = Stopwatch.StartNew();

            //var jagged8Count = jagged8.Count();
            //Console.WriteLine($"jagged8Count {jagged8Count} in {sw.Elapsed}");

            sw = Stopwatch.StartNew();
            uint counted  = 0;
            int  phase    = 0;
            int  phaseMax = 1 << 28;

            foreach (var item in jagged8)
            {
                counted++;
                //phase++;
                //if (phase == phaseMax)
                //{
                //    phase = 0;
                //    Console.WriteLine($"Counted {counted} in {sw.Elapsed}");
                //}
            }
            Console.WriteLine($"Counted {counted} in {sw.Elapsed}");
        }
        public static IEnumerable <char[]> GetWordListFractalsWithMaskedFractals(IEnumerable <string> wordList, char[] fractalList, int maxDepth)
        {
            var fractalbases = AlphaFractalBases;

            foreach (var word in wordList)
            {
                var wordPermuations = word.Select(x => fractalbases[x]).ToList();

                var jaggedSingle = new EnumerableJaggedArray <char>(wordPermuations.ToArray());
                foreach (var jagged in jaggedSingle)
                {
                    var seriesIterator = new SeriesIteratorOfChar(jagged, fractalList, maxDepth);
                    foreach (var iter in seriesIterator)
                    {
                        yield return(iter);
                    }
                }
            }
        }
        public static IEnumerable <char[]> GetWordListFractalsWithPrefix(IEnumerable <string> wordList, char[] prefixList, int maxSuffixLength)
        {
            var fractalbases = AlphaFractalBases;

            foreach (var word in wordList)
            {
                var wordPermuations = word.Select(x => fractalbases[x]).ToList();
                for (var i = 0; i < maxSuffixLength; i++)
                {
                    var copy = wordPermuations.ToList();
                    for (var k = 0; k < i; k++)
                    {
                        copy.Insert(0, prefixList);
                    }
                    var jaggedSingle = new EnumerableJaggedArray <char>(copy.ToArray());
                    foreach (var perm in jaggedSingle)
                    {
                        yield return(perm);
                    }
                }
            }
        }
        public bool MoveNext()
        {
            bool result = jaggedArrayEnumerator.MoveNext();

            if (!result)
            {
                result = maskEnumerator.MoveNext();
                if (result)
                {
                    if (jaggedElements.Length != maskEnumerator.Current.Length)
                    {
                        jaggedElements = maskEnumerator.Current.Select(x => new T[] { }).ToArray();
                    }
                    //var jaggedElements = new List<T[]>();
                    int baseIndex = 0;
                    for (var i = 0; i < maskEnumerator.Current.Length; i++)
                    {
                        if (maskEnumerator.Current[i])
                        {
                            //jaggedElements.Add(BaseSeriesElements[baseIndex++]);
                            jaggedElements[i] = BaseSeriesElements[baseIndex++];
                        }
                        else
                        {
                            //jaggedElements.Add((T[])IterationSet.Clone());
                            jaggedElements[i] = (T[])IterationSet.Clone();
                        }
                    }
                    this.jaggedArray           = new EnumerableJaggedArray <T>(jaggedElements.ToArray());
                    this.jaggedArrayEnumerator = jaggedArray.GetEnumerator();
                    result = jaggedArrayEnumerator.MoveNext();
                }
            }

            return(result);
        }