I'm attempting to generate a maze using a version of Kruskal's algorithm. I need to check if some coordinates (in an int[] array, eg [1, 5]) are in an existing set.
Here is a copy of the part of the code;
// find sets containing cells to be joined
for (HashSet<int[]> h : cells) {
if (h.contains(new int[]{x, y - 2})) {
set1 = h;
}
}
The issue is that the if statement is never true, but I'm 99.9% sure it should be true at least once.
Am I using HashSet.contains() wrong?
Thanks