Beispiel #1
0
        /// <summary>
        /// Floods the fill.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="grid">The grid.</param>
        /// <param name="startX">The start x.</param>
        /// <param name="startY">The start y.</param>
        /// <param name="test">The test.</param>
        /// <param name="set">The set.</param>
        /// <param name="compareF">The compare f.</param>
        public static void FloodFill <T>(ref T[][] grid, int startX, int startY, T test, T set,
                                         CompareDel <T> compareF = null)
        {
            var g = new MatrixO <T> {
                Matrix = grid, Height = grid.Length, Width = grid[0].Length, CompareF = compareF
            };

            StartRight(ref g, startX, startY, test, set, true);
            StartRight(ref g, startX, startY + 1, test, set, false);
            grid = g.Matrix;
        }
Beispiel #2
0
        /// <summary>
        /// Replaces the specified matrix.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="matrix">The matrix.</param>
        /// <param name="test">The test.</param>
        /// <param name="set">The set.</param>
        /// <param name="compare">The compare.</param>
        public static void Replace <T>(ref T[][] matrix, T test, T set, CompareDel <T> compare = null)
        {
            var h = matrix.Length;
            var w = matrix[0].Length;

            for (var y = 0; y < h; y++)
            {
                for (var x = 0; x < w; x++)
                {
                    if ((compare == null && matrix[y][x].Equals(test)) ||
                        (compare != null && compare(matrix[y][x], test)))
                    {
                        matrix[y][x] = set;
                    }
                }
            }
        }
Beispiel #3
0
 public static void StringMessage(string str1, string str2, CompareDel comparedel)
 {
     comparedel(str1, str2);
 }