Package com.helger.base.rt
Class BitSetHelper
java.lang.Object
com.helger.base.rt.BitSetHelper
Helper class to work with bit sets.
- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull BitSetcreateBitSet(byte nValue) Convert the passed byte value to an bit set of size 8.static @NonNull BitSetcreateBitSet(int nValue) Convert the passed int value to an bit set of size 32.static @NonNull BitSetcreateBitSet(long nValue) Convert the passed long value to an bit set of size 64.static @NonNull BitSetcreateBitSet(short nValue) Convert the passed short value to an bit set of size 16.static intgetExtractedIntValue(@NonNull BitSet aBS) Extract the int representation of the passed bit set.static longgetExtractedLongValue(@NonNull BitSet aBS) Extract 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.
-