MCPcopy Create free account
hub / github.com/KDE/kdevelop / computeSetFromNodes

Method computeSetFromNodes

kdevplatform/language/util/setrepository.cpp:554–593  ·  view source on GitHub ↗

Constructs a set node from the given two sub-nodes. Those must be valid, they must not intersect, and they must have a correct split-hierarchy. The do not need to be split around their computed split-position.

Source from the content-addressed store, hash-verified

552//Constructs a set node from the given two sub-nodes. Those must be valid, they must not intersect, and they must have a correct split-hierarchy.
553//The do not need to be split around their computed split-position.
554uint SetRepositoryAlgorithms::computeSetFromNodes(uint leftNode, uint rightNode, const SetNodeData* left,
555 const SetNodeData* right, uchar splitBit)
556{
557 Q_ASSERT(left->end() <= right->start());
558 uint splitPosition = splitPositionForRange(left->start(), right->end(), splitBit);
559
560 Q_ASSERT(splitPosition);
561
562 if (splitPosition < left->end()) {
563 //The split-position intersects the left node
564 uint leftLeftNode = left->leftNode();
565 uint leftRightNode = left->rightNode();
566
567 const SetNodeData* leftLeft = this->getLeftNode(left);
568 const SetNodeData* leftRight = this->getRightNode(left);
569
570 Q_ASSERT(splitPosition >= leftLeft->end() && splitPosition <= leftRight->start());
571
572 //Create a new set from leftLeft, and from leftRight + right. That set will have the correct split-position.
573 uint newRightNode = computeSetFromNodes(leftRightNode, rightNode, leftRight, right, splitBit);
574
575 return createSetFromNodes(leftLeftNode, newRightNode, leftLeft);
576 } else if (splitPosition > right->start()) {
577 //The split-position intersects the right node
578 uint rightLeftNode = right->leftNode();
579 uint rightRightNode = right->rightNode();
580
581 const SetNodeData* rightLeft = this->getLeftNode(right);
582 const SetNodeData* rightRight = this->getRightNode(right);
583
584 Q_ASSERT(splitPosition >= rightLeft->end() && splitPosition <= rightRight->start());
585
586 //Create a new set from left + rightLeft, and from rightRight. That set will have the correct split-position.
587 uint newLeftNode = computeSetFromNodes(leftNode, rightLeftNode, left, rightLeft, splitBit);
588
589 return createSetFromNodes(newLeftNode, rightRightNode, nullptr, rightRight);
590 } else {
591 return createSetFromNodes(leftNode, rightNode, left, right);
592 }
593}
594
595uint SetRepositoryAlgorithms::set_union(uint firstNode, uint secondNode, const SetNodeData* first,
596 const SetNodeData* second, uchar splitBit)

Callers

nothing calls this directly

Calls 3

splitPositionForRangeFunction · 0.85
endMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected