A 512 x 512 map with each unit being divided into about 4 squares.
So 512 X 512 x 200 X 4 = 209715200 bytes.
Printable View
Ah. Well, for a space that large, another consideration is how many of those bytes you typically expect to be set. If the percentage is high, then one of the aforementioned approaches will work. But if you are only expecting to actually set a relatively small number of those bits, then you should consider a sparse representation. Something like this:
Since each entry will require at least 12 bytes (probably more like 20 after map overhead), this would only represent an improvement over a dynamic_bitset if the percentage of active bits is expected to be is < 1%.Code:struct Coordinate
{
short x, y, r, s;//x,y is [0,511], r is [0,199], s is [0,3].
bool operator<(const Coordinate &rhs) const
{
if (x < rhs.x)
return true;
if (x == rhs.x && y < rhs.y)
return true;
if (x == rhs.x && r == rhs.y && r < rhs.r)
return true;
if (x == rhs.x && r == rhs.y && r == rhs.r && s < rhs.s)
return true;
return false;
}
};
std::map<Coordinate,bool> active;