Package java.util

Examples of java.util.BitSet.flip()


  public void testbitsetlogic() throws Exception {
    final BitSet setallfalse = new BitSet(7);
    final BitSet invert = (BitSet) setallfalse.clone();
    assertThat(invert.length(), is(0));

    invert.flip(0, 6);
    assertThat(invert.length(), is(6));
    final BitSet set = new BitSet();
    set.set(3);
    set.set(4);
    set.set(5);
View Full Code Here


          b.fastSet(idx);
          idx = rand.nextInt(sz);
          a.clear(idx);
          b.fastClear(idx);
          idx = rand.nextInt(sz);
          a.flip(idx);
          b.fastFlip(idx);

          boolean val = b.flipAndGet(idx);
          boolean val2 = b.flipAndGet(idx);
          assertTrue(val != val2);
View Full Code Here

      // test ranges, including possible extension
      int fromIndex, toIndex;
      fromIndex = rand.nextInt(sz+80);
      toIndex = fromIndex + rand.nextInt((sz>>1)+1);
      BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex);
      OpenBitSet bb = (OpenBitSet)b.clone(); bb.flip(fromIndex,toIndex);

      doIterate(aa,bb, mode);   // a problem here is from flip or doIterate

      fromIndex = rand.nextInt(sz+80);
View Full Code Here

    byte[] expectedByteArray = new byte[1];
    byte[] outputArray = new byte[1];
    BitSet methodBitSet = new BitSet(8);

    /* 0x01 */
    methodBitSet.flip(0);
    expectedByteArray[0] = (byte)1;
    /* 0x01 & 0x00 == 0x01 */
    outputArray = HexUtil.bitsToBytes(methodBitSet,0);
    assertFalse(Arrays.equals(expectedByteArray,outputArray));
    /* 0x01 & 0x01 == 0x01 */
 
View Full Code Here

    /* 0x01 & 0x01 == 0x01 */
    outputArray = HexUtil.bitsToBytes(methodBitSet,1);
    assertTrue(Arrays.equals(expectedByteArray,outputArray));
   
    /* 0x80 */
    methodBitSet.flip(7);
    /* 0x08 */
    methodBitSet.flip(3);
    expectedByteArray[0] = (byte)128+8+1;
    /* 0x89 & 0x08 == 0x89 */
    outputArray = HexUtil.bitsToBytes(methodBitSet,3);
View Full Code Here

    assertTrue(Arrays.equals(expectedByteArray,outputArray));
   
    /* 0x80 */
    methodBitSet.flip(7);
    /* 0x08 */
    methodBitSet.flip(3);
    expectedByteArray[0] = (byte)128+8+1;
    /* 0x89 & 0x08 == 0x89 */
    outputArray = HexUtil.bitsToBytes(methodBitSet,3);
    assertFalse(Arrays.equals(expectedByteArray,outputArray));
    /* 0x89 & 0xff == 0x89 */
 
View Full Code Here

          b.fastSet(idx);
          idx = random.nextInt(sz);
          a.clear(idx);
          b.fastClear(idx);
          idx = random.nextInt(sz);
          a.flip(idx);
          b.fastFlip(idx);

          boolean val = b.flipAndGet(idx);
          boolean val2 = b.flipAndGet(idx);
          assertTrue(val != val2);
View Full Code Here

      // test ranges, including possible extension
      int fromIndex, toIndex;
      fromIndex = random.nextInt(sz+80);
      toIndex = fromIndex + random.nextInt((sz>>1)+1);
      BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex);
      OpenBitSet bb = (OpenBitSet)b.clone(); bb.flip(fromIndex,toIndex);

      doIterate(aa,bb, mode);   // a problem here is from flip or doIterate

      fromIndex = random.nextInt(sz+80);
View Full Code Here

          idx = random().nextInt(sz);
          a.clear(idx);
          b.clear(idx);
         
          idx = random().nextInt(sz);
          a.flip(idx);
          b.flip(idx, idx+1);

          idx = random().nextInt(sz);
          a.flip(idx);
          b.flip(idx, idx+1);
View Full Code Here

          idx = random().nextInt(sz);
          a.flip(idx);
          b.flip(idx, idx+1);

          idx = random().nextInt(sz);
          a.flip(idx);
          b.flip(idx, idx+1);

          boolean val2 = b.get(idx);
          boolean val = b.getAndSet(idx);
          assertTrue(val2 == val);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.