'Find an object with certain private value in a java Collection
I am currently coding a game that uses an 8x8 grid. I have to stock a domino (2x1 size) in the grid for every player but when a player wants to add a Domino to his grid I have to verify if the Domino (1) is next to another Domino (2) with the same field type on his Tile that touches the Domino (1). I wanna use a 2D Array but when I have to draw every Tile I got an O(n^2) which is bad. So it is possible to do that with a Java Collection? I was thinking of a Map but this seems pretty hard to achieve...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|