heap

converting/constructing vector of tuples into heap

白昼怎懂夜的黑 提交于 2020-07-07 10:33:58
问题 - Construction i constructed a vector of tuples vector<tuple<int,int,int>> x . For sake of simplicity, lets assume it is constructed it this way. vector<tuple<int,int,int>> x; for (int ii=0; ii < 10; ii++){ for (int jj=0; jj < 10; jj++){ currpeak[0] = ii + rand() % 10; currpeak[1] = jj + rand() % 10; currpeak[2] = rand() % 100; x.emplace_back(currpeak[0], currpeak[1], currpeak[2]); } } Now i want to get the n largest tuples, according to the 3rd element, and append them to another variable

converting/constructing vector of tuples into heap

别来无恙 提交于 2020-07-07 10:33:06
问题 - Construction i constructed a vector of tuples vector<tuple<int,int,int>> x . For sake of simplicity, lets assume it is constructed it this way. vector<tuple<int,int,int>> x; for (int ii=0; ii < 10; ii++){ for (int jj=0; jj < 10; jj++){ currpeak[0] = ii + rand() % 10; currpeak[1] = jj + rand() % 10; currpeak[2] = rand() % 100; x.emplace_back(currpeak[0], currpeak[1], currpeak[2]); } } Now i want to get the n largest tuples, according to the 3rd element, and append them to another variable