void AssFile::Sort(EntryList<AssDialogue> &lst, CompFunc comp, std::set<AssDialogue*> const& limit) { if (limit.empty()) { lst.sort(comp); return; } // Sort each selected block separately, leaving everything else untouched for (auto begin = lst.begin(); begin != lst.end(); ++begin) { if (!limit.count(&*begin)) continue; auto end = begin; while (end != lst.end() && limit.count(&*end)) ++end; // sort doesn't support only sorting a sublist, so move them to a temp list EntryList<AssDialogue> tmp; tmp.splice(tmp.begin(), lst, begin, end); tmp.sort(comp); lst.splice(end, tmp); begin = --end; } }
void AssFile::Sort(EntryList &lst, CompFunc comp, std::set<AssDialogue*> const& limit) { AssEntryComp compE; compE.comp = comp; // Sort each block of AssDialogues separately, leaving everything else untouched for (entryIter begin = lst.begin(); begin != lst.end(); ++begin) { if (!is_dialogue(&*begin, limit)) continue; entryIter end = begin; while (end != lst.end() && is_dialogue(&*end, limit)) ++end; // used instead of std::list::sort for partial list sorting EntryList tmp; tmp.splice(tmp.begin(), lst, begin, end); tmp.sort(compE); lst.splice(end, tmp); begin = --end; } }