C++ 用bitmap实现无重复大文件的排序

BitMap的实现在上一篇博文中
#include "BitMap.h"
#include <ctime>
int main()
{
     double start = clock();
     BitMap a = BitMap(9999999);
     freopen("E:\\phoneNum.txt","r",stdin);
  //导致cin有许多额外的开销,下面取消和stdin的同步,以加快读取速度
     std::ios::sync_with_stdio(false);
     int tmp;
     for(unsigned i = 0; i < 9999999; i++){
        cin >> tmp;
        if(tmp)
            a.setBit(tmp);
     }
     for(unsigned i = 1; i <= 9999999; i++){
        if(a.getBit(i))
            cout << i << endl;
     }
     printf("%.3lf\n",((double)clock() - start)/CLOCKS_PER_SEC);
     return 0;
}
posted @ 2014-05-14 10:14  Tympani  阅读(246)  评论(0)    收藏  举报