K
koperenkogel
Dear cpp-ians,
I am working with a vector of structures.
vector <meta_segment> meta_segm (2421500);
and the structure look like:
struct meta_segment
{
float id;
float num;
float mean;
float sum;
float sumofsquares;
float std;
struct pixel * head;
struct pixel * tail;
struct pixel * edge_head;
struct pixel * edge_tail;
struct segment * segment;
bool full;
};
I run a procedure that:
1. takes a random element of the vector
2. runs a function on the element
3. removes the element from the list with the 'meta_segm.erase'.
and repeats this procedure untill the vector is empty
The problem I have is in the function of step 2. This function uses the
random element (A) (out of step 1) and searches for a second element
(B) based on different criteria. So my function runs actually for two
elements (A and B), instead of only one (A).
Now, I want to translate this in step 3 and remove A and B from the
vector.
I know how to remove A, but I have no idea how to remove B. B is not
necessarly A's neighbour. I thought of searching for it (based on the
same criteria I use to detect it), but I that takes to much time since
I will have to do it for every element then.
Any advice on how to program this kind of problem is welcome.
Thanks in advance and kind regards,
Stef
I am working with a vector of structures.
vector <meta_segment> meta_segm (2421500);
and the structure look like:
struct meta_segment
{
float id;
float num;
float mean;
float sum;
float sumofsquares;
float std;
struct pixel * head;
struct pixel * tail;
struct pixel * edge_head;
struct pixel * edge_tail;
struct segment * segment;
bool full;
};
I run a procedure that:
1. takes a random element of the vector
2. runs a function on the element
3. removes the element from the list with the 'meta_segm.erase'.
and repeats this procedure untill the vector is empty
The problem I have is in the function of step 2. This function uses the
random element (A) (out of step 1) and searches for a second element
(B) based on different criteria. So my function runs actually for two
elements (A and B), instead of only one (A).
Now, I want to translate this in step 3 and remove A and B from the
vector.
I know how to remove A, but I have no idea how to remove B. B is not
necessarly A's neighbour. I thought of searching for it (based on the
same criteria I use to detect it), but I that takes to much time since
I will have to do it for every element then.
Any advice on how to program this kind of problem is welcome.
Thanks in advance and kind regards,
Stef