private Collection < Tile > getSharedNeigbors ( Tile tile1 , Tile tile2 ) { final Collection < Tile > neighbors1 = map . getNeighbors ( tile1 ) ; final Collection < Tile > neighbors2 = map . getNeighbors ( tile2 ) ; final Collection < Tile > sharedNeighbors = new HashSet <> ( 2 ) ; for ( final Tile neighbor : neighbors1 ) { if ( neighbors2 . contains ( neighbor ) ) { sharedNeighbors . add ( neighbor ) ; } } neighbors1 . clear ( ) ; neighbors2 . clear ( ) ; return sharedNeighbors ; }
Get the neighbors in commons between two tiles .