lattice_system とりあえず形になった。
template <class T, class IndexMapper> class lattice_system{ public: ... private: std::vector<T> elems_; IndexMapper mapper_; }; class index_mapper{ public: ... size_type point_to_index(const point_type& p){ //様々な実装 } private: range range_; };
という2つのクラスが中心で
// -1 <= x <= 1, -1 <= y <= 1 の範囲の格子系を生成 lattice_system<Widget, index_mapper> sys(range(-1, 1, -1, 1)); // 点(1, 1)の格子の要素にアクセス sys[ point(1, 1) ] = widget;
の様に使う。
index_mapperを入れ替えることでいろいろな格子系を生成できるようになる。
問題は効率だな〜。boost::multi_arrayくらいの効率であれば良いけどどうかな。