Class BitSet2


  • public final class BitSet2
    extends Object
    • 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 <S> BitSet copyOf​(Collection<? extends S> set,
                                        ToIntFunction<? super S> mapping)
        Converts a set into a bitset.
        Parameters:
        set - set to be converted
        mapping - mapping from elements to indices
        Returns:
        corresponding BitSet
      • asSet

        public static SortedSet<Integer> asSet​(BitSet bitSet)
        Creates a view of the {@param bitSet} as a Set. 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 to Arrays.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 decoded
        stateMap - 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.