/**
           * Fills the supplied array with the number of examples
           * from the current dataset that fall into each of the
           * target categories (based on the attribute mask).
           *
           * @param mask The mask that determines which examples
           *        reach the current position in the decision
           *        tree.
           *
           * @param examples An iteration over a series of
           *        examples from the current dataset.
           *
           * @param counts The method expects the parameter to be
           *        an array with a size equal to the number of
           *        target attribute values.  Each position in
           *        the array is filled with a corresponding count
           *        of the number of training examples that fall into
           *        that particular target class, at the current
           *        position in the decision tree.
           *
           * @param reachedHere The method expects the parameter
           *        to be an array with a size equal to the
           *        <i>total</i> number of examples being examined.
           *        Each cell in the array is set to true or
           *        false, depending on whether or not the
           *        corresponding example reaches the current
           *        position in the decision tree.
           */
        private void getExampleCounts(AttributeMask mask, IEnumerator<int[]> examples, int[] counts, bool[] reachedHere)
        {
            // Zero any values currently in stats.
            for (int i = 0; i < counts.Length; i++)
            {
                counts[i] = 0;
            }

            int j = 0;

            // Loop through and get totals.
            while (examples.MoveNext())
            {
                int[] example = (int[])examples.Current;

                if (mask.matchMask(example))
                {
                    counts[example[0]]++;   // Increment appropriate
                    // target count.
                    if (reachedHere != null && reachedHere.Length > j)
                        reachedHere[j] = true;
                }

                j++;
            }
        }