this.bits = new boolean[length];
}
+ /** copy constructor */
+ public BitVector(BitVector bv) {
+ this(bv.length());
+ for(int i=0; i<bv.length(); i++)
+ set(i, bv.get(i));
+ }
+
/** copy the low-order bits of the argument into this BitVector; returns <tt>this</tt> */
public BitVector set(long value) {
if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector");
return this;
}
+ /** copy the low-order bits of the argument into this BitVector and sign extend; returns <tt>this</tt> */
+ public BitVector setAndSignExtend(long value) {
+ if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector");
+ for(int i=0; i<Math.min(length(), 64); i++)
+ set(i, ((value >>> i) & 1L) != 0);
+ if (value < 0)
+ for(int i=64; i<length(); i++)
+ set(i, true);
+ return this;
+ }
+
public int length() {
return bits.length;
}