I have a two dimensional grid of cells. In this simulation, cells may request to switch position with another cell. The request also has a priority.
The problem is that Im having a hard time coming up with a good way to structure this. If A wants to switch with B, and B also wants to switch with A, they currently can be switched and switched back in a single logic tick (which should be impossible).
The solution probably involves making sure (A to B)==(B to A) and insertion sorting them into a list by their priority.
Does such data structure have a name? Anyone recognise the problem and can provide some good links for reading?