Search in sources :

Example 41 with BitSet

use of java.util.BitSet in project j2objc by google.

the class BitSetTest method test_nextSetBitI.

public void test_nextSetBitI() {
    BitSet bs = new BitSet(500);
    bs.set(5);
    bs.set(32);
    bs.set(63);
    bs.set(64);
    bs.set(71, 110);
    bs.set(127, 130);
    bs.set(193);
    bs.set(450);
    try {
        bs.nextSetBit(-1);
        fail();
    } catch (IndexOutOfBoundsException expected) {
    }
    assertEquals(5, bs.nextSetBit(0));
    assertEquals(5, bs.nextSetBit(5));
    assertEquals(32, bs.nextSetBit(6));
    assertEquals(32, bs.nextSetBit(32));
    assertEquals(63, bs.nextSetBit(33));
    // boundary tests
    assertEquals(63, bs.nextSetBit(63));
    assertEquals(64, bs.nextSetBit(64));
    // at bitset element 1
    assertEquals(71, bs.nextSetBit(65));
    assertEquals(71, bs.nextSetBit(71));
    assertEquals(72, bs.nextSetBit(72));
    assertEquals(127, bs.nextSetBit(110));
    // boundary tests
    assertEquals(127, bs.nextSetBit(127));
    assertEquals(128, bs.nextSetBit(128));
    // at bitset element 2
    assertEquals(193, bs.nextSetBit(130));
    assertEquals(193, bs.nextSetBit(191));
    assertEquals(193, bs.nextSetBit(192));
    assertEquals(193, bs.nextSetBit(193));
    assertEquals(450, bs.nextSetBit(194));
    assertEquals(450, bs.nextSetBit(255));
    assertEquals(450, bs.nextSetBit(256));
    assertEquals(450, bs.nextSetBit(450));
    assertEquals(-1, bs.nextSetBit(451));
    assertEquals(-1, bs.nextSetBit(511));
    assertEquals(-1, bs.nextSetBit(512));
    assertEquals(-1, bs.nextSetBit(800));
}
Also used : BitSet(java.util.BitSet)

Example 42 with BitSet

use of java.util.BitSet in project j2objc by google.

the class BitSetTest method test_nextClearBitI.

public void test_nextClearBitI() {
    BitSet bs = new BitSet(500);
    // ensure all the bits from 0 to bs.size() - 1 are set to true
    bs.set(0, bs.size() - 1);
    bs.set(bs.size() - 1);
    bs.clear(5);
    bs.clear(32);
    bs.clear(63);
    bs.clear(64);
    bs.clear(71, 110);
    bs.clear(127, 130);
    bs.clear(193);
    bs.clear(450);
    try {
        bs.nextClearBit(-1);
        fail();
    } catch (IndexOutOfBoundsException expected) {
    }
    assertEquals(5, bs.nextClearBit(0));
    assertEquals(5, bs.nextClearBit(5));
    assertEquals(32, bs.nextClearBit(6));
    assertEquals(32, bs.nextClearBit(32));
    assertEquals(63, bs.nextClearBit(33));
    // boundary tests
    assertEquals(63, bs.nextClearBit(63));
    assertEquals(64, bs.nextClearBit(64));
    // at bitset element 1
    assertEquals(71, bs.nextClearBit(65));
    assertEquals(71, bs.nextClearBit(71));
    assertEquals(72, bs.nextClearBit(72));
    assertEquals(127, bs.nextClearBit(110));
    // boundary tests
    assertEquals(127, bs.nextClearBit(127));
    assertEquals(128, bs.nextClearBit(128));
    // at bitset element 2
    assertEquals(193, bs.nextClearBit(130));
    assertEquals(193, bs.nextClearBit(191));
    assertEquals(193, bs.nextClearBit(192));
    assertEquals(193, bs.nextClearBit(193));
    assertEquals(450, bs.nextClearBit(194));
    assertEquals(450, bs.nextClearBit(255));
    assertEquals(450, bs.nextClearBit(256));
    assertEquals(450, bs.nextClearBit(450));
    // bitset has 1 still the end of bs.size() -1, but calling nextClearBit
    // with any index value after the last true bit should return bs.size()
    assertEquals(512, bs.nextClearBit(451));
    assertEquals(512, bs.nextClearBit(511));
    assertEquals(512, bs.nextClearBit(512));
    // if the index is larger than bs.size(), nextClearBit should return index
    assertEquals(513, bs.nextClearBit(513));
    assertEquals(800, bs.nextClearBit(800));
    bs.clear();
    assertEquals(0, bs.nextClearBit(0));
    assertEquals(3, bs.nextClearBit(3));
    assertEquals(64, bs.nextClearBit(64));
    assertEquals(128, bs.nextClearBit(128));
}
Also used : BitSet(java.util.BitSet)

