Here are the timing results for this method #1 of count_intersection:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
int two_counter {0};
for (size_t b = layer_rep_start; b < d5.size(); ++b, ++two_counter)
if (count_intersection(d5[a].begin(), d5[a].end(), d5[b].begin(), d5[b].end()) >= 2 )
break;
int three_counter {0};
for (size_t b = layer_rep_start; b < d5.size(); ++b, ++three_counter)
if (count_intersection(d5[a].begin(), d5[a].end(), d5[b].begin(), d5[b].end()) >= 3)
break;
int four_counter {0};
for (size_t b = layer_rep_start; b < d5.size(); ++b, ++four_counter)
if (count_intersection(d5[a].begin(), d5[a].end(), d5[b].begin(), d5[b].end()) >= 4 )
break;
|
I ran the code (to print 100 lines of output) 5 times. Here are the chrono times in microseconds:
314895
318968
314709
319853
324660
After looking at a post above (6 up from here) these timings are about 5/100ths of a second slower. That's not a big deal for my purposes. I like the layout better with it this way. It's easier for me to follow (reading wise).
Here was another method #2 that I timed using chrono:
1 2 3 4 5 6 7
|
int cnt[3]{}, i = 2;
for (size_t b = a + 1; b < d5.size(); ++b, ++cnt[i])
if (count_intersection(d5[a].begin(), d5[a].end(), d5[b].begin(), d5[b].end()) >= i + 2)
if (--i < 0) break;
cnt[1] += cnt[2]; // >= 3 includes >= 4
cnt[0] += cnt[1]; // >= 2 includes >= 3
std::cout << a + 1 << '\t' << cnt[0] << '\t' << cnt[1] << '\t' << cnt[2] << '\n';
|
There was a problem with the accuracy of the output. It was very strange indeed. The only counter that was correct was cnt[2]. Now, cnt[2] (>=4), should have the highest count of the three. But, cnt[1] was higher than cnt[2], and cnt[0] was higher than cnt[1]. The weird part is, cnt[2] values were correct!!! The timings using chrono were very similar, only about 2/100ths of a second slower than method #1 timings mentioned above(in this post).
I'm very satisfied using the count_intersection method #1. I'm going to consider this thread SOLVED!!!!
MANY MANY THANKS to dutch and keskiverto for educating me on a bunch of things, and for taking the time, and showing patience. I definetly have A LOT to learn yet!! Thanks guys!!