Hey y'all, your favorite and most prolific poster here just thinkin' out loud again. Feel free to chime in if y'all want.
Let's say say we conform to the ISO C standard and this snippet of code :
where num_threads is specified from command line arguments so not dynamically allocating it violates the standard.Code:vector<tree*> *leaves = new vector<tree*>[num_threads];
Let's also assume num_threads is greater than one.
What I want to do is scan each vector in leaves for duplicates. If any two vectors in the set have matching addresses, they both immediately go onto the "unsafe" pile and will no longer be subject for testing.
If a vector clears one vector, we test it against the others in the set.
So if we have 3 vectors, A, B and C we test A against B then A against C. For efficiency, we then then just test B against C.
Like I said, I want a "safe" and "unsafe" pile. Every vector in "safe" is fully unique while every vector in "unsafe" is not unique.
I thought about just using a for-loop to loop through leaves and then iterate through each element but I'm not sure if that'll work just right out of the box.