当前位置: 首页>>代码示例>>Java>>正文


Java BitSet.valueOf方法代码示例

本文整理汇总了Java中java.util.BitSet.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java BitSet.valueOf方法的具体用法?Java BitSet.valueOf怎么用?Java BitSet.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.BitSet的用法示例。


在下文中一共展示了BitSet.valueOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DeviceStatus

import java.util.BitSet; //导入方法依赖的package包/类
public DeviceStatus(byte[] paramArrayOfByte)
{
    if (paramArrayOfByte.length == 0) {
        Timber.d("DeviceStatus: all status values were zero");
        this.riderDetected = false;
        this.riderDetectPad1 = false;
        this.riderDetectPad2 = false;
        this.icsuFault = false;
        this.icsvFault = false;
        this.charging = false;
        this.bmsCtrlComms = false;
        this.brokenCapacitor = false;
        return;
    }
    byte[] arrayOfByte = new byte[1];
    arrayOfByte[0] = paramArrayOfByte[0];
    BitSet localBitSet = BitSet.valueOf(arrayOfByte);
    this.riderDetected = localBitSet.get(0);
    this.riderDetectPad1 = localBitSet.get(1);
    this.riderDetectPad2 = localBitSet.get(2);
    this.icsuFault = localBitSet.get(3);
    this.icsvFault = localBitSet.get(4);
    this.charging = localBitSet.get(5);
    this.bmsCtrlComms = localBitSet.get(6);
    this.brokenCapacitor = localBitSet.get(7);
}
 
开发者ID:ponewheel,项目名称:android-ponewheel,代码行数:27,代码来源:DeviceStatus.java

示例2: changePositon2

import java.util.BitSet; //导入方法依赖的package包/类
@Test
public void changePositon2(){
    BitSet bitm =new BitSet(16);
    bitm.set(6);
    bitm.set(5);
    System.out.println(bitm);
    long[] lo = bitm.toLongArray();
    if(lo.length > 0){
        for(int j=0;j<lo.length - 1;j++){
            lo[j] = lo[j] >>> 1;
            lo[j] = lo[j] | (lo[j+1] << 63);
        }
        lo[lo.length-1] = lo[lo.length-1] >>> 1;
    }
    bitm = BitSet.valueOf(lo);
    System.out.println(bitm.size());
    System.out.println(bitm);
}
 
开发者ID:DStream-Storm,项目名称:DStream,代码行数:19,代码来源:PredictorHotKeyUtilTest.java

示例3: testRandomStream

import java.util.BitSet; //导入方法依赖的package包/类
@Test
public void testRandomStream() {
    final int size = 1024 * 1024;
    final int[] seeds = {
            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
            43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    final byte[] bytes = new byte[size];
    for (int seed : seeds) {
        final Random random = new Random(seed);
        random.nextBytes(bytes);
        final BitSet bitSet = BitSet.valueOf(bytes);
        final int cardinality = bitSet.cardinality();
        final IntStream stream = bitSet.stream();
        final int[] array = stream.toArray();
        assertEquals(array.length, cardinality);
        int nextSetBit = -1;
        for (int i=0; i < cardinality; i++) {
            nextSetBit = bitSet.nextSetBit(nextSetBit + 1);
            assertEquals(array[i], nextSetBit);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:BitSetStreamTest.java

示例4: testRandomStream

import java.util.BitSet; //导入方法依赖的package包/类
@Test
public void testRandomStream() {
    final int size = 1024 * 1024;
    final int[] seeds = {
            2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41,
            43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
    final byte[] bytes = new byte[size];
    for (int seed : seeds) {
        final Random random = new Random(seed);
        random.nextBytes(bytes);

        BitSet bitSet = BitSet.valueOf(bytes);
        testBitSetContents(bitSet, bitSet.stream().toArray());
        testBitSetContents(bitSet, bitSet.stream().parallel().toArray());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:BitSetStreamTest.java

示例5: read

import java.util.BitSet; //导入方法依赖的package包/类
@Override
public ChunkPositionSet read(DataInputStream stream) throws IOException {
    long[] data = new long[stream.readShort()];
    for (int i = 0; i < data.length; i++) {
        data[i] = stream.readLong();
    }
    return new ChunkPositionSet(BitSet.valueOf(data));
}
 
开发者ID:kenzierocks,项目名称:HardVox,代码行数:9,代码来源:ChunkPositionSet.java

示例6: testNot

import java.util.BitSet; //导入方法依赖的package包/类
@Test
public void testNot() {
  BloomFilter bf = new BloomFilter(8, 1, Hash.JENKINS_HASH);
  bf.bits = BitSet.valueOf(new byte[] { (byte) 0x95 });
  BitSet origBitSet = (BitSet) bf.bits.clone();
  bf.not();
  assertFalse("BloomFilter#not should have inverted all bits",
              bf.bits.intersects(origBitSet));
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:10,代码来源:TestBloomFilters.java

示例7: SynopsisHashMapAllDump

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * Hot word attenuation in hot words
 */
public void SynopsisHashMapAllDump(DumpRemoveHandler dumpRemoveHandler) {
    int dumpsize = (int) (1 / Threshold_p);
    dumpKeyCount++;
    if (dumpKeyCount == dumpsize) {
        //dump all key
        Iterator<Map.Entry<String, BitSet>> iterator = predictHotKeyMap.newEntryIterator();
        while (iterator.hasNext()){
            Map.Entry<String, BitSet> next = iterator.next();
            BitSet bitm = next.getValue();
            String key = next.getKey();
            if(key!=null){
                long[] lo = bitm.toLongArray();
                if(lo.length > 0){
                    for(int j=0;j<lo.length - 1;j++){
                        lo[j] = lo[j] >>> 1;
                        lo[j] = lo[j] | (lo[j+1] << 63);
                    }
                    lo[lo.length-1] = lo[lo.length-1] >>> 1;
                }
                bitm = BitSet.valueOf(lo);
                if (bitm.isEmpty()) {
                    iterator.remove();
                    dumpRemoveHandler.dumpRemove(key);
                }else
                    next.setValue(bitm);
            }
        }
        dumpKeyCount = 0;
    }
}
 
开发者ID:DStream-Storm,项目名称:DStream,代码行数:34,代码来源:PredictorHotKeyUtil.java

示例8: SynopsisHashMapRandomDump

import java.util.BitSet; //导入方法依赖的package包/类
/**
 * New Words in Hot Words Random Dump
 */
public void SynopsisHashMapRandomDump(DumpRemoveHandler dumpRemoveHandler) {
    int size=predictHotKeyMap.size;
    long startTimeSystemTime=System.currentTimeMillis();
    Iterator<Map.Entry<String, BitSet>> iterator = predictHotKeyMap.newEntryIterator();
    while (iterator.hasNext()){
        Map.Entry<String, BitSet> next = iterator.next();
        if (random.nextDouble()> Threshold_p){
            continue;
        }
        BitSet bitm = next.getValue();
        String key = next.getKey();
        if(key!=null){
            long[] lo = bitm.toLongArray();
            if(lo.length > 0){
                for(int j=0;j<lo.length - 1;j++){
                    lo[j] = lo[j] >>> 1;
                    lo[j] = lo[j] | (lo[j+1] << 63);
                }
                lo[lo.length-1] = lo[lo.length-1] >>> 1;
            }
            bitm = BitSet.valueOf(lo);
            if (bitm.isEmpty()) {
                iterator.remove();
                dumpRemoveHandler.dumpRemove(key);
            }else
                next.setValue(bitm);
        }
    }
}
 
开发者ID:DStream-Storm,项目名称:DStream,代码行数:33,代码来源:PredictorHotKeyUtil.java

示例9: decodeImpl

import java.util.BitSet; //导入方法依赖的package包/类
@Override
  protected Codex<V, E> decodeImpl(ByteBuffer pData) {
    int length = pData.remaining();
    int initPos = pData.position();

    // reference BitSet.toByteArray() for this calculation
    byte[] bsarray = new byte[mBitSetByteLength];
    pData.get(bsarray);
    BitSet hash = BitSet.valueOf(bsarray);
    hash.set(mLength);
    mLog.debug("Bitset: " + Arrays.toString(bsarray));

    // Usually the offset is 0, but with UDP connections it's non-zero.
    pData.position(bsarray.length + initPos + pData.arrayOffset());
    V[] decoded = mProps.generateEmptyArray((length - bsarray.length) / mProps.sizeOfSingle(), false);
    for(int i = 0; i < decoded.length; i++) {
      decoded[i] = mProps.decodeSingle(pData);
    }

//    Codex<V, E> result = new Codex<V, E>(this);
    Codex<V, E> result = new Codex<V, E>(getDefaultValue(), super.getEnum());
    int dataidx = 0;
    for(int e = 0; e < mLength; e++) {
      if(hash.get(e)) {
        result.set(e, decoded[dataidx]);
        dataidx++;
      }
    }
    return result;
  }
 
开发者ID:flybotix,项目名称:highfrequencyrobots,代码行数:31,代码来源:CompressedEncoder.java

示例10: decodeImpl

import java.util.BitSet; //导入方法依赖的package包/类
@Override
  protected Codex<Boolean, E> decodeImpl(ByteBuffer pData) {
    // reference BitSet.toByteArray() for this calculation
    byte[] bsarray = new byte[getBufferSizeInBytes()];
    pData.get(bsarray);
    BitSet hash = BitSet.valueOf(bsarray);
    hash.set(mLength);
//    Codex<Boolean, E> result = new Codex<>(this);
    Codex<Boolean, E> result = new Codex<>(super.getEnum());
    for(int i = 0; i < mLength; i++) {
      result.set(i, hash.get(i));
    }
    return result;
  }
 
开发者ID:flybotix,项目名称:highfrequencyrobots,代码行数:15,代码来源:BitEncoder.java

示例11: readRecordHeader

import java.util.BitSet; //导入方法依赖的package包/类
private BitSet readRecordHeader() throws IOException {
    byte[] header = in.readByteArray();
    BitSet bitSet = BitSet.valueOf(header);
    return bitSet;
}
 
开发者ID:atlascon,项目名称:travny,代码行数:6,代码来源:BinaryReader.java

示例12: BloomFilter

import java.util.BitSet; //导入方法依赖的package包/类
public BloomFilter(byte[] bloomMask) {
    if (bloomMask.length != BLOOM_BYTES) throw new RuntimeException("Invalid bloom filter array length: " + bloomMask.length);
    mask = BitSet.valueOf(bloomMask);
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:5,代码来源:BloomFilter.java

示例13: checkBitSet

import java.util.BitSet; //导入方法依赖的package包/类
private void checkBitSet(byte[] array) {
    BitSet bitSet = BitSet.valueOf(array);
    assertArrayEquals(array, Bytes.from(bitSet).array());
    assertEquals(bitSet, Bytes.from(bitSet).toBitSet());
}
 
开发者ID:patrickfav,项目名称:bytes-java,代码行数:6,代码来源:BytesConstructorTests.java

示例14: FLG

import java.util.BitSet; //导入方法依赖的package包/类
private FLG(int version, byte b) {
  this.bitSet = BitSet.valueOf(new byte[]{b});
  this.version = version;
  validate();
}
 
开发者ID:CheYulin,项目名称:OpenMessageShaping,代码行数:6,代码来源:LZ4FrameOutputStream.java

示例15: next

import java.util.BitSet; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public BitSet next() {
    BitSet res = BitSet.valueOf(new long[] {i});
    i++;
    return res;
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:7,代码来源:CategoricalFeatureProcessor.java


注:本文中的java.util.BitSet.valueOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。