Java BitSet isSubSet(BitSet x, BitSet y)

Here you can find the source of isSubSet(BitSet x, BitSet y)

Description

very inefficient, but Java wonderful bitset has no subset op perhaps using bit iterator would be faster, I can't be bothered.

License

LGPL

Parameter

Parameter Description
x a parameter
y a parameter

Declaration

public static boolean isSubSet(BitSet x, BitSet y) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.BitSet;

public class Main {
    /**//from  ww w.  j  a  va  2 s. c  om
     * very inefficient, but Java wonderful bitset has no subset op
     * perhaps using bit iterator would be faster, I can't be bothered.
     * @param x
     * @param y
     * @return
     */
    public static boolean isSubSet(BitSet x, BitSet y) {
        y = (BitSet) y.clone();
        y.and(x);
        return y.equals(x);
    }
}

Related

  1. isEmptySet(BitSet setToTest)
  2. isHammingDistanceOne(BitSet a, BitSet b)
  3. isSet(int n, BitSet... sets)
  4. isSubset(BitSet bits1, BitSet bits2)
  5. isSubset(BitSet subsetToTest, BitSet supersetToTest)
  6. longFrom(final BitSet bitSet)
  7. longToBitSet(long bits)
  8. longToBitSet(long value)
  9. mapToBitSet(Map map, String key)