Package eu.bandm.tools.util.java
Class BitSets
java.lang.Object
eu.bandm.tools.util.java.BitSets
Library of constants and operations for working with bit sets.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic BitSetall(int limit) Returns a bit set containing all bits up to a given limit (exclusive).static BitSetReturns a bit set containing only those bits which are common to all given sets.static BitSetReturns a new bit set containing the bits which is contained in the first given bit set, but not in the second.static voidforEach(BitSet arg, IntConsumer fun) Applies a consumer to each bit contained in a given bit set.static BitSetReturns a bit set containing those bits which are contained in any of the given sets.static BitSetsingleton(int single) Returns a bit set containing exactly one bit.static intFinds the unique bit contained in a bit set.static BitSetReturns a new bit set containing the bits which are contained in exactly one of the given bit sets.
-
Method Details
-
and
Returns a bit set containing only those bits which are common to all given sets.- Parameters:
args- some bit sets- Returns:
- a new bit set containing any bit if and only if it is contained in all given bit sets
- Throws:
IllegalArgumentException- ifargsis emptyNullPointerException- ifargsor any element of it is null- See Also:
-
andNot
Returns a new bit set containing the bits which is contained in the first given bit set, but not in the second.- Parameters:
arg1- a bit setarg2- another bit set- Returns:
- a new bit set containing any bit if and only if it is contained in
arg1, but not inarg2 - Throws:
NullPointerException- ifarg1orarg2is null- See Also:
-
or
Returns a bit set containing those bits which are contained in any of the given sets.The union of zero bit sets is empty.
- Parameters:
args- some bit sets- Returns:
- a new bit set containing any bit if and only if it is contained in at least one of the given bit sets
- Throws:
NullPointerException- ifargsor any element of it is null- See Also:
-
xor
Returns a new bit set containing the bits which are contained in exactly one of the given bit sets.- Parameters:
a1- a bit seta2- another bit set- Returns:
- a new bit set containing any bit if and only if it is contained in
either
a1ora2, but not both - Throws:
NullPointerException- ifa1ora2is null- See Also:
-
all
Returns a bit set containing all bits up to a given limit (exclusive).- Parameters:
limit- the number of bits- Returns:
- a bit set with all bits up to
limit(exclusive) - Throws:
IllegalArgumentException- iflimitis negative- See Also:
-
singleton
Returns a bit set containing exactly one bit.- Parameters:
single- the bit- Returns:
- a new bit set containing the given bit but no other
- Throws:
IndexOutOfBoundsException- ifsingleis negative- See Also:
-
the
Finds the unique bit contained in a bit set.- Parameters:
singleton- a bit set containing exactly one bit- Returns:
- the index of the contained bit
- Throws:
IllegalArgumentException- ifsingletoncontains none, or more than one bit- See Also:
-
forEach
Applies a consumer to each bit contained in a given bit set.- Parameters:
arg- the bit setfun- the consumer- Throws:
NullPointerException- ifargorfunis null
-