部分类型的std :: list [英] Partial sort of std::list
问题描述
我有一个链接列表,我想排序的部分,例如:
I have a linked list that I want to sort part of, eg:
std::sort(someIterator, otherIterator, predicate);
std :: sort需要随机访问迭代器,因此这种方法不起作用。有一个专门的std :: list :: sort,但是只能排序整个列表。我不认为我有足够的访问列表成员自己写的东西。
std::sort requires random-access iterators so this approach doesn't work. There is a specialisation std::list::sort, but that can only sort the entire list. I don't think I have enough access to the list members to write something myself.
有没有办法做到这一点,而不改变,说,矢量? p>
Is there a way to do this without changing to, say, vector?
推荐答案
如何将要排序的列表中的部分挂钩到一个独立的列表中,
然后使用专用列表排序,然后将其重新回到原始列表中?
How about unhooking the part of the list that you want sorted, into a standalone list, then use the specialized list sort, then hook it back into the original list?
这篇关于部分类型的std :: list的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!