Class BitVector

java.lang.Object
com.itextpdf.barcodes.qrcode.BitVector

final class BitVector extends Object
JAVAPORT: This should be combined with BitArray in the future, although that class is not yet dynamically resizeable. This implementation is reasonable but there is a lot of function calling in loops I'd like to get rid of.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
     
    private static final int
     
    private int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a bitvector usng the default size
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendBit(int bit)
    Append the a bit to the bit vector
    void
    appendBits(int value, int numBits)
    Append "numBits" bits in "value" to the bit vector.
    void
    Append a different BitVector to this BitVector
    private void
    appendByte(int value)
    Add a new byte to the end, possibly reallocating and doubling the size of the array if we've run out of room.
    int
    at(int index)
    Return the bit value at "index".
    byte[]
    Callers should not assume that array.length is the exact number of bytes needed to hold sizeInBits - it will typically be larger for efficiency.
    int
     
    int
     
     
    void
    xor(BitVector other)
    XOR the contents of this bitvector with the contetns of "other"

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • sizeInBits

      private int sizeInBits
    • array

      private byte[] array
    • DEFAULT_SIZE_IN_BYTES

      private static final int DEFAULT_SIZE_IN_BYTES
      See Also:
  • Constructor Details

    • BitVector

      public BitVector()
      Create a bitvector usng the default size
  • Method Details

    • at

      public int at(int index)
      Return the bit value at "index".
      Parameters:
      index - index in the vector
      Returns:
      bit value at "index"
    • size

      public int size()
      Returns:
      the number of bits in the bit vector.
    • sizeInBytes

      public int sizeInBytes()
      Returns:
      the number of bytes in the bit vector.
    • appendBit

      public void appendBit(int bit)
      Append the a bit to the bit vector
      Parameters:
      bit - 0 or 1
    • appendBits

      public void appendBits(int value, int numBits)
      Append "numBits" bits in "value" to the bit vector. Examples: - appendBits(0x00, 1) adds 0. - appendBits(0x00, 4) adds 0000. - appendBits(0xff, 8) adds 11111111.
      Parameters:
      value - int interpreted as bitvector
      numBits - 0 <= numBits <= 32.
    • appendBitVector

      public void appendBitVector(BitVector bits)
      Append a different BitVector to this BitVector
      Parameters:
      bits - BitVector to append
    • xor

      public void xor(BitVector other)
      XOR the contents of this bitvector with the contetns of "other"
      Parameters:
      other - Bitvector of equal length
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String representation of the bitvector
    • getArray

      public byte[] getArray()
      Callers should not assume that array.length is the exact number of bytes needed to hold sizeInBits - it will typically be larger for efficiency.
      Returns:
      size of the array containing the bitvector
    • appendByte

      private void appendByte(int value)
      Add a new byte to the end, possibly reallocating and doubling the size of the array if we've run out of room.
      Parameters:
      value - byte to add.