I have the following vectors:
vector<unsigned> A,B1;
vector<pair<unsigned,unsigned> > B2;
I want to perform the intersection of (A,B1) and then the intersection of (A,B2). I want to then perform the union of the two intersection results. Vectors A and B1 contain sorted unsigned integers and vector B2 contains pair of (start,end) values. Example vectors A and B2, and their intersection vector is shown below:
vector<unsigned> A(2,4,6,8,9,10,34,74,79,81,89,91,95);
vector<pair<unsigned,unsigned> > B2={ {2, 3}, {29, 40}, {60, 85} };
vector<unsigned> intersection; //result of intersection of A and B2 -> Procedure of performing intersection is explained below
//intersection=(2,34,74,79,81);
2 is in intersection as 2 is in {2,3}.Similarly 34 is in intersection as 34 lies between {29,40}. Similarly 74,79,81 is in intersection as they lie within B2's last element {60,85}'s range.
Is there some efficient way by which I may get the same results as:- (1). intersection A and B1; (2). intersection of A and B2; (3). union of the two intersections performed in step 1 and 2 (i.e. intersection (A,B1) and (A,B2))
Aucun commentaire:
Enregistrer un commentaire