Created
April 12, 2022 13:53
-
-
Save yknishidate/5b8ba8be6a3c2b401e45341f582c0073 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Array1D | |
{ | |
float vals[WIDTH]; | |
float& operator[] (int index) | |
{ | |
return vals[index]; | |
} | |
}; | |
struct Array2D | |
{ | |
Array1D rows[HEIGHT]; | |
Array1D& operator[] (int index) | |
{ | |
return rows[index]; | |
} | |
}; | |
struct Array | |
{ | |
struct Index | |
{ | |
int x, y; | |
}; | |
float vals[WIDTH * HEIGHT]; | |
float& operator[] (Index index) | |
{ | |
return vals[index.y * WIDTH + index.x]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment