提交 ea2fc4cc 编写于 作者: Y Yu Yang 提交者: QI JUN

Use stable_sort in lod_rank_table (#5378)

It is easy to debug and test when use `stable_sort`and the time
complexity is not changed.
上级 51d4afaa
......@@ -33,10 +33,15 @@ void LoDRankTable::Reset(const LoD& lod, size_t level) {
item.length = vec[i + 1] - vec[i];
items_.emplace_back(item);
}
std::sort(items_.begin(), items_.end(),
[](const TableItem& a, const TableItem& b) {
return a.length > b.length;
});
// NOTE(yuyang18):
//
// The time complexity of stable_sort is O(N*log(N)) if additional memory is
// available. It is easy to debug and unit test when using `stable_sort`
// instead of `sort`. Also, the items of a rank table will not be too large.
std::stable_sort(items_.begin(), items_.end(),
[](const TableItem& a, const TableItem& b) {
return a.length > b.length;
});
}
} // namespace framework
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册