HOW TO CREATE a multy MAP for 3 data sets
I have a huge amount of data set. I wish to use array to store these data. In more deatil,
In my array, i want to use 3 columns such as Number number_of_points point_numbers
. For this i can create a array like mypointstore[][]
(for example mypointstore[20][3]
). But my problem is that i want to store point numbers in column 3 like, 20, 1, 32, 9, 200, 12
and etc.(mypointstore[0][0]= 1
, mypointstore[0][1]= 6
and mypointstore[0][2]={ 20, 1, 32, 9, 200, 12 }
). I don’t know that is it posible to use array for this structure? If so, please help me to solve this problem.
I tried to use map like map<int,int,vector<int>> mypointstore;
but i don’t know how to insert data into this map;
My some codes are here
map<int,int, vector<int>> mypointstore;
size=20;
For (int i=0; i<= size;i++){
Int det=0;
For (int j=0; j<= points.size();j++){//points is a one of array with my points
If (points.at(j)>Z1 && points.at(j) <=Z2){
//Here i want to store i , det and poiznts.at(j) like i i开发者_如何学Cn 1st colum, det in 2nd and
//pointnumber in 3rd colum) in each step of the loop it take a point
//number //which satisfied the if condition so it should be include into my
// vector of map
det++;
}
}
// at here i want to change total det value into 2nd element of my map so it like (0)(6)( 20, 1, 32, 9, 200, 12)
}
similar procedure for the next step so finaly it should be
(0)(6)( 20, 1, 32, 9, 200, 12)
(1)(10)( 20, 1, 32, 9, 200, 12, 233, 80, 12, 90)
(2)(3)( 3, 15, 32)
It sounds to me like you probably want a vector of structs, something like:
struct point_data {
int number;
std::vector<int> point_numbers;
};
std::vector<point_data> points;
I've only put in two "columns", because (at least as I understand it) your number_of_points
is probably point_numbers.size()
.
If you're going to use the number
to find the rest of the data, then your idea to use a map
would make sense:
std::map<int, std:vector<int> > points;
You could use a multimap<int, int>
instead of map<int, vector<int> >
but I usually find the latter more understandable.
精彩评论