mardi 29 novembre 2016

Iterator in permutation value order

I have a simple struct for permutation:

struct Permutation
{
   vector<string> items; // ["val_0", "val_1", "val_2", "val_3", "val_4"]
   vector<short> permutationValue;  // Let's say value is [4, 2, 0, 1, 3]
}

I want to be able to use it in range loop, like that

for(string item: permutation){
{ 
    cout << item << endl;
}

end expected output should be:

val_4
val_2
val_0
val_1
val_3

What methods should I implement in Permutation class to achive it?

Aucun commentaire:

Enregistrer un commentaire