vendredi 30 décembre 2016

Remove union large vectors in c++ efficiently?

I need to union a million vectors for doing so I am using the following program. Each of the vectors contain a billion elements. The result of the union should not contain any duplicates.

set<unsigned> myfunc()
{
    vector<unsigned> vec(1000000); 
    set<unsigned> result;
    for(int i=0; i<1000000; i++)
       result.insert(vec[i].begin(), vec[i].end(); //vec[i] contains a billion elements

    return result;
}

Is there some way by which I may union the two large vectors effectively? As the above code seems to be running

Aucun commentaire:

Enregistrer un commentaire