public final class BitSetUtilities extends Object
DomainBitSet
s.Constructor and Description |
---|
BitSetUtilities() |
Modifier and Type | Method and Description |
---|---|
static BigInteger |
asBigInteger(BitSet bitset)
Creates a BigInteger of a given bit set.
|
static BigInteger |
asBigInteger(long mask)
Converts a long to a positive (unsigned) integer.
|
static BitSet |
asBitSet(BigInteger mask)
Creates a BitSet of a given mask.
|
static <X extends Enum<X> & EnumBitSetHelper<X>> |
asBitSet(long mask)
Creates a BitSet of a given bit mask.
|
static long |
asLong(BigInteger mask)
Converts a BigInteger to long.
|
static long |
asLong(BitSet bitset)
Converts a BitSet to long.
|
static <C,T1 extends C,T2 extends C> |
cross(DomainBitSet<T2> set1,
DomainBitSet<T2> set2,
Class<C> type)
Returns the Cartesian Product.
|
static <T> DomainBitSet<T> |
intersect(DomainBitSet<T> set1,
DomainBitSet<T> set2)
Returns the intersection of two sets.
|
static <T> DomainBitSet<T> |
minus(DomainBitSet<T> set1,
DomainBitSet<T> set2)
Returns the relative complement of two sets.
|
static <T> Collector<T,Set<T>,DomainBitSet<T>> |
toDomainBitSet(Domain<T> domain)
Collector to convert a
Stream to a DomainBitSet . |
static <T,D extends DomainBitSet<T>> |
toDomainBitSet(Function<Collection<T>,D> bitsetFactory)
Collector to convert a
Stream to a DomainBitSet . |
static <T> Collector<Pair<Object,Integer,T>,?,TreeMap<Integer,T>> |
toTreeMap()
|
static <T> DomainBitSet<T> |
union(DomainBitSet<T> set1,
DomainBitSet<T> set2)
Returns the union of two sets.
|
public static BigInteger asBigInteger(BitSet bitset)
bitset
- A bit set.public static BigInteger asBigInteger(long mask)
mask
- A long value that represents a bit set.public static BitSet asBitSet(BigInteger mask)
mask
- A bit mask, must be positive.public static <X extends Enum<X> & EnumBitSetHelper<X>> BitSet asBitSet(long mask)
This method can not check if there are more than 64 elements on the enum type, as the enum type is not known. It simply converts a long to a bitset.
X
- Enum type of the elements.mask
- A bit mask.public static long asLong(BigInteger mask)
mask
- A bit mask, must be positive and lower than 264.IllegalArgumentException
- Only positive values with up to 64 bits are allowed.public static long asLong(BitSet bitset)
bitset
- A bit set.IllegalArgumentException
- Only bit sets with using up to 64 bits are allowed.public static <C,T1 extends C,T2 extends C> Set<Pair<C,T1,T2>> cross(DomainBitSet<T2> set1, DomainBitSet<T2> set2, Class<C> type)
Example: If the types are Integer
and Double
then the supertype Number
can be used.
The returned set has a size of this.size() * set.size()
. The given type has to be
a super type of both other types.
C
- A common base type.T1
- The type of the elements in the first set.T2
- The type of the elements in the second set.set1
- A set.set2
- Another set.DomainBitSet.cross(DomainBitSet)
,
DomainBitSet.cross(DomainBitSet, BiConsumer)
public static <T> DomainBitSet<T> intersect(DomainBitSet<T> set1, DomainBitSet<T> set2)
T
- The type of the domain.set1
- The first set.set2
- The second set.BinaryOperator
,
DomainBitSet.intersect(Iterable)
public static <T> DomainBitSet<T> minus(DomainBitSet<T> set1, DomainBitSet<T> set2)
T
- The type of the domain.set1
- The first set.set2
- The second set.BinaryOperator
,
DomainBitSet.minus(Iterable)
public static <T> Collector<T,Set<T>,DomainBitSet<T>> toDomainBitSet(Domain<T> domain)
Stream
to a DomainBitSet
.T
- Type of elements.domain
- the Domain
to create the DomainBitSet
.Domain.factory()
,
Collectors.toCollection(Supplier)
public static <T,D extends DomainBitSet<T>> Collector<T,Set<T>,D> toDomainBitSet(Function<Collection<T>,D> bitsetFactory)
Stream
to a DomainBitSet
.T
- Type of elements.D
- Type of DomainBitSet.bitsetFactory
- Creates an empty bitset.Collectors.toCollection(Supplier)
public static <T> Collector<Pair<Object,Integer,T>,?,TreeMap<Integer,T>> toTreeMap()
Stream
of Pair
s to a TreeMap
.
A stream with multiple entries for the same position will cause a IllegalStateException
.
T
- the type of the elements.DomainBitSet.zipWithPosition()
public static <T> DomainBitSet<T> union(DomainBitSet<T> set1, DomainBitSet<T> set2)
T
- The type of the domain.set1
- The first set.set2
- The second set.BinaryOperator
,
DomainBitSet.union(Iterable)