Example usage for java.util BitSet or

List of usage examples for java.util BitSet or

Introduction

In this page you can find the example usage for java.util BitSet or.

Prototype

public void or(BitSet set) 

Source Link

Document

Performs a logical OR of this bit set with the bit set argument.

Usage

From source file:BitOps.java

public static void main(String args[]) {
    BitSet set = new BitSet();
    set.set(1);//from   ww w  .j  av  a  2s .co m
    set.set(2);
    set.set(3);
    set.set(4);
    set.set(5);
    System.out.println(set);
    BitSet set2 = new BitSet();
    set2.set(1);
    set2.set(3);
    set2.set(5);
    set2.set(7);
    BitSet set3 = (BitSet) set.clone();
    set3.and(set2);
    System.out.println(set3);
    set3 = (BitSet) set.clone();
    set3.or(set2);
    System.out.println(set3);
    set3 = (BitSet) set.clone();
    set3.xor(set2);
    System.out.println(set3);
    set3 = (BitSet) set.clone();
    set3.andNot(set2);
    System.out.println(set3);
    set3.andNot(null);
}

From source file:MainClass.java

public static void main(String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);// w  w w.  jav a2 s  . c  om
    bites.set(1);
    bites.set(2);
    bites.set(3);
    System.out.println(bites);

    bites.and(bites);
    System.out.println(bites);

    bites.or(bites);
    System.out.println(bites);

    bites.xor(bites);
    System.out.println(bites);

    bites.andNot(bites);
    System.out.println(bites);

}

From source file:Main.java

public static void main(String[] args) {

    BitSet bitset1 = new BitSet(8);
    BitSet bitset2 = new BitSet(8);

    // assign values to bitset1
    bitset1.set(0);//from   ww w  .  j  a  va2s .co  m
    bitset1.set(1);

    // assign values to bitset2
    bitset2.set(2);
    bitset2.set(4);
    bitset2.set(6);

    // print the sets
    System.out.println("Bitset1:" + bitset1);
    System.out.println("Bitset2:" + bitset2);

    // perform a logical or between the two bitsets
    bitset1.or(bitset2);
    System.out.println(bitset1);
}

From source file:MainClass.java

public static void main(String args[]) {
    BitSet bits1 = new BitSet(16);
    BitSet bits2 = new BitSet(16);

    // set some bits
    for (int i = 0; i < 16; i++) {
        if ((i % 2) == 0)
            bits1.set(i);//  w  w  w . j  a v  a 2 s .  c o  m
        if ((i % 5) != 0)
            bits2.set(i);
    }

    System.out.println("Initial pattern in bits1: ");
    System.out.println(bits1);
    System.out.println("\nInitial pattern in bits2: ");
    System.out.println(bits2);

    // AND bits
    bits2.and(bits1);
    System.out.println("\nbits2 AND bits1: ");
    System.out.println(bits2);

    // OR bits
    bits2.or(bits1);
    System.out.println("\nbits2 OR bits1: ");
    System.out.println(bits2);

    // XOR bits
    bits2.xor(bits1);
    System.out.println("\nbits2 XOR bits1: ");
    System.out.println(bits2);
}

From source file:com.textocat.textokit.morph.model.Wordform.java

public static BitSet getAllGramBits(Wordform wf, MorphDictionary dict) {
    BitSet bs = wf.getGrammems();
    // TODO how to detect null lemma ids?
    bs.or(dict.getLemma(wf.getLemmaId()).getGrammems());
    return bs;//  w ww .jav a  2s . c o  m
}

From source file:com.cloudera.oryx.kmeans.computation.cluster.KSketchIndex.java

private static int hammingDistance(BitSet q, BitSet idx) {
    BitSet x = new BitSet(q.size());
    x.or(q);
    x.xor(idx);/* w ww.j  a  v a  2s. c  o  m*/
    return x.cardinality();
}

From source file:ca.phon.ipa.features.FeatureSet.java

/**
 * Produces a new FeatureSet based on the set-union
 * of the two given FeatureSets//from ww  w . jav a 2 s.  c  o  m
 * 
 * @param fs1
 * @param fs2
 *
 * @return fs1 UNION fs2
 */
public static FeatureSet union(FeatureSet fs1, FeatureSet fs2) {
    BitSet bs = (BitSet) fs1.features.clone();
    bs.or(fs2.features);

    return new FeatureSet(bs);
}

From source file:com.l2jfree.gameserver.idfactory.BitSetIDFactory.java

protected synchronized void increaseBitSetCapacity() {
    BitSet newBitSet = new BitSet(PrimeFinder.nextPrime(usedIdCount() * 11 / 10));
    newBitSet.or(_freeIds);
    _freeIds = newBitSet;//from  w w w  .ja  v  a2 s .c  om
}

From source file:fingerprints.helper.BloomFilter.java

public BitSet toBitSet() {
    BitSet result = new BitSet(bitSetSize);
    result.or(bitSet);
    return result;
}

From source file:com.textocat.textokit.morph.opencorpora.resource.MorphDictionaryImpl.java

public void addWordform(String text, Wordform wf) {
    wf = wf.cloneWithGrammems(internWordformGrammems(wf.getGrammems()));
    wfByString.put(text, wf);//from  w  ww  .  j  a va  2s .  c o m
    // add complete tag
    BitSet tag = wf.getGrammems();
    tag.or(getLemma(wf.getLemmaId()).getGrammems());
    tagset.add(tag);
    // fire event
    listeners.fire().onWordformAdded(this, text, wf);
}