MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / findCommonInLeaf

Method findCommonInLeaf

highs/util/HighsHashTree.h:508–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506
507 template <int SizeClass1, int SizeClass2>
508 static HighsHashTableEntry<K, V>* findCommonInLeaf(
509 InnerLeaf<SizeClass1>* leaf1, InnerLeaf<SizeClass2>* leaf2, int hashPos) {
510 uint64_t matchMask = leaf1->occupation & leaf2->occupation;
511 if (matchMask == 0) return nullptr;
512
513 int offset1 = -1;
514 int offset2 = -1;
515 while (matchMask) {
516 int pos = HighsHashHelpers::log2i(matchMask);
517 matchMask ^= (uint64_t{1} << pos);
518
519 int i =
520 leaf1->occupation.num_set_until(static_cast<uint8_t>(pos)) + offset1;
521 while (get_first_chunk16(leaf1->hashes[i]) != pos) {
522 ++i;
523 ++offset1;
524 }
525
526 int j =
527 leaf2->occupation.num_set_until(static_cast<uint8_t>(pos)) + offset2;
528 while (get_first_chunk16(leaf2->hashes[j]) != pos) {
529 ++j;
530 ++offset2;
531 }
532
533 while (true) {
534 if (leaf1->hashes[i] > leaf2->hashes[j]) {
535 ++i;
536 if (i == leaf1->size || get_first_chunk16(leaf1->hashes[i]) != pos)
537 break;
538 } else if (leaf2->hashes[j] > leaf1->hashes[i]) {
539 ++j;
540 if (j == leaf2->size || get_first_chunk16(leaf2->hashes[j]) != pos)
541 break;
542 } else {
543 if (leaf1->entries[i].key() == leaf2->entries[j].key())
544 return &leaf1->entries[i];
545
546 ++i;
547 if (i == leaf1->size || get_first_chunk16(leaf1->hashes[i]) != pos)
548 break;
549 ++j;
550 if (j == leaf2->size || get_first_chunk16(leaf2->hashes[j]) != pos)
551 break;
552 }
553 };
554 }
555
556 return nullptr;
557 }
558
559 template <int SizeClass>
560 static HighsHashTableEntry<K, V>* findCommonInLeaf(InnerLeaf<SizeClass>* leaf,

Callers

nothing calls this directly

Calls 7

num_set_untilMethod · 0.80
getTypeMethod · 0.80
getBranchNodeMethod · 0.80

Tested by

no test coverage detected