Example 43 with BitSet

use of java.util.BitSet in project h2o-3 by h2oai.

the class SharedTreeNode method calculateChildInclusiveLevels.

/**
   * Calculate the set of levels that flow through to a child.
   * @param includeAllLevels naVsRest dictates include all (inherited) levels
   * @param discardAllLevels naVsRest dictates discard all levels
   * @param nodeBitsetDoesContain true if the GenmodelBitset from the compressed_tree
   * @return Calculated set of levels
   */
private BitSet calculateChildInclusiveLevels(boolean includeAllLevels, boolean discardAllLevels, boolean nodeBitsetDoesContain) {
    BitSet inheritedInclusiveLevels = findInclusiveLevels(colId);
    BitSet childInclusiveLevels = new BitSet();
    for (int i = 0; i < domainValues.length; i++) {
        // Calculate whether this level should flow into this child node.
        boolean includeThisLevel = false;
        {
            if (discardAllLevels) {
                includeThisLevel = false;
            } else if (includeAllLevels) {
                includeThisLevel = calculateIncludeThisLevel(inheritedInclusiveLevels, i);
            } else if (bs.isInRange(i) && bs.contains(i) == nodeBitsetDoesContain) {
                includeThisLevel = calculateIncludeThisLevel(inheritedInclusiveLevels, i);
            }
        }
        if (includeThisLevel) {
            childInclusiveLevels.set(i);
        }
    }
    return childInclusiveLevels;
}
Also used : BitSet(java.util.BitSet) GenmodelBitSet(hex.genmodel.utils.GenmodelBitSet)

Example 44 with BitSet

use of java.util.BitSet in project h2o-3 by h2oai.

the class SharedTreeNode method setRightChild.

void setRightChild(SharedTreeNode v) {
    rightChild = v;
    boolean childInclusiveNa = calculateChildInclusiveNa(!leftward);
    v.setInclusiveNa(childInclusiveNa);
    if (!isBitset()) {
        return;
    }
    BitSet childInclusiveLevels = calculateChildInclusiveLevels(false, naVsRest, true);
    v.setInclusiveLevels(childInclusiveLevels);
}
Also used : BitSet(java.util.BitSet) GenmodelBitSet(hex.genmodel.utils.GenmodelBitSet)

Example 45 with BitSet

use of java.util.BitSet in project h2o-3 by h2oai.

the class SharedTreeNode method setLeftChild.

void setLeftChild(SharedTreeNode v) {
    leftChild = v;
    boolean childInclusiveNa = calculateChildInclusiveNa(leftward);
    v.setInclusiveNa(childInclusiveNa);
    if (!isBitset()) {
        return;
    }
    BitSet childInclusiveLevels = calculateChildInclusiveLevels(naVsRest, false, false);
    v.setInclusiveLevels(childInclusiveLevels);
}
Also used : BitSet(java.util.BitSet) GenmodelBitSet(hex.genmodel.utils.GenmodelBitSet)

Aggregations

BitSet (java.util.BitSet)1018 Test (org.junit.Test)129 ArrayList (java.util.ArrayList)112 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)45 List (java.util.List)38 Map (java.util.Map)33 HashMap (java.util.HashMap)30 HashSet (java.util.HashSet)29 IOException (java.io.IOException)24 Random (java.util.Random)24 RegisterSpecList (com.taobao.android.dx.rop.code.RegisterSpecList)22 Cursor (android.database.Cursor)20 MatrixCursor (android.database.MatrixCursor)20 MergeCursor (android.database.MergeCursor)20 DirectoryResult (com.android.documentsui.DirectoryResult)20 LinkedList (java.util.LinkedList)20 Iterator (java.util.Iterator)14 File (java.io.File)13 BlockNode (jadx.core.dex.nodes.BlockNode)12 BitSetGroup (org.apache.carbondata.core.util.BitSetGroup)12