1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
/* Set-theoretical difference of node i and j */
int StorageMap::difference(int i, int j) {
multimap<int,int>::iterator it2;
multimap<int,int> difference;
/*
printf("\nI:\n");
for (it=mymap.lower_bound (i) ; it != mymap.upper_bound (i); ++it)
printf("%i => %i\n", it->first, it->second);
printf("\nJ:\n");
for (it=mymap.lower_bound (j) ; it != mymap.upper_bound (j); ++it)
printf("%i => %i\n", it->first, it->second);
*/
//vector<int> a;
int counter = 0;
it = mymap.find(i);
it2 = mymap.find(j);
while (it->first == i)
{
if(it2->first != j) {
//printf("List for %i longer than list for %i, include\n", it->first, it2->first);
//a.push_back(it->second);
++counter;
++it;
}
else if (it->second < it2->second) {
//printf("%i=>%i < %i=>%i, include\n", it->first, it->second, it2->first, it2->second);
//a.push_back(it->second);
++counter;
++it;
}
else if (it->second > it2->second) {
//printf("%i=>%i > %i=>%i, exclude\n", it->first, it->second, it2->first, it2->second);
++it2;
}
else {
//printf("%i=>%i = %i=>%i, exclude\n", it->first, it->second, it2->first, it2->second);
++it;
++it2;
}
}
/*
printf("\nSet difference: ");
for(int i=0; i < a.size(); ++i)
printf("%i ", a[i]);
printf("\n");
*/
return counter;
};
|