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);
      FixedBitSet bb = (FixedBitSet)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

  public void test_flipII() {
    BitSet bitset = new BitSet();
    for (int i = 0; i < 20; i++) {
      bitset.set(i);
    }
    bitset.flip(10, 10);
  }

  /**
   * @tests java.util.BitSet#get(int, int)
   */
 
View Full Code Here

    int totalCharacters = table.cardinality();
    if (totalCharacters * 2 <= DISTINCT_CHARS) {
      return precomputedPositive(totalCharacters, table, toString());
    } else {
      // TODO(user): is it worth it to worry about the last character of large matchers?
      table.flip(Character.MIN_VALUE, Character.MAX_VALUE + 1);
      int negatedCharacters = DISTINCT_CHARS - totalCharacters;
      String suffix = ".negate()";
      final String description = toString();
      String negatedDescription = description.endsWith(suffix)
          ? description.substring(0, description.length() - suffix.length())
View Full Code Here

    @GwtIncompatible("java.util.BitSet")
    @Override
    void setBits(BitSet table) {
      BitSet tmp = new BitSet();
      original.setBits(tmp);
      tmp.flip(Character.MIN_VALUE, Character.MAX_VALUE + 1);
      table.or(tmp);
    }

    @Override public CharMatcher negate() {
      return original;
View Full Code Here

    int totalCharacters = table.cardinality();
    if (totalCharacters * 2 <= DISTINCT_CHARS) {
      return precomputedPositive(totalCharacters, table, description);
    } else {
      // TODO(user): is it worth it to worry about the last character of large matchers?
      table.flip(Character.MIN_VALUE, Character.MAX_VALUE + 1);
      int negatedCharacters = DISTINCT_CHARS - totalCharacters;
      return new NegatedFastMatcher(toString(),
          precomputedPositive(negatedCharacters, table, description + ".negate()"));
    }
  }
View Full Code Here

    @GwtIncompatible("java.util.BitSet")
    @Override
    void setBits(BitSet table) {
      BitSet tmp = new BitSet();
      original.setBits(tmp);
      tmp.flip(Character.MIN_VALUE, Character.MAX_VALUE + 1);
      table.or(tmp);
    }

    @Override public CharMatcher negate() {
      return original;
View Full Code Here

        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

        bs2 = new BitSet(128);
        bs2.set(2, 20);
        bs2.set(62);
        bs2.set(121, 123);
        bs2.set(127);
        bs2.flip(0, 128);
        resultbs = bs2.get(0, bs.size());
        assertTrue("equality principle", bs2.equals(resultbs));
    }

    /**
 
View Full Code Here

        // pos1 and pos2 is in the same bitset element, boundary testing
        bs = new BitSet(16);
        bs.set(7);
        bs.set(10);
        bs.flip(7, 64);
        assertEquals("Failed to grow BitSet", 64, bs.size());
        for (int i = 0; i < 7; i++) {
            assertTrue("Shouldn't have flipped bit " + i, !bs.get(i));
        }
        assertTrue("Failed to flip bit 7", !bs.get(7));
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.