Package java.util

Examples of java.util.BitSet.flip()


          boolean val = b.flipAndGet(idx);
          boolean val2 = b.flipAndGet(idx);
          assertTrue(val != val2);

          idx = random().nextInt(sz);
          a.flip(idx);
          b.fastFlip((long) idx);

          val = b.flipAndGet((long) idx);
          val2 = b.flipAndGet((long) 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 = 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

 
  private static void testFlip() {
    /* simple case */
    BitSet bitset = new BitSet();
    bitset.set(0);
    bitset.flip(0, 0);
    assertTrue("Should not be flipped with 0 length range", bitset.get(0));
    bitset.flip(0, 1);
    assertTrue("Should be false with range of one", !bitset.get(0));
    bitset.flip(0);
    assertTrue("Should be true again", bitset.get(0));
View Full Code Here

    /* simple case */
    BitSet bitset = new BitSet();
    bitset.set(0);
    bitset.flip(0, 0);
    assertTrue("Should not be flipped with 0 length range", bitset.get(0));
    bitset.flip(0, 1);
    assertTrue("Should be false with range of one", !bitset.get(0));
    bitset.flip(0);
    assertTrue("Should be true again", bitset.get(0));
   
    /* need to grow */
 
View Full Code Here

    bitset.set(0);
    bitset.flip(0, 0);
    assertTrue("Should not be flipped with 0 length range", bitset.get(0));
    bitset.flip(0, 1);
    assertTrue("Should be false with range of one", !bitset.get(0));
    bitset.flip(0);
    assertTrue("Should be true again", bitset.get(0));
   
    /* need to grow */
    bitset.flip(1000);
    assertTrue("1000 should be true", bitset.get(1000));
View Full Code Here

    assertTrue("Should be false with range of one", !bitset.get(0));
    bitset.flip(0);
    assertTrue("Should be true again", bitset.get(0));
   
    /* need to grow */
    bitset.flip(1000);
    assertTrue("1000 should be true", bitset.get(1000));
    assertTrue("1001 should be false", !bitset.get(1001));
    assertTrue("999 should be false", !bitset.get(999));
   
    /* Range over 2 segments */
 
View Full Code Here

    assertTrue("1000 should be true", bitset.get(1000));
    assertTrue("1001 should be false", !bitset.get(1001));
    assertTrue("999 should be false", !bitset.get(999));
   
    /* Range over 2 segments */
    bitset.flip(60, 70);
    assertTrue("59 should be false", !bitset.get(59));
    for (int i=60; i < 70; ++i) {
      assertTrue(i + " should be true", bitset.get(i));
    }
    assertTrue("70 should be false", !bitset.get(70));
View Full Code Here

    assertTrue("bit 2 should be 0", !bitset.get(2));
    assertTrue("bit 3 should be 1", bitset.get(3));
    assertCardinality(bitset, 17);

    bitset = new BitSet(70);
    bitset.flip(0, 65);
    for (int i=0; i < 65; ++i) {
      assertTrue("bit " + i + " should be set", bitset.get(i));
    }
    assertTrue("bit 65 should not be set", !bitset.get(65));
  }
View Full Code Here

    int[] t = new int[n];
    // Direction of each element's movement
    BitSet right = new BitSet(n);
    int j;
    while ((j = incFact(t)) > 0) {
      right.flip(j + 1, n);
      boolean rdir = right.get(j);
      swapWithNext.invoke(rdir ? p[j] : p[j] - 1);
      int k = p[j] + (rdir ? +1 : -1);
      int rk = r[k];
      IntCollections.swap(r, p[j], k);
View Full Code Here

        bs.set(127, 130);
        bs.set(193);
        bs.set(450);
        assertEquals("cardinality() returned wrong value", 48, bs.cardinality());

        bs.flip(0, 500);
        assertEquals("cardinality() returned wrong value", 452, bs
                .cardinality());

        bs.clear();
        assertEquals("cardinality() returned wrong value", 0, bs.cardinality());
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.