
please wait
|
|
|
|
keskiverto Wrote: The code of count_intersection exists only in my comment. You have to copy it from there. |
dutch Wrote: Yeah, keskiverto wrote the count_intersection code as a modification (optimization for your purpose) of the set_intersection code, so you need to copy that code as a function in your program. |
|
|
This seems a little confusing to me. |
|
|
a
, line_number
, and layer_rep_start
are basically the same, so I just used a
.int cnt[3] {}
is an array of 3 ints to hold the counts.cnt[0]
will hold the 2 count, cnt[1]
the 3 count, cnt[2]
the 4 count.i
, starting at 2 and going down to 0.i
hits -1 the inner for loop will break.i + 2
gives the count that index i
represents.int cnt[3] {} is an array of 3 ints to hold the counts. It is initialized to all zeroes by the empty braces. cnt[0] will hold the 2 count, cnt[1] the 3 count, cnt[2] the 4 count. It is indexed with i, starting at 2 and going down to 0. When i hits -1 the inner for loop will break. i + 2 gives the count that index i represents. |
The idea is that counting the 2's, 3's, and 4's separately is duplicating much of the work. The >=4's are also >=3's and >=2's. The >=3's are also >=2's. If you see what I mean. |
|
|
|
|