Advertisement
canezzy

writeOutFile

Apr 3rd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include "WriteOutFile.h"
  2.  
  3. extern concurrent_hash_map<unsigned char, unsigned int> couterValues;
  4.  
  5. RetVal WriteOutFile(string fileName)
  6. {
  7.     ofstream outputFile(fileName.c_str());
  8.  
  9.     if (outputFile.is_open() == false)
  10.     {
  11.         cout << "WriteOutFile: Output file " << fileName << " could not be opened." << endl;
  12.         return RET_ERROR;
  13.     }
  14.  
  15.     for(int i=0; i<256; i++)
  16.     {
  17.         concurrent_hash_map<unsigned char, unsigned int>::accessor a;
  18.         if(couterValues.find(a, i))
  19.         {
  20.             outputFile << i << ":\t" << a->second << endl;
  21.         }
  22.     }
  23.  
  24.     outputFile.close();
  25.  
  26.     return RET_OK;
  27. }
  28.  
  29.  
  30.  
  31. -----------------------------------------
  32.  
  33.  
  34. #ifndef _WRITE_OUT_FILE_H_
  35. #define _WRITE_OUT_FILE_H_
  36.  
  37. #include <iostream>
  38. #include <fstream>
  39. #include <string>
  40. #include <queue>
  41. #include <tbb/concurrent_hash_map.h>
  42. #include "defines.h"
  43.  
  44. using namespace std;
  45. using namespace tbb;
  46.  
  47. RetVal WriteOutFile(string fileName);
  48.  
  49. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement