skip_test.c
资源名称:leda.tar.gz [点击查看]
上传用户:gzelex
上传日期:2007-01-07
资源大小:707k
文件大小:1k
源码类别:
数值算法/人工智能
开发平台:
MultiPlatform
- #include <LEDA/impl/skiplist.h>
- #include <LEDA/stream.h>
- main(int argc, char** argv)
- {
- string_istream args(argc-1,argv+1);
- float p0 = 0.20;
- float p1 = 0.60;
- int N = 10000;
- args >> p0 >> p1 >> N;
- cout << string("# keys = %d p0 = %f p1 = %fn",N,p0,p1);
- newline;
- GenPtr* RAND = new GenPtr[N];
- rand_int.set_seed(12345);
- for(int i=0; i<N; i++) RAND[i] = (GenPtr)rand_int(0,MAXINT-1);
- float T0 = used_time();
- float T = used_time();
- newline;
- cout << " insert lookup delete totaln";
- newline;
- for(float prob = p0; prob < p1; prob += 0.01)
- {
- skiplist skip(prob);
- cout << string("p = %4.2f ",prob);
- cout.flush();
- int i;
- for(i=0; i<N; i++) skip.insert(RAND[i],0);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- for(i=0; i<N; i++) skip.lookup(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout.flush();
- for(i=0; i<N; i++) skip.del(RAND[i]);
- cout << string("%10.2f",used_time(T));
- cout << string("%10.2f",used_time(T0));
- newline;
- }
- return 0;
- }