jeudi 31 mars 2016

How to address the next iterator in a loop and insert an element at a same address?

1) I have got an error while I tried to access next iterator of the inner loop by using next(). I was wondering where this error comes from. To be specific I have a vector of lists and I want to check connection feasibility with the next element, that's what feas[it2][(next(it2))] does.

2) After the if condition satisfies, I would like to insert an element, lets say 3, at the same address. If you could correct the insert function I will be so grateful.

To sum up, I want to know how can I have access to next element within the list?, and also how to insert a value at the same address?

Many thanks

vector<list<int>>temp;
for (const auto& it1 : temp)
{

    for (const auto& it2 : it1)
    {

        if (feas[it2][(next(it2))] == 1)
        {
            temp[it1].insert (it2,3);
        }

    }
}

Aucun commentaire:

Enregistrer un commentaire