0
What is the most efficient c/c++ structure that I can use to create and store cycles, so that I can ensure that repeated cycles are not stored?
I have a CICLO struct, such that:
struct CICLO {
vector<Arco> rota;
float COST;
}
struct Arco {
int i, j;
Arco () {};
Arco (const Arco& obj): i(obj.i), j(obj.j) {};
Arco(int _i, int _j) : i(_i), j(_j) {}
};
I thought I’d have a cycle vector to store all the cycles ever cracked.
vector<CICLO> ConjCiclos;
For each new cycle created, I need to check that it is no longer stored in Conjciclos.
O ciclo 1-2-2-1 é o mesmo que o ciclo 2-2-1-2.
How can I detect it efficiently?
I thought using a map would be a good option. However, what key lófica can I create, so that the above cycles have the same key?
But how could I compose a key in that case? You have any suggestions?
– rbl
What parameters do you set as a key for searching?
– lsalamon
I am in need of help precisely to define this key. Given two equal cycles, more created differently, for example 1-2-3-4-1 and 2-3-4-1-2. How can I set the key to the cycles, so that these cycles have the same key and I can detect redundancy?
– rbl
You can use this sequence of numbers to assemble a single number, concatenating them, so they will be unique to each Cycle. If these sequences are larger, not fitting in a LONG, for example, pass them to a Std:string buffer, placing each one in a position. Since Std:string is a class you can adjust each one to have the required size and not worry about memory release.
– lsalamon