Class FlexFec03BitSet


  • public class FlexFec03BitSet
    extends Object
    A bit-set class which is similar to a standard bitset, but with 2 differences: 1) The size of this set is preserved. Unlike the standard bitset, which will not include leading 0's in its size (which doesn't work well for a bitmask), this one will always report the size it was allocated for 2) When reading (valueOf) and writing (toByteArray) it inverts the order of the bits. This is because in FlexFEC-03, the left-most bit of the mask represents a delta value of '0'.
    • Constructor Summary

      Constructors 
      Constructor Description
      FlexFec03BitSet​(int numBits)
      Ctor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBit​(int bitIndex, boolean bitValue)
      Add a bit with the given value in the given position.
      void clear​(int bitIndex)
      Clear the bit (set to 0) at the given index
      boolean get​(int bitIndex)
      Get the bit at the given index
      void removeBit​(int bitIndex)
      Remove a bit from the given position.
      void set​(int bitIndex)
      Set the bit (set to 1) at the given index
      int sizeBits()
      Get the size of this set, in bits
      int sizeBytes()
      Get the size of this set, in bytes
      byte[] toByteArray()
      Writes this bitset to a byte array, where the rightmost bit is treated as the least significant bit.
      String toString()
      Print the bitmask in a manner where the left-most bit is the LSB
      static FlexFec03BitSet valueOf​(byte[] bytes)
      Parse the value of the given byte buffer into the bitset
      static FlexFec03BitSet valueOf​(byte[] bytes, int offset, int length)
      Parse the given bytes (at the given offset and length) into a FlexFec03BitSet
    • Constructor Detail

      • FlexFec03BitSet

        public FlexFec03BitSet​(int numBits)
        Ctor
        Parameters:
        numBits - the size, in bits, of this set
    • Method Detail

      • set

        public void set​(int bitIndex)
        Set the bit (set to 1) at the given index
      • get

        public boolean get​(int bitIndex)
        Get the bit at the given index
      • clear

        public void clear​(int bitIndex)
        Clear the bit (set to 0) at the given index
      • addBit

        public void addBit​(int bitIndex,
                           boolean bitValue)
        Add a bit with the given value in the given position. Existing bits will be moved to the right. No loss of bits will occur.
        Parameters:
        bitIndex - the index at which to insert the bit
        bitValue - the value to set on the inserted bit
      • removeBit

        public void removeBit​(int bitIndex)
        Remove a bit from the given position. Existing bits will be moved to the left.
      • valueOf

        public static FlexFec03BitSet valueOf​(byte[] bytes)
        Parse the value of the given byte buffer into the bitset
      • valueOf

        public static FlexFec03BitSet valueOf​(byte[] bytes,
                                              int offset,
                                              int length)
        Parse the given bytes (at the given offset and length) into a FlexFec03BitSet
        Parameters:
        bytes - the byte buffer to parse
        offset - the offset at which to start parsing
        length - the length (in bytes) of the chunk to parse
        Returns:
        a FlexFec03BitSet representing the chunk of the given buffer based on the given offset and length
      • sizeBytes

        public int sizeBytes()
        Get the size of this set, in bytes
        Returns:
        the size of this set, in bytes
      • sizeBits

        public int sizeBits()
        Get the size of this set, in bits
        Returns:
        the size of this set, in bits
      • toByteArray

        public byte[] toByteArray()
        Writes this bitset to a byte array, where the rightmost bit is treated as the least significant bit.
      • toString

        public String toString()
        Print the bitmask in a manner where the left-most bit is the LSB
        Overrides:
        toString in class Object