mercredi 1 avril 2020

Loop doesn't go further than 999

I'm working on code that reads data from some CSV file and put it into a vector<vector<string> > then I want to search the data for matching fields with my query.

    vector<vector<string> > data = cleanData(classifier);
    cout << data.size()<< endl; //output is 16615
    // processing
    for (long long i=0; i<v.size(); i++){
        vector<vector<string> > res;
        int index = getIndex(k[i]);
        for(long long j=0; j<data.size(); j++){
            vector<string> row = data[j];
            if(row[index] == v[i]){
                res.push_back(data[j]);
            }
        }
        data.swap(res);
        cout << data.size();
    }

Somehow when printing j it doesn't go more than 999 although my size is bigger than that and there is no error after that but the code won't get to the partdata.swap(res); cout << data.size();

I'm not sure what I'm missing, changing iterator from int to long long didn't work either.

It's almost like there is stack overflow.

How can I fix this?

Aucun commentaire:

Enregistrer un commentaire