Package owl.collections
Class BitSet2
- java.lang.Object
-
- owl.collections.BitSet2
-
public final class BitSet2 extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SortedSet<Integer>asSet(BitSet bitSet)Creates a view of the {@param bitSet} as aSet.static <S> Set<? extends S>asSet(BitSet bs, IntFunction<? extends S> stateMap)Converts a BitSet into a set.static BitSetcopyOf(BitSet bitSet)static <S> BitSetcopyOf(Collection<? extends S> set, ToIntFunction<? super S> mapping)Converts a set into a bitset.static BitSetcopyOf(Collection<Integer> set)static BitSetcopyOf(ImmutableBitSet set)static BitSetfromInt(int i)Converts an int into a BitSet.static BitSetintersection(BitSet a, BitSet b)static BitSetof()static BitSetof(int e0)static BitSetof(int... elements)static BitSetof(int e0, int e1)static Iterable<BitSet>powerSet(int i)Returns an iterator over all BitSets with length at most i.static Iterable<BitSet>powerSet(BitSet basis)static inttoInt(BitSet bs)Converts a BitSet into an Int.static BitSetunion(BitSet a, BitSet b)static BitSetwithout(BitSet a, BitSet b)
-
-
-
Method Detail
-
of
public static BitSet of()
-
of
public static BitSet of(int e0)
-
of
public static BitSet of(int e0, int e1)
-
of
public static BitSet of(int... elements)
-
copyOf
public static BitSet copyOf(ImmutableBitSet set)
-
copyOf
public static BitSet copyOf(Collection<Integer> set)
-
copyOf
public static <S> BitSet copyOf(Collection<? extends S> set, ToIntFunction<? super S> mapping)
Converts a set into a bitset.- Parameters:
set- set to be convertedmapping- mapping from elements to indices- Returns:
- corresponding BitSet
-
asSet
public static SortedSet<Integer> asSet(BitSet bitSet)
Creates a view of the {@param bitSet} as aSet. All changes of the underlying Bitset are reflected in the view and vice-versa.This method acts as bridge between bitset-based and collection-based APIs, in combination with
copyOf(Collection), similar toArrays.asList(Object[])- Parameters:
bitSet- the bitset for which the view is created.- Returns:
- a view.
-
asSet
public static <S> Set<? extends S> asSet(BitSet bs, IntFunction<? extends S> stateMap)
Converts a BitSet into a set.- Parameters:
bs- bitset to be decodedstateMap- mapping from bits to elements- Returns:
- resulting set
-
toInt
public static int toInt(BitSet bs)
Converts a BitSet into an Int.- Parameters:
bs- bitset to be encoded (should be small enough to fit into int)
-
fromInt
public static BitSet fromInt(int i)
Converts an int into a BitSet.- Parameters:
i- int to be decoded into bitset
-
powerSet
public static Iterable<BitSet> powerSet(int i)
Returns an iterator over all BitSets with length at most i.- Parameters:
i- the maximal length.- Returns:
- each next()-call constructs a fresh BitSet.
-
-