MCPcopy Create free account
hub / github.com/WheretIB/nullc / sort

Function sort

external/pugixml/pugixml.cpp:5003–5031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5001 }
5002
5003 template <typename I, typename Pred> void sort(I begin, I end, const Pred& pred)
5004 {
5005 // sort large chunks
5006 while (end - begin > 32)
5007 {
5008 // find median element
5009 I middle = begin + (end - begin) / 2;
5010 median(begin, middle, end - 1, pred);
5011
5012 // partition in three chunks (< = >)
5013 I eqbeg, eqend;
5014 partition(begin, middle, end, pred, &eqbeg, &eqend);
5015
5016 // loop on larger half
5017 if (eqbeg - begin > end - eqend)
5018 {
5019 sort(eqend, end, pred);
5020 end = eqbeg;
5021 }
5022 else
5023 {
5024 sort(begin, eqbeg, pred);
5025 begin = eqend;
5026 }
5027 }
5028
5029 // insertion sort small chunk
5030 if (begin != end) insertion_sort(begin, end, pred, &*begin);
5031 }
5032}
5033
5034// Allocator used for AST and evaluation stacks

Callers 3

TestInference.cppFile · 0.85
xpath_sortFunction · 0.85
remove_duplicatesMethod · 0.85

Calls 3

medianFunction · 0.85
partitionFunction · 0.85
insertion_sortFunction · 0.85

Tested by

no test coverage detected