Class BitArray

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

final class BitArray extends Object
A simple, fast array of bits, represented compactly by an array of ints internally.
  • Field Summary

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

    Constructors
    Constructor
    Description
    BitArray(int size)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all bits (sets to false).
    void
    flip(int i)
    Flips bit i.
    boolean
    get(int i)
     
    int[]
     
    int
     
    boolean
    isRange(int start, int end, boolean value)
    Efficient method to check if a range of bits is set, or not set.
    private static int[]
    makeArray(int size)
     
    void
    Reverses all bits in the array.
    void
    set(int i)
    Sets bit i.
    void
    setBulk(int i, int newBits)
    Sets a block of 32 bits, starting at bit i.
     

    Methods inherited from class java.lang.Object

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

    • bits

      private int[] bits
    • size

      private final int size
  • Constructor Details

    • BitArray

      public BitArray(int size)
  • Method Details

    • getSize

      public int getSize()
    • get

      public boolean get(int i)
      Parameters:
      i - bit to get.
      Returns:
      true iff bit i is set
    • set

      public void set(int i)
      Sets bit i.
      Parameters:
      i - bit to set
    • flip

      public void flip(int i)
      Flips bit i.
      Parameters:
      i - bit to set
    • setBulk

      public void setBulk(int i, int newBits)
      Sets a block of 32 bits, starting at bit i.
      Parameters:
      i - first bit to set
      newBits - the new value of the next 32 bits. Note again that the least-significant bit corresponds to bit i, the next-least-significant to i+1, and so on.
    • clear

      public void clear()
      Clears all bits (sets to false).
    • isRange

      public boolean isRange(int start, int end, boolean value)
      Efficient method to check if a range of bits is set, or not set.
      Parameters:
      start - start of range, inclusive.
      end - end of range, exclusive
      value - if true, checks that bits in range are set, otherwise checks that they are not set
      Returns:
      true iff all bits are set or not set in range, according to value argument
      Throws:
      IllegalArgumentException - if end is less than or equal to start
    • getBitArray

      public int[] getBitArray()
      Returns:
      underlying array of ints. The first element holds the first 32 bits, and the least significant bit is bit 0.
    • reverse

      public void reverse()
      Reverses all bits in the array.
    • makeArray

      private static int[] makeArray(int size)
    • toString

      public String toString()
      Overrides:
      toString in class Object