Example #1
0
 public static void main(String[] args) {
   RandomList r = new RandomList(RandomList.FillType.fillInt, 10);
   List l = r.fill();
   sort_az(l);
   System.out.println(l);
   sort_za(l);
   System.out.println(l);
 }
Example #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());
   }
 }
Example #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;
  }
Example #4
0
 static void dispose(Node n) {
   if (n != null) {
     seeds.remove(n);
     nodes.remove(n);
     n.dispose();
   }
 }
  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() + " ");
  }
Example #6
0
 static Node randomNode() {
   return nodes.randomElement();
 }
Example #7
0
 static int size() {
   return nodes.size();
 }
Example #8
0
 static void store(Node n) {
   nodes.add(n);
 }