The lexicographical (or row-major) order of a map

The lexicographical (or row-major) order of a map

on Nov 25 in Math, Programeren by

flattr this!

Storing a map in memory can happen in two ways.

You can store every Y-position in an X-row, like this:

map[X][Y] = tile;

That might be neat, I find it a little annoying in Javascript and prefer the “lexicographic order” or “row-major order”.

Basically, you calculate the ID of the tile, what total number it is on the map.

lexicograph = y * width + x;

One Comment

  • celebrities zegt:

    Woah! I’m really loving the template/theme of this site. It’s
    simple, yet effective. A lot of times it’s tough to get that “perfect balance” between superb usability and visual appeal. I must say you’ve
    done a amazing job with this. In addition, the blog loads very quick
    for me on Opera. Superb Blog!

Leave a Comment