MCPcopy Create free account
hub / github.com/LFYSec/MScan / and

Method and

src/main/java/pascal/taie/util/collection/SparseBitSet.java:588–673  ·  view source on GitHub ↗

Performs a logical AND of this target bit set with the argument bit set. This operation cannot skip zero blocks in the other set, thus we cannot implement it via #iterateBlocks. @param set a bit set @return true if this bit set changed as a result of the call

(IBitSet set)

Source from the content-addressed store, hash-verified

586 * @return {@code true} if this bit set changed as a result of the call
587 */
588 @Override
589 public boolean and(IBitSet set) {
590 if (this == set) {
591 return false;
592 }
593 if (!(set instanceof SparseBitSet other)) {
594 throw new UnsupportedOperationException(
595 String.format("%s does not support AND with %s",
596 this.getClass(), set.getClass()));
597 }
598 // Unlike other set operations, AND requires iteration on
599 // non-null blocks of both this and other sets.
600 boolean changed = false;
601 long[][][] thisTable = this.table;
602 long[][][] otherTable = other.table;
603 int w1InCommon = Math.min(thisTable.length, otherTable.length);
604 // process common part
605 for (int w1 = 0; w1 < w1InCommon; ++w1) {
606 long[][] otherArea = otherTable[w1];
607 long[][] thisArea = thisTable[w1];
608 if (otherArea != null) {
609 if (thisArea != null) {
610 // both areas are present
611 boolean isZeroArea = true;
612 for (int w2 = 0; w2 < LENGTH2; ++w2) {
613 long[] thisBlock = thisArea[w2];
614 long[] otherBlock = otherArea[w2];
615 if (otherBlock != null) {
616 if (thisBlock != null) {
617 // both blocks are present
618 boolean isZeroBlock = true;
619 // perform AND on each words
620 for (int w3 = 0; w3 < LENGTH3; ++w3) {
621 long oldWord = thisBlock[w3];
622 long newWord = oldWord & otherBlock[w3];
623 if (oldWord != newWord) {
624 thisBlock[w3] = newWord;
625 changed = true;
626 }
627 if (newWord != 0) {
628 isZeroBlock = false;
629 }
630 }
631 if (isZeroBlock) {
632 thisArea[w2] = null;
633 } else {
634 isZeroArea = false;
635 }
636 }
637 } else if (isNonZeroBlock(thisBlock)) {
638 // otherBlock is null and thisBlock is not zero,
639 // then clear thisBlock and mark changed
640 thisArea[w2] = null;
641 changed = true;
642 }
643 }
644 if (isZeroArea) {
645 // iterate all thisBlocks and found they are all zero,

Callers

nothing calls this directly

Calls 7

isNonZeroBlockMethod · 0.95
isNonZeroAreaMethod · 0.95
clearTableMethod · 0.95
invalidateStateMethod · 0.95
formatMethod · 0.80
getClassMethod · 0.65
minMethod · 0.45

Tested by

no test coverage detected