MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPathNodeSetSort

Function xmlXPathNodeSetSort

ThirdParty/libxml2/vtklibxml2/xpath.c:2648–2688  ·  view source on GitHub ↗

* xmlXPathNodeSetSort: * @set: the node set * * Sort the node set in document order */

Source from the content-addressed store, hash-verified

2646 * Sort the node set in document order
2647 */
2648void
2649xmlXPathNodeSetSort(xmlNodeSetPtr set) {
2650#ifndef WITH_TIM_SORT
2651 int i, j, incr, len;
2652 xmlNodePtr tmp;
2653#endif
2654
2655 if (set == NULL)
2656 return;
2657
2658#ifndef WITH_TIM_SORT
2659 /*
2660 * Use the old Shell's sort implementation to sort the node-set
2661 * Timsort ought to be quite faster
2662 */
2663 len = set->nodeNr;
2664 for (incr = len / 2; incr > 0; incr /= 2) {
2665 for (i = incr; i < len; i++) {
2666 j = i - incr;
2667 while (j >= 0) {
2668#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
2669 if (xmlXPathCmpNodesExt(set->nodeTab[j],
2670 set->nodeTab[j + incr]) == -1)
2671#else
2672 if (xmlXPathCmpNodes(set->nodeTab[j],
2673 set->nodeTab[j + incr]) == -1)
2674#endif
2675 {
2676 tmp = set->nodeTab[j];
2677 set->nodeTab[j] = set->nodeTab[j + incr];
2678 set->nodeTab[j + incr] = tmp;
2679 j -= incr;
2680 } else
2681 break;
2682 }
2683 }
2684 }
2685#else /* WITH_TIM_SORT */
2686 libxml_domnode_tim_sort(set->nodeTab, set->nodeNr);
2687#endif /* WITH_TIM_SORT */
2688}
2689
2690#define XML_NODESET_DEFAULT 10
2691/**

Callers 10

xmlXPathDistinctFunction · 0.85
xmlXPathNodeLeadingFunction · 0.85
xmlXPathLeadingFunction · 0.85
xmlXPathNodeTrailingFunction · 0.85
xmlXPathTrailingFunction · 0.85
xmlXPathCompOpEvalFirstFunction · 0.85
xmlXPathCompOpEvalLastFunction · 0.85
xmlXPathCompOpEvalFunction · 0.85

Calls 2

xmlXPathCmpNodesExtFunction · 0.85
xmlXPathCmpNodesFunction · 0.85

Tested by

no test coverage detected