Samstag, 3. April 2010

stl::map vs boost::multi_index

Well, what is the best way to simulate 3 column database table using c++?
I am trying to use the Boost.multiindex container for my particle tracking project.
The first problem what I was accounting is the set_intersection. The data table is following:

struct particleID
 {
 int           ID;// real ID for particle from Gadget2 file "ID" block
 unsigned int  IDf;// postition in the file
 particleID(int id,const unsigned int idf):ID(id),IDf(idf){}
 bool operator<(const particleID& p)const { return ID<p.ID;}
 unsigned int getByGasID()const {return (ID&0x0FFF);};
 friend std::ostream & operator <<(std::ostream& , const particleID& p );
 };

The multiset container is configured as following:
struct ID{};
struct IDf{};
struct IDgas{};

typedef multi_index_container<
 particleID,
 indexed_by<
  ordered_unique<
   tag<IDf>,  BOOST_MULTI_INDEX_MEMBER(particleID,unsigned int,IDf)>,
  ordered_non_unique<
   tag,BOOST_MULTI_INDEX_MEMBER(particleID,int,ID)>,
  ordered_non_unique<
   tag,BOOST_MULTI_INDEX_CONST_MEM_FUN(particleID,unsigned int,getByGasID)> 
 >
> particlesID_set;


So I will continue it in my next post, while I am going to watch nice movie by "ARTE" channel.

Keine Kommentare: