Mic*_*ael 2 c++ sorting operators
我希望这不是一个noob问题 - 尽管它是我在stackoverflow上的第一个问题;)
当使用实施例2层的载体partial_sort_copy,它给你"最小的" n个值,这取决于如何操作者<针对T(其中,n是所述目标矢量的大小)的类中定义的
是否有可能使用operator>而不定义额外的功能?
提前致谢 :)
您不必定义额外的功能; C++标准库已经有一个.
它被称为std::greater.
// Where 'T' is the type of object being sorted:
std::partial_sort(input.begin(), input.end(),
output.begin(), output.end(),
std::greater<T>());
Run Code Online (Sandbox Code Playgroud)