adds single bit display of bitvectors
This commit is contained in:
1 parent
0f662e427e
commit
a4215fceb1
13 files changed
+441
-17
No files matched your search
+7
-1
@@ -93,7 +93,7 @@ public class BitVector implements IEvent {
|
||||
// Copy values out of packed array
|
||||
for (int i = 0; i < width; i++) {
|
||||
int currentWord = (packedValues[wordOffset] >> bitOffset) & 3;
|
||||
res[width - i - 1] = BitValue.fromInt(currentWord).toChar();
|
||||
res[width - i - 1] = BitValue.fromOrdinal(currentWord).toChar();
|
||||
bitOffset += 2;
|
||||
if (bitOffset == 32) {
|
||||
wordOffset++;
|
||||
@@ -103,6 +103,12 @@ public class BitVector implements IEvent {
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Read a bit by its zero-based position, with bit 0 the least significant bit. */
|
||||
public BitValue getValue(int index) {
|
||||
if (index < 0 || index >= width) throw new IndexOutOfBoundsException(index);
|
||||
return BitValue.fromOrdinal((packedValues[index / 16] >>> ((index % 16) * 2)) & 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user