Package java.util

Examples of java.util.BitSet.flip()


          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


      // test ranges, including possible extension
      int fromIndex, toIndex;
      fromIndex = random().nextInt(sz/2);
      toIndex = fromIndex + random().nextInt(sz - fromIndex);
      BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex);
      LongBitSet bb = b.clone(); bb.flip(fromIndex,toIndex);

      fromIndex = random().nextInt(sz/2);
      toIndex = fromIndex + random().nextInt(sz - fromIndex);
      aa = (BitSet)a.clone(); aa.clear(fromIndex,toIndex);
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

      // test ranges, including possible extension
      int fromIndex, toIndex;
      fromIndex = random().nextInt(sz/2);
      toIndex = fromIndex + random().nextInt(sz - fromIndex);
      BitSet aa = (BitSet)a.clone(); aa.flip(fromIndex,toIndex);
      FixedBitSet bb = b.clone(); bb.flip(fromIndex,toIndex);

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

      fromIndex = random().nextInt(sz/2);
View Full Code Here

    }

    BitSet singleBitDiff( BitSet x, BitSet y ) {
        BitSet t = new BitSet( x.length() );
        t.or( x );
        t.flip(0, t.size());
        t.and( y );

        switch ( t.cardinality() ) {
            case 0 : return t;
            case 1 : return t;
View Full Code Here

    }

    BitSet singleBitDiff( BitSet x, BitSet y ) {
        BitSet t = new BitSet();
        t.or( x );
        t.flip(0, t.size());
        t.and( y );

        switch ( t.cardinality() ) {
            case 0 : return t;
            case 1 : return t;
View Full Code Here

 
  public void test1(TestHarness harness)
  {
    harness.checkPoint("(int)");
    BitSet bs = new BitSet(17);
    bs.flip(11);
    harness.check(bs.nextSetBit(0), 11);
   
    boolean pass = false;
    try
    {
View Full Code Here

    harness.check(bs.nextSetBit(0), 11);
   
    boolean pass = false;
    try
    {
      bs.flip(-1);
    }
    catch (IndexOutOfBoundsException e)
    {
      pass = true;
    }
View Full Code Here

 
  public void test2(TestHarness harness)
  {
    harness.checkPoint("(int, int)");
    BitSet bs = new BitSet(21);
    bs.flip(3, 5);
    harness.check(!bs.get(2));
    harness.check(bs.get(3));
    harness.check(bs.get(4));
    harness.check(!bs.get(5));
   
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.