Example usage for java.util BitSet equals

List of usage examples for java.util BitSet equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object against the specified object.

Usage

From source file:Main.java

public static void main(String[] args) {

    BitSet bitset1 = new BitSet(8);

    bitset1.set(0);/*  w w  w  . j  ava2  s. c o  m*/
    bitset1.set(1);
    bitset1.set(2);

    BitSet bitset2 = new BitSet(8);

    bitset1.set(0);
    bitset1.set(1);
    bitset1.set(2);

    System.out.println(bitset1.equals(bitset2));

}

From source file:Main.java

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

From source file:de.hpi.petrinet.PetriNet.java

protected Map<Node, Set<Node>> deriveDominators(boolean reverse) {

    int initIndex = reverse ? this.getNodes().indexOf(this.getFinalPlace())
            : this.getNodes().indexOf(this.getInitialPlace());

    int size = this.getNodes().size();
    final BitSet[] dom = new BitSet[size];
    final BitSet ALL = new BitSet(size);

    for (Node n : this.getNodes())
        ALL.set(this.getNodes().indexOf(n));

    for (Node n : this.getNodes()) {
        int index = this.getNodes().indexOf(n);
        BitSet curDoms = new BitSet(size);
        dom[index] = curDoms;/*from w ww . j av a  2  s.  co m*/

        if (index != initIndex)
            curDoms.or(ALL);
        else
            curDoms.set(initIndex);
    }

    boolean changed = true;

    /*
     * While we change the dom relation for a node
     */
    while (changed) {
        changed = false;
        for (Node n : this.getNodes()) {
            int index = this.getNodes().indexOf(n);
            if (index == initIndex)
                continue;

            final BitSet old = dom[index];
            final BitSet curDoms = new BitSet(size);
            curDoms.or(old);

            Collection<Node> predecessors = reverse ? n.getSucceedingNodes() : n.getPrecedingNodes();
            for (Node p : predecessors) {
                int index2 = this.getNodes().indexOf(p);
                curDoms.and(dom[index2]);
            }

            curDoms.set(index);

            if (!curDoms.equals(old)) {
                changed = true;
                dom[index] = curDoms;
            }
        }
    }

    Map<Node, Set<Node>> dominators = new HashMap<Node, Set<Node>>();

    for (Node n : this.getNodes()) {
        int index = this.getNodes().indexOf(n);
        dominators.put(n, new HashSet<Node>());
        for (int i = 0; i < size; i++)
            if (dom[index].get(i))
                dominators.get(n).add(this.getNodes().get(i));
    }

    return dominators;
}

From source file:model.DecomposableModel.java

public BitSet findSab(GraphAction action) {
    int a = action.getV1();
    int b = action.getV2();

    BitSet Sab = null;
    for (CliqueGraphEdge e : graph.cg.edgeSet()) {
        BitSet clique1 = e.getClique1();
        BitSet clique2 = e.getClique2();
        if ((clique1.get(a) && clique2.get(b)) || (clique2.get(a) && clique1.get(b))) {
            Sab = e.getSeparator();// w w  w  .j a  v  a 2  s . c om
            break;
        }
    }
    if (Sab == null) {// disconnected components
        Sab = new BitSet(dimensionsForVariables.length);
    }

    if (!Sab.equals(graph.getSeparator(a, b))) {
        System.err.println("Ouch");
    }
    return Sab;

}

From source file:org.apache.hadoop.hive.ql.optimizer.optiq.stats.HiveRelMdRowCount.java

private static boolean isKey(BitSet c, RelNode rel) {
    boolean isKey = false;
    Set<BitSet> keys = RelMetadataQuery.getUniqueKeys(rel);
    if (keys != null) {
        for (BitSet key : keys) {
            if (key.equals(c)) {
                isKey = true;//from   w w  w . j a  v  a  2 s.  com
                break;
            }
        }
    }
    return isKey;
}

From source file:org.knime.knip.core.features.ObjectCalcAndCache.java

public <T extends RealType<T>> CooccurrenceMatrix cooccurenceMatrix(final IterableInterval<T> ii,
        final int dimX, final int dimY, final int distance, final int nrGrayLevels,
        final MatrixOrientation matrixOrientation, final BitSet features) {
    if ((m_coocII != ii) || (m_coocDist != distance) || (m_coocGrayLevels != nrGrayLevels)
            || (m_coocOrientation != matrixOrientation) || !features.equals(m_coocBitSet)) {
        final MakeCooccurrenceMatrix<T> matrixOp = new MakeCooccurrenceMatrix<T>(dimX, dimY, distance,
                nrGrayLevels, matrixOrientation, features);
        if ((m_coocMatrix == null) || (m_coocGrayLevels != nrGrayLevels)) {
            // matrix still null or size must change
            m_coocMatrix = new CooccurrenceMatrix(nrGrayLevels);
        }//from  w ww.  j a va 2 s . c  o m
        matrixOp.compute(ii, m_coocMatrix);
        m_coocII = ii;
        m_coocDist = distance;
        m_coocGrayLevels = nrGrayLevels;
        m_coocOrientation = matrixOrientation;
        m_coocBitSet = features;
    }
    return m_coocMatrix;
}