public static void main(String[] args) {
    RandomList<String> rs = new RandomList<String>();
    for (String s : ("The quick brown fox jumped over " + "the lazy brown dog").split(" "))
      rs.add(s);
    for (int i = 0; i < 11; i++) System.out.print(rs.select() + " ");

    RandomList<Integer> is = new RandomList<Integer>();
    for (Integer i : new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}) is.add(i);
    for (int i = 0; i < 11; i++) System.out.print(is.select() + " ");

    RandomList<Double> fs = new RandomList<Double>();
    for (Double f : new double[] {0, 1, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10}) fs.add(f);
    for (int i = 0; i < 11; i++) System.out.print(is.select() + " ");
  }
示例#2
0
 public static void main(String[] args) {
   RandomList<String> rs = new RandomList<String>();
   for (String s : ("lla asssa aa asa saa saa s asas").split(" ")) {
     rs.add(s);
   }
   for (int i = 0; i < rs.size(); i++) {
     System.out.println(rs.select());
   }
 }
示例#3
0
  static Collection<EndPoint> randomEndPoints(Node caller, int total) {

    Set<EndPoint> res = new HashSet<EndPoint>();

    if (seeds.isEmpty()) res.add(nodes.randomElement().endpoint);
    else
      while (res.size() < Math.min(total, seeds.size())) {
        res.add(seeds.randomElement().endpoint);
      }

    seeds.add(caller);
    return res;
  }
示例#4
0
 static void store(Node n) {
   nodes.add(n);
 }