jeudi 23 septembre 2021

Search inside vector of vectors

I have a 2D vector that i have to check if a ID already have been defined. The struct look like this

struct ExchangeStruct1 {
    std::vector<int16_t>id;
    std::vector< ObjectType_enum>type;

    std::vector<void*>source;
    std::vector<void*>destination;
    ExchangeStruct1();
};

The vector is defined as following

std::vector<std::vector<ExchangeStruct1>> exchangeList;

Is it possebile to search for the id in the second level of the vector. I tried using

it = std::find_if(exchangeList.begin(), exchangeList.end(), [key](const ExchangeStruct1>& o) -> bool {return o.id == key; });

But it only search in the first level

Aucun commentaire:

Enregistrer un commentaire