X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.core%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fcore%2Ftypes%2FBitVector.java;h=aed0288d93b8efd0a660e3b9dc6b49248036ad1a;hb=153f81323a215691a0477af3fd1dd4a9d5b02958;hp=74375210549cc280f52ec497ece927a76835df90;hpb=4afd7c9afe4333815a488f90bdc3c3b9991028f4;p=Mograsim.git diff --git a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java index 74375210..aed0288d 100644 --- a/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java +++ b/net.mograsim.logic.core/src/net/mograsim/logic/core/types/BitVector.java @@ -2,6 +2,7 @@ package net.mograsim.logic.core.types; import static java.lang.String.format; +import java.math.BigInteger; import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; @@ -49,11 +50,26 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable, Iterable, Iterable op) @@ -196,21 +227,32 @@ public final class BitVector implements StrictLogicType, Iterablewith all bits set to null. Use with care! + * Returns a new mutator of the specified width, with all bits set to null. Use with care! */ - public static BitVectorMutator ofLength(int length) + public static BitVectorMutator ofWidth(int width) { - return new BitVectorMutator(new Bit[length]); + return new BitVectorMutator(new Bit[width]); } /** * Returns an empty mutator which has no bits set and will simply copy the values from the first binary operation performed. + *

+ * An empty BitVectorMutator must not be converted to BitVector or used to manipulate single bits until at least one two + * operand logic operation is performed. */ public static BitVectorMutator empty() { return new BitVectorMutator(null); } + /** + * @see #empty() + */ + public boolean isEmpty() + { + return bits == null; + } + /** * Produces the resulting, immutable {@link BitVector}
* @@ -267,6 +309,8 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable, Iterable, Iterable, Iterableoffset to the right.
- * Therefore offset + other.length() <= this.length() needs to be true. + * Therefore offset + other.width() <= this.wdith() needs to be true. * - * @throws ArrayIndexOutOfBoundsException if offset + other.length() > this.length() + * @throws ArrayIndexOutOfBoundsException if offset + other.width() > this.width() * * @see Object#equals(Object) */ @@ -343,7 +395,7 @@ public final class BitVector implements StrictLogicType, Iterable, Iterable, Iterable