From 7e4425b77531e0e7d97cc3fb464d3c80a87a1645 Mon Sep 17 00:00:00 2001 From: adam Date: Thu, 26 Jun 2008 11:32:14 +0100 Subject: [PATCH] add BitVector copy constructor and BitVector.setAndSignExtend() --- src/edu/berkeley/fleet/api/BitVector.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/edu/berkeley/fleet/api/BitVector.java b/src/edu/berkeley/fleet/api/BitVector.java index c883b3b..9282200 100644 --- a/src/edu/berkeley/fleet/api/BitVector.java +++ b/src/edu/berkeley/fleet/api/BitVector.java @@ -15,6 +15,13 @@ public class BitVector { this.bits = new boolean[length]; } + /** copy constructor */ + public BitVector(BitVector bv) { + this(bv.length()); + for(int i=0; ithis */ public BitVector set(long value) { if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector"); @@ -23,6 +30,17 @@ public class BitVector { return this; } + /** copy the low-order bits of the argument into this BitVector and sign extend; returns this */ + public BitVector setAndSignExtend(long value) { + if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector"); + for(int i=0; i>> i) & 1L) != 0); + if (value < 0) + for(int i=64; i