Skip to content

Instantly share code, notes, and snippets.

@yknishidate
Created April 12, 2022 13:53
Show Gist options
  • Save yknishidate/5b8ba8be6a3c2b401e45341f582c0073 to your computer and use it in GitHub Desktop.
Save yknishidate/5b8ba8be6a3c2b401e45341f582c0073 to your computer and use it in GitHub Desktop.
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