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

Function xmlParserFindNodeInfoIndex

ThirdParty/libxml2/vtklibxml2/parserInternals.c:2695–2724  ·  view source on GitHub ↗

* xmlParserFindNodeInfoIndex: * @seq: a node info sequence pointer * @node: an XML node pointer * * DEPRECATED: Don't use. * * xmlParserFindNodeInfoIndex : Find the index that the info record for * the given node is or should be at in a sorted sequence * * Returns a long indicating the position of the record */

Source from the content-addressed store, hash-verified

2693 * Returns a long indicating the position of the record
2694 */
2695unsigned long
2696xmlParserFindNodeInfoIndex(xmlParserNodeInfoSeqPtr seq,
2697 xmlNodePtr node)
2698{
2699 unsigned long upper, lower, middle;
2700 int found = 0;
2701
2702 if ((seq == NULL) || (node == NULL))
2703 return ((unsigned long) -1);
2704
2705 /* Do a binary search for the key */
2706 lower = 1;
2707 upper = seq->length;
2708 middle = 0;
2709 while (lower <= upper && !found) {
2710 middle = lower + (upper - lower) / 2;
2711 if (node == seq->buffer[middle - 1].node)
2712 found = 1;
2713 else if (node < seq->buffer[middle - 1].node)
2714 upper = middle - 1;
2715 else
2716 lower = middle + 1;
2717 }
2718
2719 /* Return position */
2720 if (middle == 0 || seq->buffer[middle - 1].node < node)
2721 return middle;
2722 else
2723 return middle - 1;
2724}
2725
2726
2727/**

Callers 2

xmlParserFindNodeInfoFunction · 0.85
xmlParserAddNodeInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected