I have a struct which has one variable, a `std::vector<std::vector<bool>>`

that represents a grid. One of these structs is equal to another if the grids are equal, or if any rotation of the grids is equal. I'm trying to use an `unordered_set`

to store many of these, however, after some research, I've found that I need to have some sort of a hash function. I have never used a hash function before, and the things I've found in reference to it are confusing to me. So, my question, how do I/what is the best way to write a hash function for such a data type, or is it better to just use an unordered set of grids and test the rotations as I add them in?

Some code:

```
int nx, ny;
typedef std::vector<std::vector<bool>> grid;
struct rotateableGrid {
public:
grid data;
rotateableGrid(grid data) : data(data) {}
rotateableGrid(rotateableGrid &rg) : data(rg.data) {}
bool operator==(const rotateableGrid & rhs) {
for (int c = 0; c < 4; c++) {
if (rotate(c) == rhs.data) return true;
}
return false;
}
private:
grid rotate(int amt) {
if (amt % 4 == 0) return data;
grid ret(ny, std::vector<bool>(nx));
for (int x = 0; x < nx; x++) {
for (int y = 0; y < ny; y++) {
switch (amt % 4) {
case 1:
if (x < ny && nx - 1 - y >= 0) ret[x][nx - 1 - y] = data[y][x];
break;
case 2:
if (nx - 1 - x >= 0 && ny - 1 - y >= 0) ret[ny - 1 - y][nx - 1 - x] = data[y][x];
break;
case 3:
if (ny - 1 - x >= 0 && y < nx) ret[x][nx - 1 - y] = data[y][x];
break;
default:
break;
}
}
}
return ret;
}
};
```

Thanks in advance!

**Note:** I am using C++ in VS 2013