#ifndef __VOID_SPARSE_GRID_HPP #define __VOID_SPARSE_GRID_HPP #include #include "config.hpp" #include namespace CosmoTool { template struct bracketAccessor { typedef typename T::value_type result_type; result_type operator()(T const& V, size_t const N) const throw () { return V[N]; } }; template struct GridElement { std::list eList; }; template struct GridDesc { GridElement *grid; uint32_t gridRes; CType boxSize; }; template class SparseIterator { protected: typedef CType coord[N]; int32_t index_min[N], index_max[N], index_cur[N]; GridElement *eCur; GridDesc desc; typename std::list::iterator eIterator; GridElement *getElement(); public: SparseIterator(GridDesc& d, coord& c, CType R); SparseIterator(); ~SparseIterator(); SparseIterator& operator++(); bool last(); T& operator*() { return *eIterator; } T *operator->() { return eIterator.operator->(); } }; template > class SparseGrid { public: typedef CType coord[N]; typedef SparseIterator iterator; CAccessor acc; SparseGrid(CType L, uint32_t gridRes); ~SparseGrid(); void addElementInGrid(T& e); iterator locateElements(coord& c, CType R); void clear(); protected: GridDesc grid; }; }; #include "sparseGrid.tcc" #endif