Example #1
0
  private static void fill(String s) {
    Matcher match = numbers.matcher(s);

    int size, min, max;
    try {
      match.find();
      size = Integer.valueOf(match.group());
      match.find();
      min = Integer.valueOf(match.group());
      match.find();
      max = Integer.valueOf(match.group());
    } catch (Exception ex) {
      System.out.println("Unable to parse arguments.");
      return;
    }
    Integer[] added = new Integer[size];
    for (int i = 0; i < size; i++) {
      added[i] = random(min, max);
      list.put(added[i]);
    }
    System.out.println("New size: " + list.size());
  }
  public static void main(String[] args) {
    SkipList list = new SkipList();
    //		for (int i = 0; i < 5; i++) {
    //			int insert = (int)(Math.random()*100);
    //
    //			System.out.println("ADDED " + list.add(insert));
    //
    //
    //		}
    //		System.out.println("FINISHED ADDING");
    //		list.add(10);
    //		list.add(1);
    //		System.out.println(list.contains(10));
    //		System.out.println(list.contains(1));
    //		list.remove(10);
    //		list.remove(1);
    //		System.out.println(list.contains(10));
    //		System.out.println(list.contains(1));

    long c = System.currentTimeMillis();
    for (int x = 0; x < 1000000; x++) {
      int ran = (int) (Math.random() * (1 << 30)) + 5;
      list.add(ran);
    }
    // t.traverse(root);
    list.add(1);
    System.out.println(list.contains(1));
    System.out.println(list.contains(2));
    list.remove(1);
    System.out.println(list.contains(1));
    System.out.println(System.currentTimeMillis() - c);

    //		Node currentNode = list.head;
    //		for (int j = 0; j <= list.maxLevel; j++) {
    //			print(currentNode);
    //			currentNode = currentNode.down;
    //		}
  }
Example #3
0
 private static void put(String s) {
   Integer i = parse(s);
   list.put(i);
   System.out.println("Put: " + i + " (Size: " + list.size() + ")");
 }
Example #4
0
 private static void contains(String s) {
   Integer i = parse(s);
   if (i != null) {
     System.out.println("Contains: " + list.contains(i));
   }
 }
Example #5
0
 private static void last() {
   System.out.println(list.last());
 }
Example #6
0
 private static void first() {
   System.out.println(list.first());
 }
Example #7
0
 private static void print() {
   System.out.println(list.toString());
 }
Example #8
0
 private static void dataSet() {
   System.out.println("DataSet: " + list.dataSet().toString());
 }
Example #9
0
 private static void clear() {
   list.clear();
   System.out.println("Cleared (Size: " + list.size() + ")");
 }
Example #10
0
 private static void size() {
   System.out.println("Size: " + list.size());
 }
Example #11
0
 private static void get(String s) {
   Integer i = parse(s);
   System.out.println("Get: " + list.get(i));
 }
Example #12
0
 private static void remove(String s) {
   Integer i = parse(s);
   System.out.println("Remove: " + list.remove(i) + " (Size: " + list.size() + ")");
 }