public void copy(FlowSet<T> destFlow) { if (sameType(destFlow)) { ArrayPackedSet<T> dest = (ArrayPackedSet<T>) destFlow; for (int i = 0; i < bits.length; i++) dest.bits[i] = this.bits[i]; } else super.copy(destFlow); }
public void union(FlowSet<T> otherFlow, FlowSet<T> destFlow) { if (sameType(otherFlow) && sameType(destFlow)) { ArrayPackedSet<T> other = (ArrayPackedSet<T>) otherFlow; ArrayPackedSet<T> dest = (ArrayPackedSet<T>) destFlow; if (!(other instanceof ArrayPackedSet) || bits.length != other.bits.length) throw new RuntimeException("Incompatible other set for union"); for (int i = 0; i < bits.length; i++) dest.bits[i] = this.bits[i] | other.bits[i]; } else super.union(otherFlow, destFlow); }
public void complement(FlowSet<T> destFlow) { if (sameType(destFlow)) { ArrayPackedSet<T> dest = (ArrayPackedSet<T>) destFlow; for (int i = 0; i < bits.length; i++) dest.bits[i] = ~(this.bits[i]); // Clear the bits which are outside of this universe if (bits.length >= 1) { int lastValidBitCount = map.size() % 32; if (lastValidBitCount != 0) dest.bits[bits.length - 1] &= ~(0xFFFFFFFF << lastValidBitCount); } } else super.complement(destFlow); }