Package java.util

Examples of java.util.BitSet.flip()


        } catch (IndexOutOfBoundsException e) {
            // Correct behaviour
        }

        // Try setting a bit on a 64 boundary
        bs.flip(128);
        assertEquals("Failed to grow BitSet", 192, bs.size());
        assertTrue("Failed to flip bit", bs.get(128));

        bs = new BitSet(64);
        for (int i = bs.size(); --i >= 0;) {
View Full Code Here


        assertEquals("Failed to grow BitSet", 192, bs.size());
        assertTrue("Failed to flip bit", bs.get(128));

        bs = new BitSet(64);
        for (int i = bs.size(); --i >= 0;) {
            bs.flip(i);
            assertTrue("Test1: Incorrectly flipped bit" + i, bs.get(i));
            assertTrue("Incorrect length", bs.length() == (i + 1));
            for (int j = bs.size(); --j > i;) {
                assertTrue("Test2: Incorrectly flipped bit" + j, !bs.get(j));
            }
View Full Code Here

                assertTrue("Test2: Incorrectly flipped bit" + j, !bs.get(j));
            }
            for (int j = i; --j >= 0;) {
                assertTrue("Test3: Incorrectly flipped bit" + j, !bs.get(j));
            }
            bs.flip(i);
        }

        BitSet bs0 = new BitSet(0);
        assertEquals("Test1: Wrong size", 0, bs0.size());
        assertEquals("Test1: Wrong length", 0, bs0.length());
View Full Code Here

        BitSet bs0 = new BitSet(0);
        assertEquals("Test1: Wrong size", 0, bs0.size());
        assertEquals("Test1: Wrong length", 0, bs0.length());

        bs0.flip(0);
        assertEquals("Test2: Wrong size", 64, bs0.size());
        assertEquals("Test2: Wrong length", 1, bs0.length());

        bs0.flip(63);
        assertEquals("Test3: Wrong size", 64, bs0.size());
View Full Code Here

        bs0.flip(0);
        assertEquals("Test2: Wrong size", 64, bs0.size());
        assertEquals("Test2: Wrong length", 1, bs0.length());

        bs0.flip(63);
        assertEquals("Test3: Wrong size", 64, bs0.size());
        assertEquals("Test3: Wrong length", 64, bs0.length());

        eightbs.flip(7);
        assertTrue("Failed to flip bit 7", !eightbs.get(7));
View Full Code Here

        // Test for method void java.util.BitSet.flip(int, int)
        // pos1 and pos2 are in the same bitset element
        BitSet bs = new BitSet(16);
        bs.set(7);
        bs.set(10);
        bs.flip(7, 11);
        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));
        assertTrue("Failed to flip bit 8", bs.get(8));
View Full Code Here

     * @see org.apache.lucene.search.Filter#bits(org.apache.lucene.index.IndexReader)
     */
    @Override
    public BitSet bits(IndexReader reader) throws IOException {
        BitSet bitSet = new BitSet(reader.maxDoc());
        bitSet.flip(0, reader.maxDoc()); // set all documents 
        int[] docs = new int[1];
        int[] freq = new int[1];
        for (String id : this.entyIds) {
            if (id != null) {
                TermDocs termDocs = reader.termDocs(new Term(
View Full Code Here

            if (id != null) {
                TermDocs termDocs = reader.termDocs(new Term(
                        this.searchField, id));
                int count = termDocs.read(docs, freq);
                if (count == 1)
                    bitSet.flip(docs[0]);
            }
        }
        return bitSet;
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;
      String suffix = ".negate()";
      String negatedDescription = description.endsWith(suffix)
          ? description.substring(0, description.length() - suffix.length())
          : description + suffix;
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

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.