I\'ve got this function:
template void Inventory::insertItem(std::vector& v, const T& x) { std::vector<
2条回答 时光说笑 (楼主) 2021-02-18 23:38 What you are doing is inefficient. Use a binary search instead: #include template void insertItem(std::vector& v, const T& x) { v.insert(std::upper_bound(v.begin(), v.end(), x), x); } 0 讨论(0) 查看其它2个回答 发布评论: 提交评论 加载中... 自定义标题段落格式字体字号代码语言点击上传x 验证码 看不清? 提交回复
What you are doing is inefficient. Use a binary search instead:
#include template void insertItem(std::vector& v, const T& x) { v.insert(std::upper_bound(v.begin(), v.end(), x), x); }
热议问题