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 BitSet
all
(int limit) Returns a bit set containing all bits up to a given limit (exclusive).static BitSet
Returns a bit set containing only those bits which are common to all given sets.static BitSet
Returns a new bit set containing the bits which is contained in the first given bit set, but not in the second.static void
forEach
(BitSet arg, IntConsumer fun) Applies a consumer to each bit contained in a given bit set.static BitSet
Returns a bit set containing those bits which are contained in any of the given sets.static BitSet
singleton
(int single) Returns a bit set containing exactly one bit.static int
Finds the unique bit contained in a bit set.static BitSet
Returns 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
- ifargs
is emptyNullPointerException
- ifargs
or 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
- ifarg1
orarg2
is 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
- ifargs
or 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
a1
ora2
, but not both - Throws:
NullPointerException
- ifa1
ora2
is 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
- iflimit
is 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
- ifsingle
is 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
- ifsingleton
contains 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
- ifarg
orfun
is null
-