Examples of nextBoolean()


Examples of java.util.Random.nextBoolean()

        Random random = new Random(1);
        String s = "'\"$/-* \n";
        for (int i = 0; i < 200; i++) {
            StringBuilder buffQuoted = new StringBuilder();
            StringBuilder buffRaw = new StringBuilder();
            if (random.nextBoolean()) {
                buffQuoted.append("'");
                for (int j = 0; j < 10; j++) {
                    char c = s.charAt(random.nextInt(s.length()));
                    if (c == '\'') {
                        buffQuoted.append('\'');
View Full Code Here

Examples of java.util.Random.nextBoolean()

        HashMap<Long, Integer> map = New.hashMap();
        for (int i = 0; i < 1000; i++) {
            long key = rand.nextInt(10) * 1000000000L;
            Integer r = map.get(key);
            int result = r == null ? 0 : (int) r;
            if (rand.nextBoolean()) {
                prepSelect.setLong(1, key);
                ResultSet rs = prepSelect.executeQuery();
                rs.next();
                assertEquals(result, rs.getInt(1));
            } else {
View Full Code Here

Examples of java.util.Random.nextBoolean()

                prepSelect.setLong(1, key);
                ResultSet rs = prepSelect.executeQuery();
                rs.next();
                assertEquals(result, rs.getInt(1));
            } else {
                if (rand.nextBoolean()) {
                    prepInsert.setLong(1, key);
                    prepInsert.setInt(2, rand.nextInt());
                    prepInsert.execute();
                    map.put(key, result + 1);
                } else {
View Full Code Here

Examples of java.util.Random.nextBoolean()

         return null;

      Random random = new Random(System.currentTimeMillis());
      ClientProperty ret = new ClientProperty(this.colName, null, null);
      if (sqlType == Types.BOOLEAN) {
         ret.setValue("" + random.nextBoolean());
         return ret;
      }
      if (sqlType == Types.CHAR)
         return nextChar(random, 1);
      if (sqlType == Types.BINARY)
View Full Code Here

Examples of java.util.Random.nextBoolean()

   public void process() throws Exception {
      if (hosts == null)
         return;
      Random random = new Random();
      for (int i=0; i < hosts.length; i++) {
         if (random.nextBoolean())
            continue;
         global.getProperty().set("filewatcher.test.counter", "" + (++counter));
         global.getProperty().set("filewatcher.test.hostname", hosts[i]);
         String tmp = replace(content);
         if (tmp != null) {
View Full Code Here

Examples of java.util.Random.nextBoolean()

      float[] orig = new float[16*1024*1024];
      MutableSparseFloatArray arr = new MutableSparseFloatArray(new float[orig.length]);
     
      for (int i = 0; i < 32*1024; i++) {
        int idx = r.nextInt(orig.length);
        if (r.nextBoolean()) {
          assertTrue("orig "+orig[idx]+" not the same as arr "+arr.get(idx)+" at idx="+idx, orig[idx] == arr.get(idx));
        } else {
          float val = r.nextFloat();
          orig[idx] = val;
          arr.set(idx, val);
View Full Code Here

Examples of java.util.Random.nextBoolean()

  testBooleanArray(new boolean[] { false });
  testBooleanArray(new boolean[] { true, false });
  Random rand = new Random();
  boolean[] v = new boolean[100];
  for (int i = 0; i < v.length; ++i) {
      v[i] = rand.nextBoolean();
  }
  testBooleanArray(v);
    }

    public void testBooleanArray(boolean[] v) throws Exception {
View Full Code Here

Examples of java.util.Random.nextBoolean()

    {
        Random r = new Random(count);
        float[] result = new float[count];
        for (int i = 0; i < count; ++i) {
            float f = r.nextFloat();
            result[i] = r.nextBoolean() ? -f : f;
        }
        return result;
    }

    private double[] doubleArray(int count)
View Full Code Here

Examples of java.util.Random.nextBoolean()

    {
        Random r = new Random(count);
        double[] result = new double[count];
        for (int i = 0; i < count; ++i) {
            double d = r.nextDouble();
            result[i] = r.nextBoolean() ? -d : d;
        }
        return result;
    }

    private String buildDoc(Object dataArray, boolean addNoise)
View Full Code Here

Examples of java.util.Random.nextBoolean()

        Random r = new Random(Array.get(dataArray, 0).hashCode());
        for (int i = 0; i < len; ++i) {
            Object value = Array.get(dataArray, i).toString();
            sb.append(value);
            // Let's add 25% of time
            if (addNoise && r.nextBoolean() && r.nextBoolean()) {
                if (r.nextBoolean()) {
                    sb.append("<!-- comment: "+value+" -->");
                } else {
                    sb.append("<?pi "+value+"?>");
                }
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.