0
$\begingroup$

Say I have a grid that is 4 columns wide, 4 rows high, I can get the "total" number of a certain point like this:

(y * width) + x

So point (0,1) would be calculated like this (1 * 4) + 0 = 4

But does that have some kind of fancy name, something I could use in my code?

1 Answers 1

1

Sorting points in your grid according to the values of the function $(x, y)\mapsto y\cdot\mathrm{width} + x$ is commonly called lexicographic order or dictionary order, since it yields the same order you would get if you sorted the ordered pairs (0, 0), (0, 1), ..., (3, 2), (3, 3) as though they were words in a dictionary. A function which maps one set into a total order is often called a sort key (in programming) or a linear extension (especially in order theory).

  • 0
    Exactly what I was looking for, thanks!2011-11-26