MCPcopy Create free account
hub / github.com/SVF-tools/SVF / intersectWithComplement

Method intersectWithComplement

svf/include/Util/SparseBitVector.h:943–999  ·  view source on GitHub ↗

Intersect our bitmap with the complement of the RHS and return true if ours changed.

Source from the content-addressed store, hash-verified

941 // Intersect our bitmap with the complement of the RHS and return true
942 // if ours changed.
943 bool intersectWithComplement(const SparseBitVector &RHS)
944 {
945 if (this == &RHS)
946 {
947 if (!empty())
948 {
949 clear();
950 return true;
951 }
952 return false;
953 }
954
955 bool changed = false;
956 ElementListIter Iter1 = Elements.begin();
957 ElementListConstIter Iter2 = RHS.Elements.begin();
958
959 // If either our bitmap or RHS is empty, we are done
960 if (Elements.empty() || RHS.Elements.empty())
961 return false;
962
963 // Loop through, intersecting as we go, erasing elements when necessary.
964 while (Iter2 != RHS.Elements.end())
965 {
966 if (Iter1 == Elements.end())
967 {
968 CurrElementIter = Elements.begin();
969 return changed;
970 }
971
972 if (Iter1->index() > Iter2->index())
973 {
974 ++Iter2;
975 }
976 else if (Iter1->index() == Iter2->index())
977 {
978 bool BecameZero;
979 changed |= Iter1->intersectWithComplement(*Iter2, BecameZero);
980 if (BecameZero)
981 {
982 ElementListIter IterTmp = Iter1;
983 ++Iter1;
984 Elements.erase(IterTmp);
985 }
986 else
987 {
988 ++Iter1;
989 }
990 ++Iter2;
991 }
992 else
993 {
994 ++Iter1;
995 }
996 }
997 CurrElementIter = Elements.begin();
998 return changed;
999 }
1000

Callers 2

removeCandidatesMethod · 0.45
operator-Function · 0.45

Calls 6

indexMethod · 0.80
beginMethod · 0.45
emptyMethod · 0.45
endMethod · 0.45
clearMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected