Search in sources :

Example 61 with BitSet

use of java.util.BitSet in project jdk8u_jdk by JetBrains.

the class B6296240 method main.

public static void main(String[] args) {
    String[] malformedIPv4s = { "192.168.1.220..." };
    BitSet expectedExceptions = new BitSet(malformedIPv4s.length);
    expectedExceptions.clear();
    for (int i = 0; i < malformedIPv4s.length; i++) {
        try {
            InetAddress.getAllByName(malformedIPv4s[i]);
        } catch (UnknownHostException e) {
            expectedExceptions.set(i);
        }
    }
    for (int i = 0; i < malformedIPv4s.length; i++) {
        if (!expectedExceptions.get(i)) {
            System.out.println("getAllByName(\"" + malformedIPv4s[i] + "\") should throw exception.");
        }
    }
    if (expectedExceptions.cardinality() != malformedIPv4s.length) {
        throw new RuntimeException("Failed: some expected UnknownHostExceptions are not thrown.");
    }
}
Also used : BitSet(java.util.BitSet)

Example 62 with BitSet

use of java.util.BitSet in project android_frameworks_base by DirtyUnicorns.

the class HotplugDetectionAction method complement.

// A - B = A & ~B
private static BitSet complement(BitSet first, BitSet second) {
    // Need to clone it so that it doesn't touch original set.
    BitSet clone = (BitSet) first.clone();
    clone.andNot(second);
    return clone;
}
Also used : BitSet(java.util.BitSet)

Example 63 with BitSet

use of java.util.BitSet in project android_frameworks_base by DirtyUnicorns.

the class HotplugDetectionAction method checkHotplug.

private void checkHotplug(List<Integer> ackedAddress, boolean audioOnly) {
    BitSet currentInfos = infoListToBitSet(tv().getDeviceInfoList(false), audioOnly);
    BitSet polledResult = addressListToBitSet(ackedAddress);
    // At first, check removed devices.
    BitSet removed = complement(currentInfos, polledResult);
    int index = -1;
    while ((index = removed.nextSetBit(index + 1)) != -1) {
        if (index == Constants.ADDR_AUDIO_SYSTEM) {
            HdmiDeviceInfo avr = tv().getAvrDeviceInfo();
            if (avr != null && tv().isConnected(avr.getPortId())) {
                ++mAvrStatusCount;
                Slog.w(TAG, "Ack not returned from AVR. count: " + mAvrStatusCount);
                if (mAvrStatusCount < AVR_COUNT_MAX) {
                    continue;
                }
            }
        }
        Slog.v(TAG, "Remove device by hot-plug detection:" + index);
        removeDevice(index);
    }
    // Reset the counter if the ack is returned from AVR.
    if (!removed.get(Constants.ADDR_AUDIO_SYSTEM)) {
        mAvrStatusCount = 0;
    }
    // Next, check added devices.
    BitSet added = complement(polledResult, currentInfos);
    index = -1;
    while ((index = added.nextSetBit(index + 1)) != -1) {
        Slog.v(TAG, "Add device by hot-plug detection:" + index);
        addDevice(index);
    }
}
Also used : HdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo) BitSet(java.util.BitSet)

Example 64 with BitSet

use of java.util.BitSet in project jmonkeyengine by jMonkeyEngine.

the class BoneTrack method setTime.

/**
     * 
     * Modify the bone which this track modifies in the skeleton to contain
     * the correct animation transforms for a given time.
     * The transforms can be interpolated in some method from the keyframes.
     *
     * @param time the current time of the animation
     * @param weight the weight of the animation
     * @param control
     * @param channel
     * @param vars
     */
public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) {
    BitSet affectedBones = channel.getAffectedBones();
    if (affectedBones != null && !affectedBones.get(targetBoneIndex)) {
        return;
    }
    Bone target = control.getSkeleton().getBone(targetBoneIndex);
    Vector3f tempV = vars.vect1;
    Vector3f tempS = vars.vect2;
    Quaternion tempQ = vars.quat1;
    Vector3f tempV2 = vars.vect3;
    Vector3f tempS2 = vars.vect4;
    Quaternion tempQ2 = vars.quat2;
    int lastFrame = times.length - 1;
    if (time < 0 || lastFrame == 0) {
        rotations.get(0, tempQ);
        translations.get(0, tempV);
        if (scales != null) {
            scales.get(0, tempS);
        }
    } else if (time >= times[lastFrame]) {
        rotations.get(lastFrame, tempQ);
        translations.get(lastFrame, tempV);
        if (scales != null) {
            scales.get(lastFrame, tempS);
        }
    } else {
        int startFrame = 0;
        int endFrame = 1;
        // use lastFrame so we never overflow the array
        int i;
        for (i = 0; i < lastFrame && times[i] < time; i++) {
            startFrame = i;
            endFrame = i + 1;
        }
        float blend = (time - times[startFrame]) / (times[endFrame] - times[startFrame]);
        rotations.get(startFrame, tempQ);
        translations.get(startFrame, tempV);
        if (scales != null) {
            scales.get(startFrame, tempS);
        }
        rotations.get(endFrame, tempQ2);
        translations.get(endFrame, tempV2);
        if (scales != null) {
            scales.get(endFrame, tempS2);
        }
        tempQ.nlerp(tempQ2, blend);
        tempV.interpolateLocal(tempV2, blend);
        tempS.interpolateLocal(tempS2, blend);
    }
    //        if (weight != 1f) {
    target.blendAnimTransforms(tempV, tempQ, scales != null ? tempS : null, weight);
//        } else {
//            target.setAnimTransforms(tempV, tempQ, scales != null ? tempS : null);
//        }
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) BitSet(java.util.BitSet)

Example 65 with BitSet

use of java.util.BitSet in project android_frameworks_base by AOSPA.

the class ModelTest method testSort_sizesWithBucketing.

// Tests that directories and files are properly bucketed when sorting by size
public void testSort_sizesWithBucketing() {
    MatrixCursor c = new MatrixCursor(COLUMNS);
    for (int i = 0; i < ITEM_COUNT; ++i) {
        MatrixCursor.RowBuilder row = c.newRow();
        row.add(RootCursorWrapper.COLUMN_AUTHORITY, AUTHORITY);
        row.add(Document.COLUMN_DOCUMENT_ID, Integer.toString(i));
        row.add(Document.COLUMN_SIZE, i);
        // Interleave directories and text files.
        String mimeType = (i % 2 == 0) ? Document.MIME_TYPE_DIR : "text/*";
        row.add(Document.COLUMN_MIME_TYPE, mimeType);
    }
    DirectoryResult r = new DirectoryResult();
    r.cursor = c;
    r.sortOrder = State.SORT_ORDER_SIZE;
    model.update(r);
    boolean seenAllDirs = false;
    int previousSize = Integer.MAX_VALUE;
    BitSet seen = new BitSet(ITEM_COUNT);
    // bucketed at the front of the list, sorted by size, followed by documents, sorted by size.
    for (String id : model.getModelIds()) {
        Cursor cOut = model.getItem(id);
        seen.set(cOut.getPosition());
        String mimeType = DocumentInfo.getCursorString(cOut, Document.COLUMN_MIME_TYPE);
        if (seenAllDirs) {
            assertFalse(Document.MIME_TYPE_DIR.equals(mimeType));
        } else {
            if (!Document.MIME_TYPE_DIR.equals(mimeType)) {
                seenAllDirs = true;
                // Reset the previous size seen, because documents are bucketed separately by
                // the sort.
                previousSize = Integer.MAX_VALUE;
            }
        }
        // Check sort order - descending numerical
        int size = DocumentInfo.getCursorInt(c, Document.COLUMN_SIZE);
        assertTrue(previousSize >= size);
        previousSize = size;
    }
    // Check that all items were accounted for.
    assertEquals(ITEM_COUNT, seen.cardinality());
}
Also used : DirectoryResult(com.android.documentsui.DirectoryResult) BitSet(java.util.BitSet) MergeCursor(android.database.MergeCursor) MatrixCursor(android.database.MatrixCursor) Cursor(android.database.Cursor) MatrixCursor(android.database.MatrixCursor)

Aggregations

BitSet (java.util.BitSet)2037 Test (org.junit.Test)294 ArrayList (java.util.ArrayList)224 List (java.util.List)83 HashMap (java.util.HashMap)76 Map (java.util.Map)70 IOException (java.io.IOException)60 HashSet (java.util.HashSet)52 Test (org.junit.jupiter.api.Test)47 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)45 Random (java.util.Random)42 Configuration (org.apache.hadoop.conf.Configuration)40 Path (org.apache.hadoop.fs.Path)39 ValidReadTxnList (org.apache.hadoop.hive.common.ValidReadTxnList)33 BlockNode (jadx.core.dex.nodes.BlockNode)29 File (java.io.File)27 LinkedList (java.util.LinkedList)27 RexNode (org.apache.calcite.rex.RexNode)27 ByteBuffer (java.nio.ByteBuffer)25 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)25