@@ -397,16 +397,15 @@ enum FreeCellResult {
397397 }
398398
399399 /** Find the cell with the lest number of possible candidates.
400- * @param rowColumnResult a two-element int array receiving the
401- * row and column of the result. First element will be the row index,
402- * the second the column index.
400+ * @param rowColumnResult an object receiving the
401+ * row and column of the result.
403402 * @return {@linkplain FreeCellResult#FOUND} if a free cell was found,
404403 * {@linkplain FreeCellResult#NONE_FREE} if all cells are occupied,
405404 * {@linkplain FreeCellResult#CONTRADICTION} if cells were free but
406405 * could not be occupied.
407406 */
408407 FreeCellResult findLeastFreeCell (final CellIndex rowColumnResult ) {
409- int minimumBits = - 1 ;
408+ int minimumBits = Integer . MAX_VALUE ;
410409 int minimumRow = -1 ;
411410 int minimumColumn = -1 ;
412411
@@ -429,9 +428,9 @@ FreeCellResult findLeastFreeCell(final CellIndex rowColumnResult) {
429428 }
430429 int bits = Integer .bitCount (free );
431430
432- assert bits <= width ;
431+ assert bits > 0 && bits <= width ;
433432
434- if (bits != 0 && ( minimumBits == - 1 || bits < minimumBits ) ) {
433+ if (bits < minimumBits ) {
435434 minimumColumn = column ;
436435 minimumRow = row ;
437436 minimumBits = bits ;
@@ -445,7 +444,7 @@ FreeCellResult findLeastFreeCell(final CellIndex rowColumnResult) {
445444 }
446445 rowColumnResult .row = minimumRow ;
447446 rowColumnResult .column = minimumColumn ;
448- return minimumBits != - 1
447+ return minimumBits != Integer . MAX_VALUE
449448 ? FreeCellResult .FOUND
450449 : FreeCellResult .NONE_FREE ;
451450 }
0 commit comments