public Direction isNeighborOf ( GridNode otherNode ) { Direction [ ] orderedDirs = Direction . getOrderedDirs ( ) ; for ( int i = 0 ; i < orderedDirs . length ; i ++ ) { Direction direction = orderedDirs [ i ] ; int newCol = col + direction . col ; int newRow = row + direction . row ; if ( otherNode . col == newCol && otherNode . row == newRow ) { return direction ; } } return null ; }
Checks if the supplied node is adjacent to the current .