MCPcopy Create free account
hub / github.com/MyGUI/mygui / sort

Function sort

Tools/EditorFramework/pugixml.cpp:6278–6307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6276
6277template<typename I, typename Pred>
6278void sort(I begin, I end, const Pred& pred)
6279{
6280 // sort large chunks
6281 while (end - begin > 32)
6282 {
6283 // find median element
6284 I middle = begin + (end - begin) / 2;
6285 median(begin, middle, end - 1, pred);
6286
6287 // partition in three chunks (< = >)
6288 I eqbeg, eqend;
6289 partition(begin, middle, end, pred, &eqbeg, &eqend);
6290
6291 // loop on larger half
6292 if (eqbeg - begin > end - eqend)
6293 {
6294 sort(eqend, end, pred);
6295 end = eqbeg;
6296 }
6297 else
6298 {
6299 sort(begin, eqbeg, pred);
6300 begin = eqend;
6301 }
6302 }
6303
6304 // insertion sort small chunk
6305 if (begin != end)
6306 insertion_sort(begin, end, pred, &*begin);
6307}
6308PUGI__NS_END
6309
6310// Allocator used for AST and evaluation stacks

Callers 3

updateFromColourMethod · 0.70
type_t xpath_sortMethod · 0.70
remove_duplicatesMethod · 0.70

Calls 3

medianFunction · 0.70
partitionFunction · 0.70
insertion_sortFunction · 0.70

Tested by

no test coverage detected