1 23 24 29 42 43 48 49 package com.sun.enterprise.util.collection; 50 51 import java.util.*; 52 53 public class DListTest { 54 55 public static void main(String [] args) 56 throws Exception 57 { 58 59 int count = 20; 60 long time=0, t1=0, t2 = 0; 61 String data = "SomeData_"; 62 63 SortedArrayListBucket bucket = new SortedArrayListBucket(); 64 for (int i=0; i<count; i+= 5) { 65 bucket.put(i, data + i); 66 } 67 68 for (int i=1; i<count; i+= 3) { 69 bucket.put(i, data + i); 70 } 71 72 for (int i=3; i<count; i+= 4) { 73 bucket.put(i, data + i); 74 } 75 76 for (int i=-23; i<count; i+= 4) { 77 bucket.put(i, data + i); 78 } 79 IntEntry entry = null; 80 Iterator iter = bucket.entryIterator(); 81 while (iter.hasNext()) { 82 entry = (IntEntry) iter.next(); 83 System.out.println(entry); 84 } 85 86 87 t1 = System.currentTimeMillis(); 88 for (int i=0; i<1000000; i++) { 89 for (int j=-25; j<25; j++) { 90 bucket.get(j); 91 } 92 } 93 t2 = System.currentTimeMillis(); 94 System.out.println("llist.remove(): " + ((t2 - t1) / 1000.0) + " seconds " + time); 95 } 97 98 } | Popular Tags |