I will try to make this as simple as possible, I have the following struct struct meteo_record { public: [...ctor...] [...getters and setters...] private: string var_name; string grid_type; float ip1; float ip2; float ip3; float ig1; float ig2; float ig3; int ip1Kind; int data_key; }; All these attributes are non-unique except for the data_key which is not a sorting criteria. What I need to do is to be able to iterate over the whole set by certain criteria. lets say I have the following records [var_name grid_type ip1 ip2 ip3 ig1 ig2 ig3 ip1kind]
12345 12 34 5 0 0
0 1 ^^ 12345 12 34 5 0 0 0 1 GZ 12345 645 24 1 12 34 5 1 GZ 12345 646 24 1 12 34 5 1 GZ 12345 647 24 1 12 34 5 1 GZ 12345 645 24 1 12 34 5 2 GZ 12345 646 24 1 12 34 5 2 GZ 12345 647 24 1 12 34 5 2 GZ 12345 645 26 1 12 34 5 1 GZ 12345 646 26 1 12 34 5 1 GZ 12345 647 26 1 12 34 5 1 GZ 12345 645 26 1 12 34 5 2 GZ 12345 646 26 1 12 34 5 2 GZ 12345 647 26 1 12 34 5 2 TT 12345 645 24 1 12 34 5 1 TT 12345 646 24 1 12 34 5 1 TT 12345 647 24 1 12 34 5 1 TT 12345 645 24 1 12 34 5 2 TT 12345 646 24 1 12 34 5 2 TT 12345 647 24 1 12 34 5 2 TT 12345 645 26 1 12 34 5 1 TT 12345 646 26 1 12 34 5 1 TT 12345 647 26 1 12 34 5 1 TT 12345 645 26 1 12 34 5 2 TT 12345 646 26 1 12 34 5 2 TT 12345 647 26 1 12 34 5 2 [...same sequence again with different grid_type...]
33345 33 34 5 0 0
0 1 ^^ 33345 33 34 5 0 0 0 1 TT 33345 647 26 1 33 34 5 2 [...]
the grid_type is derived from ip1 ip2 and ip3 in some cases and from ig1 ig2 and ig3 in some other cases my criterias are *sort by same _gryd_type_ group by _var_name_ with same _ip2_ and same _ip1kind_ ordered on _ip1_* What I have done is create a multi_index with the grid_type as an index and then I created views for all the other attributes. I first iterate over the grid_types and keep the unique ones in an array (only the keys) /// probably the wrong way to do this in this case I would keep 12345 and 33345 /// for (recordIter = set.begin(); recordIter != set.end(); recordIter = set.upper_bound( (*recordIter)->getgrid_type() ) ) /// /// returns only one of each duplicate grid_type /// for each grid_type I then create the var_name view and iterate over the unique var_names and so on and so on... until i get a grouping that looks like this [var_name grid_type ip1 ip2 ip3 ig1 ig2 ig3 ip1kind] GZ 12345 645 24 1 12 34 5 1 GZ 12345 646 24 1 12 34 5 1 GZ 12345 647 24 1 12 34 5 1 Once I get a grouping like this one, I extract the data_key for each record and read the data from a file. Then I construct a matrix for this grouping from the corresponding data that was read. There must be a better way of doing this, any help will be greatly appreciated! -- Sébastien Fortier