Class FlexFec03BitSet
- java.lang.Object
-
- org.jitsi.impl.neomedia.transform.fec.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 voidaddBit(int bitIndex, boolean bitValue)Add a bit with the given value in the given position.voidclear(int bitIndex)Clear the bit (set to 0) at the given indexbooleanget(int bitIndex)Get the bit at the given indexvoidremoveBit(int bitIndex)Remove a bit from the given position.voidset(int bitIndex)Set the bit (set to 1) at the given indexintsizeBits()Get the size of this set, in bitsintsizeBytes()Get the size of this set, in bytesbyte[]toByteArray()Writes this bitset to a byte array, where the rightmost bit is treated as the least significant bit.StringtoString()Print the bitmask in a manner where the left-most bit is the LSBstatic FlexFec03BitSetvalueOf(byte[] bytes)Parse the value of the given byte buffer into the bitsetstatic FlexFec03BitSetvalueOf(byte[] bytes, int offset, int length)Parse the given bytes (at the given offset and length) into a FlexFec03BitSet
-
-
-
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 bitbitValue- 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 parseoffset- the offset at which to start parsinglength- 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.
-
-