#include <map_type.h>
Public Member Functions | |
| Map (DATA defaultValue) | |
| Map (const Map< DATA, BLKSIZE > &map) | |
| Map & | operator= (const Map< DATA, BLKSIZE > &map) |
| ~Map () | |
| void | fill (DATA val) |
| void | clear () |
| void | set (int x, int y, DATA val) |
| DATA | get (int x, int y) const |
| bool | onMap (int x, int y) const |
| void | worldSet (int x, int y, DATA val) |
| DATA | worldGet (int x, int y) const |
| bool | worldOnMap (int x, int y) const |
| DATA * | getBase () |
Public Attributes | |
| const int | MAP_BLOCKSIZE |
| const int | MAP_W |
| Number of clusters in horizontal direction. | |
| const int | MAP_H |
| Number of clusters in vertical direction. | |
Private Attributes | |
| DATA | _mapData [((WORLD_W+BLKSIZE-1)/BLKSIZE)*((WORLD_H+BLKSIZE-1)/BLKSIZE)] |
| const DATA | _MAP_DEFAULT_VALUE |
| Default value of a cluster. | |
A map is assumed to cover a 2D grid of WORLD_W times WORLD_H positions. A block of positions may be clustered, and represented by a single data value.
| DATA | Data type of a data value. | |
| BLKSIZE | Size of the cluster. |
Definition at line 95 of file map_type.h.
Generic map constructor.
| defaultValue | Default value to use for off-map positions, and for clearing the map. |
Definition at line 136 of file map_type.h.
| Map< DATA, BLKSIZE >::Map | ( | const Map< DATA, BLKSIZE > & | map | ) | [inline] |
Copy constructor
Definition at line 147 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::MAP_W.
Generic map destructor
Definition at line 174 of file map_type.h.
| Map< DATA, BLKSIZE > & Map< DATA, BLKSIZE >::operator= | ( | const Map< DATA, BLKSIZE > & | map | ) | [inline] |
Assignment operator
Definition at line 161 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::MAP_W.
| void Map< DATA, BLKSIZE >::fill | ( | DATA | value | ) | [inline] |
Generic fill routine.
| value | Value with which to fill the map. |
Definition at line 185 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::MAP_W.
Referenced by Map< DATA, BLKSIZE >::clear().
| void Map< DATA, BLKSIZE >::clear | ( | ) | [inline] |
Generic clear routine.
Resets all data of the map to _MAP_DEFAULT_VALUE.
Definition at line 199 of file map_type.h.
References Map< DATA, BLKSIZE >::_MAP_DEFAULT_VALUE, and Map< DATA, BLKSIZE >::fill().
Referenced by Micropolis::init(), and Micropolis::initWillStuff().
| void Map< DATA, BLKSIZE >::set | ( | int | x, | |
| int | y, | |||
| DATA | value | |||
| ) | [inline] |
Set the value of a cluster.
If the coordinate is off the map, the value is not stored.
| x | X cluster position (at world position x * MAP_BLOCKSIZE). | |
| y | Y cluster position (at world position y * MAP_BLOCKSIZE). | |
| value | Value to use. |
Definition at line 225 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::onMap().
Referenced by Micropolis::computeComRateMap(), Micropolis::decRateOfGrowthMap(), Micropolis::setFireCoverage(), Micropolis::setPoliceCoverage(), Micropolis::setRateOfGrowth(), and smoothStationMap().
| DATA Map< DATA, BLKSIZE >::get | ( | int | x, | |
| int | y | |||
| ) | const [inline] |
Return the value of a cluster.
If the coordinate is off the map, the _MAP_DEFAULT_VALUE is returned.
| x | X cluster position (at world position x * MAP_BLOCKSIZE). | |
| y | Y cluster position (at world position y * MAP_BLOCKSIZE). |
Definition at line 242 of file map_type.h.
References Map< DATA, BLKSIZE >::_MAP_DEFAULT_VALUE, Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::onMap().
Referenced by Micropolis::decRateOfGrowthMap(), Micropolis::getFireCoverage(), Micropolis::getPoliceCoverage(), Micropolis::getRateOfGrowth(), and smoothStationMap().
| bool Map< DATA, BLKSIZE >::onMap | ( | int | x, | |
| int | y | |||
| ) | const [inline] |
Verify that cluster coordinates are within map boundaries.
| x | X cluster position (at world position x * MAP_BLOCKSIZE). | |
| y | Y cluster position (at world position y * MAP_BLOCKSIZE). |
Definition at line 259 of file map_type.h.
References Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::MAP_W.
Referenced by Map< DATA, BLKSIZE >::get(), and Map< DATA, BLKSIZE >::set().
| void Map< DATA, BLKSIZE >::worldSet | ( | int | x, | |
| int | y, | |||
| DATA | value | |||
| ) | [inline] |
Set the value of a cluster.
If the coordinate is off the map, the value is not stored.
| x | X world position. | |
| y | Y world position. | |
| value | Value to use. |
Definition at line 274 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::worldOnMap().
Referenced by Micropolis::doSpecialZone(), Micropolis::fireZone(), Micropolis::incRateOfGrowth(), and Micropolis::startFireInZone().
| DATA Map< DATA, BLKSIZE >::worldGet | ( | int | x, | |
| int | y | |||
| ) | const [inline] |
Return the value of a cluster.
If the coordinate is off the map, the _MAP_DEFAULT_VALUE is returned.
| x | X world position. | |
| y | Y world position. |
Definition at line 293 of file map_type.h.
References Map< DATA, BLKSIZE >::_MAP_DEFAULT_VALUE, Map< DATA, BLKSIZE >::_mapData, Map< DATA, BLKSIZE >::MAP_H, and Map< DATA, BLKSIZE >::worldOnMap().
Referenced by Micropolis::crimeScan(), Micropolis::doFire(), Micropolis::doSpecialZone(), Micropolis::evalCom(), Micropolis::fireZone(), Micropolis::getDensityStr(), Micropolis::incRateOfGrowth(), and Micropolis::startFireInZone().
| bool Map< DATA, BLKSIZE >::worldOnMap | ( | int | x, | |
| int | y | |||
| ) | const [inline] |
Verify that world coordinates are within map boundaries.
| x | X world position. | |
| y | Y world position. |
Definition at line 312 of file map_type.h.
References WORLD_H, and WORLD_W.
Referenced by Map< DATA, BLKSIZE >::worldGet(), and Map< DATA, BLKSIZE >::worldSet().
| DATA * Map< DATA, BLKSIZE >::getBase | ( | ) | [inline] |
Return the base address of the map data.
Definition at line 210 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData.
Referenced by Micropolis::getFireCoverageMapBuffer(), Micropolis::getPoliceCoverageMapBuffer(), and Micropolis::getRateOfGrowthMapBuffer().
| const int Map< DATA, BLKSIZE >::MAP_BLOCKSIZE |
Size of a cluster in number of world positions.
Definition at line 104 of file map_type.h.
DATA Map< DATA, BLKSIZE >::_mapData[((WORLD_W+BLKSIZE-1)/BLKSIZE)*((WORLD_H+BLKSIZE-1)/BLKSIZE)] [private] |
Data fields of the map in column-major mode.
Definition at line 124 of file map_type.h.
Referenced by Map< DATA, BLKSIZE >::fill(), Map< DATA, BLKSIZE >::get(), Map< DATA, BLKSIZE >::getBase(), Map< DATA, BLKSIZE >::Map(), Map< DATA, BLKSIZE >::operator=(), Map< DATA, BLKSIZE >::set(), Map< DATA, BLKSIZE >::worldGet(), and Map< DATA, BLKSIZE >::worldSet().
1.5.6