void (int first, int second) { int firstGroupId = smartField.find(first); int secondGroupId = smartField.find(second); if (connectedToBottom(firstGroupId)) { setConnectedToBottom(secondGroupId); } else if (connectedToBottom(secondGroupId)) { setConnectedToBottom(firstGroupId); } smartField.union(first, second); }