Package java.util

Examples of java.util.BitSet.cardinality()


        }
        LOG.debug("split=" + split + " count=" + count);
      } finally {
        reader.close();
      }
      assertEquals("Some keys in no partition.", length, bits.cardinality());
    }
  }

  private static class Range {
    private final int start;
View Full Code Here


      threadArray[i].start();
    }
    for( int i = 0; i < threadArray.length; ++i ) {
      threadArray[i].join();
    }
    assertEquals("some threads failed!", N_THREADS,success.cardinality());
  }
 
  // counting collector that can slow down at collect().
  private class MyHitCollector extends Collector {
    private final BitSet bits = new BitSet();
View Full Code Here

        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;
            default: return new BitSet();
        }
    }
View Full Code Here

        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;
            default: return new BitSet();
        }
    }
View Full Code Here

      // With 20 virtual servers and the used algorithm, we should
      // expect at least five-fold acceleration.
      assertTrue("Parallel work is broken :" + acceleration, acceleration > 500);

      assertEquals("Not all tasks served", served.cardinality(), 0);

      // 2. Testing the Request methods.
      Request rq =
        objects [ 0 ]._create_request(null, "sleep_and_return",
                                      orb.create_list(1), null
View Full Code Here

    harness.check(s1.get(1), true);
    harness.check(s1.get(2), true);
    harness.check(s1.get(3), false);

    BitSet s2 = o.get(60, 69);
    harness.check(s2.cardinality(), 2);
    harness.check(s2.get(2), false);
    harness.check(s2.get(3), true);
    harness.check(s2.get(4), true);
    harness.check(s2.get(5), false);
  }
View Full Code Here

    o.set(2);
    o.set(63);
    o.set(64);
     
    BitSet s1 = o.get(0, 9);
    harness.check(s1.cardinality(), 2);
    harness.check(s1.get(0), false);
    harness.check(s1.get(1), true);
    harness.check(s1.get(2), true);
    harness.check(s1.get(3), false);
View Full Code Here

            }
        }
        //Check if empty then create a new copy
        if (bits.isEmpty()) {
            temp = copyOf(values, begin, length); // Nothing removed, just copy
        } else if(bits.cardinality() == length){
            temp = new double[0];                 // All removed, just empty
        }else {                                   // Some removable, so new
            temp = new double[length - bits.cardinality()];
            int start = begin;  //start index from source array (i.e values)
            int dest = 0;       //dest index in destination array(i.e temp)
View Full Code Here

        if (bits.isEmpty()) {
            temp = copyOf(values, begin, length); // Nothing removed, just copy
        } else if(bits.cardinality() == length){
            temp = new double[0];                 // All removed, just empty
        }else {                                   // Some removable, so new
            temp = new double[length - bits.cardinality()];
            int start = begin;  //start index from source array (i.e values)
            int dest = 0;       //dest index in destination array(i.e temp)
            int nextOne = -1;   //nextOne is the index of bit set of next one
            int bitSetPtr = 0//bitSetPtr is start index pointer of bitset
            while ((nextOne = bits.nextSetBit(bitSetPtr)) != -1) {
View Full Code Here

                        break;
                    }
                }
            }
        }
        if (removedIndices.cardinality() == 0) {
            return indices;
        } else {
            int[] newIndices = new int[indices.size() - removedIndices.cardinality()];
            int counter = 0;
            for (int i = 0; i < indices.size(); i++) {
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.