性能优化

来源:互联网 发布:商业系统域名 编辑:程序博客网 时间:2024/05/31 11:04
struct Item {  ......  int calcWight();}bool comp(Item a, Item b){    return a.calcWeight() < b.calcWeight();}std::stable_sort(items.begin(), items.end(), comp);


struct Score{      int score;      int idx;}int n = items.size();for (int i = 0; i < n; ++i){    scores[i].score = items[i].calcWeight();    scores.idx = i;}bool comp(Score a, Score b){    return a.score < b.score;}stable_sort(scores, scores + n, comp);......     


0 0
原创粉丝点击