Given std::map<ID,struct>, efficient way to access std::vector<struct.member>?
Hello folks, I've got an interesting little design problem and I'm looking for some advice on how best to implement an efficient solution. [ I posted this message to comp.lang.c++.moderated yesterday. I'm reposting here because this _seems_ like a job for some type of iterator adaptor and I'm thinking that perhaps one of the Boost libraries might be useful in this context. But which (if any)? Would uBLAS help me here perhaps? Or am I way off base? ] Here's a simplified statement of the problem that I believe outlines the relevant details: I've got a class declared as follows: --- begin example class ---- class CFilter { public: typedef struct tag_sRow { A_t A; B_t B; C_t C; .. .. .. // some number of structure members... } sRow_t; typedef std::map<key_t/*type unimportant*/, sDataRow_t> mapData_t; typedef mapDataSet_t::iterator mapiterData_t; typedef mapDataSet_t::const_iterator mapconstiterData_t; private: mapData_t m_mapData; public: void ProcessRow(const sRow_t& sRow) { // process a single row of data } // end method ProcessRow void ProcessData(const mapData_t& mapData) { // algorithm needs fast access to: // std::vector<A_t>, std::vector<B_t>, std::vector<C_t> .... } // end method ProcessData }; // end class declaration CFilter --- end example class --- In English: CFilter declares some structure with some number of data members of arbitrary types. Internally CFilter allocates a std::map of these structures using some key_t. Effectively this defines a table of data whose rows are of type sRow_t, and whose columns can be conceptualized as std::vector<A_t>, std::vector<B_t> where std::vector<sRow_t.some_member>.size() == mapData<key_t, sDataRow_t>.size(). At runtime, CFilter.ProcessRow is called std::map<key_t, sRow_t>.size() times followed by a single call to CFilter.ProcessData. I'm trying to figure out how to _efficiently_ access the column vectors in the implementation of CFilter.ProcessData. Any suggestions would be greatly appreciated. Thanks in advance - Chris Russell
participants (1)
-
Chris Russell