44import java .util .Queue ;
55
66public class IterativeFloodFill {
7+ private IterativeFloodFill () {
8+ }
79
810 /**
911 * Represents a point in 2D space with integer coordinates.
1012 */
1113 private static class Point {
12- public final int x ;
13- public final int y ;
14+ final int x ;
15+ final int y ;
1416
15- public Point (final int x , final int y ) {
17+ Point (final int x , final int y ) {
1618 this .x = x ;
1719 this .y = y ;
1820 }
@@ -29,9 +31,7 @@ public Point(final int x, final int y) {
2931 */
3032 private static boolean shouldSkipPixel (final int [][] image , final int x , final int y , final int oldColor ) {
3133
32- if (x < 0 || x >= image .length ||
33- y < 0 || y >= image [0 ].length ||
34- image [x ][y ] != oldColor ) {
34+ if (x < 0 || x >= image .length || y < 0 || y >= image [0 ].length || image [x ][y ] != oldColor ) {
3535 return true ;
3636 }
3737
@@ -59,7 +59,6 @@ public static void floodFill(final int[][] image, final int x, final int y, fina
5959 int [] dx = {0 , 0 , -1 , 1 , 1 , -1 , 1 , -1 };
6060 int [] dy = {-1 , 1 , 0 , 0 , -1 , 1 , 1 , -1 };
6161
62-
6362 while (!queue .isEmpty ()) {
6463 Point currPoint = queue .poll ();
6564
@@ -76,7 +75,6 @@ public static void floodFill(final int[][] image, final int x, final int y, fina
7675 if (!shouldSkipPixel (image , curX , curY , oldColor )) {
7776 queue .add (new Point (curX , curY ));
7877 }
79-
8078 }
8179 }
8280 }
0 commit comments