#ifndef __POINTMAP_H__ #define __POINTMAP_H__ #include "point.h" // A 2D map class; should probably be optimized more, but beats STL map or hash_map template class PointMap { static const int T = 5, P = 5; static const int T_VAL = (1<> T) * P_VAL + (p.y >> T); int tileIndex = (p.x & T_MASK) * T_VAL + (p.y & T_MASK); if(patches[patchIndex] == 0) { patches[patchIndex] = new E[1<<(T+T)]; memset(patches[patchIndex], 0, (1<<(T+T)) * sizeof(E)); } return patches[patchIndex][tileIndex]; } }; #endif