Package com.helger.commons.lang
Class BitSetHelper
java.lang.Object
com.helger.commons.lang.BitSetHelper
Helper class to work with bit sets.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic BitSetcreateBitSet(byte nValue) Convert the passed byte value to an bit set of size 8.static BitSetcreateBitSet(int nValue) Convert the passed int value to an bit set of size 32.static BitSetcreateBitSet(long nValue) Convert the passed long value to an bit set of size 64.static BitSetcreateBitSet(short nValue) Convert the passed short value to an bit set of size 16.static intExtract the int representation of the passed bit set.static longExtract the long representation of the passed bit set.
-
Method Details
-
createBitSet
Convert the passed byte value to an bit set of size 8.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
createBitSet
Convert the passed short value to an bit set of size 16.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
createBitSet
Convert the passed int value to an bit set of size 32.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
createBitSet
Convert the passed long value to an bit set of size 64.- Parameters:
nValue- The value to be converted to a bit set.- Returns:
- The non-
nullbit set.
-
getExtractedIntValue
Extract the int representation of the passed bit set. To avoid loss of data, the bit set may not have more than 32 bits.- Parameters:
aBS- The bit set to extract the value from. May not benull.- Returns:
- The extracted value. May be negative if the bit set has 32 elements, the highest order bit is set.
-
getExtractedLongValue
Extract the long representation of the passed bit set. To avoid loss of data, the bit set may not have more than 64 bits.- Parameters:
aBS- The bit set to extract the value from. May not benull.- Returns:
- The extracted value. May be negative if the bit set has 64 elements, the highest order bit is set.
-