bbb

import java.util.Stack;
import java.util.TreeMap;


public class Test14 {
public static void main(String[] args){
 Stack<Integer> stack=new Stack<Integer>();

 int i=0;
 final int NUM=10000000;
 long date1=System.currentTimeMillis();
 while(i++<NUM)
 stack.add(i);
 System.out.println("stack add()"+(System.currentTimeMillis()-date1));
 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
 stack.peek();
 System.out.println("stack peek()"+(System.currentTimeMillis()-date1));
 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
  stack.pop();
 System.out.println("stack pop()"+(System.currentTimeMillis()-date1));
 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
  stack.size();
 System.out.println("stack size()"+(System.currentTimeMillis()-date1));
 
// i=0;
// TreeMap<Integer,Integer> map=new TreeMap<Integer,Integer>();
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  map.put(i, i);
// System.out.println("treeMap put() "+(System.currentTimeMillis()-date1));
 
 AVLTree<Integer> avl=new AVLTree<Integer>();
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
   avl.push(Integer.valueOf(i));
 System.out.println("avl push()"+(System.currentTimeMillis()-date1));
 

 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
   avl.peekMinimum();
 System.out.println("avl getMed()"+(System.currentTimeMillis()-date1));
 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
   avl.peekMaximum();
 System.out.println("avl getMax()"+(System.currentTimeMillis()-date1));
 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
   avl.peekMedian();
 System.out.println("avl getMin()"+(System.currentTimeMillis()-date1));
 
 i=0;
 date1=System.currentTimeMillis();
 while(i++<NUM)
   avl.pop();
 System.out.println("avl delete()"+(System.currentTimeMillis()-date1));
 
 
// ------------------------------------------------------------------------------this is my implemtaion
// Test15 myStack=new Test15();
// i=0;
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  {myStack.push(i);
//  if(i%10000==0)
//   System.out.println(i);
//  }
// System.out.println("myStack push()"+(System.currentTimeMillis()-date1));
// 
// i=0;
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  myStack.peek();
// System.out.println("myStack peek()"+(System.currentTimeMillis()-date1));
// 
// i=0;
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  myStack.pop();
// System.out.println("myStack pop()"+(System.currentTimeMillis()-date1));
// 
// i=0;
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  myStack.size();
// System.out.println("myStack size()"+(System.currentTimeMillis()-date1));
//
// i=0;
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  myStack.max();
// System.out.println("myStack max()"+(System.currentTimeMillis()-date1));
// 
// i=0;
// date1=System.currentTimeMillis();
// while(i++<NUM)
//  myStack.min();
// System.out.println("myStack min()"+(System.currentTimeMillis()-date1));


}

}

posted on 2011-09-26 22:03  梦逆飞  阅读(447)  评论(0编辑  收藏  举报

导航