]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/sort/example/randomgen.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / sort / example / randomgen.cpp
index 661435ecf29059eeb5d67b2907ef83d7d78a5f8a..aaa1f8505a5a878b36f0d0a36147c89c08e7b40c 100644 (file)
@@ -1,69 +1,69 @@
-// flexible random number generator providing multiple distributions.\r
-//\r
-//  Copyright Steven Ross 2009-2014.\r
-//\r
-// Distributed under the Boost Software License, Version 1.0.\r
-//    (See accompanying file LICENSE_1_0.txt or copy at\r
-//          http://www.boost.org/LICENSE_1_0.txt)\r
-\r
-//  See http://www.boost.org/libs/sort for library home page.\r
-\r
-#include <boost/random/mersenne_twister.hpp>\r
-#include <boost/random/uniform_int_distribution.hpp>\r
-#include <stdio.h>\r
-#include "stdlib.h"\r
-#include <fstream>\r
-#include <iostream>\r
-using namespace boost;\r
-\r
-int main(int argc, const char ** argv) {\r
-  random::mt19937 generator;\r
-  random::uniform_int_distribution<unsigned> distribution;\r
-  //defaults\r
-  unsigned high_shift = 16;\r
-  unsigned low_shift = 16;\r
-  unsigned count = 1000000;\r
-  //Reading in user arguments\r
-  if (argc > 1)\r
-    high_shift = atoi(argv[1]);\r
-  if (argc > 2)\r
-    low_shift = atoi(argv[2]);\r
-  if (argc > 3)\r
-    count = atoi(argv[3]);\r
-  if (high_shift > 16)\r
-    high_shift = 16;\r
-  if (low_shift > 16)\r
-    low_shift = 16;\r
-  std::ofstream ofile;\r
-  ofile.open("input.txt", std::ios_base::out | std::ios_base::binary |\r
-             std::ios_base::trunc);\r
-  if (ofile.bad()) {\r
-    printf("could not open input.txt for writing!\n");\r
-    return 1;\r
-  }\r
-  //buffering file output for speed\r
-  unsigned uDivideFactor = 1000;\r
-  //Skipping buffering for small files\r
-  if (count < uDivideFactor * 100)\r
-    uDivideFactor = count;\r
-  unsigned * pNumbers = static_cast<unsigned *>(malloc(uDivideFactor * \r
-                                                       sizeof(unsigned)));\r
-  //Generating semirandom numbers\r
-  unsigned mask = 0;\r
-  unsigned one = 1;\r
-  for (unsigned u = 0; u < low_shift; ++u) {\r
-    mask += one << u;\r
-  }\r
-  for (unsigned u = 0; u < high_shift; ++u) {\r
-    mask += one << (16 + u);\r
-  }\r
-  for (unsigned u = 0; u < count/uDivideFactor; ++u) {\r
-    unsigned i = 0;\r
-    for (; i< uDivideFactor; ++i) {\r
-      pNumbers[i] = distribution(generator) & mask;\r
-    }\r
-    ofile.write(reinterpret_cast<char *>(pNumbers), uDivideFactor * 4 );\r
-  }\r
-  ofile.close();\r
-  return 0;\r
-}\r
+// flexible random number generator providing multiple distributions.
+//
+//  Copyright Steven Ross 2009-2014.
+//
+// Distributed under the Boost Software License, Version 1.0.
+//    (See accompanying file LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+
+//  See http://www.boost.org/libs/sort for library home page.
+
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/uniform_int_distribution.hpp>
+#include <stdio.h>
+#include "stdlib.h"
+#include <fstream>
+#include <iostream>
+using namespace boost;
+
+int main(int argc, const char ** argv) {
+  random::mt19937 generator;
+  random::uniform_int_distribution<unsigned> distribution;
+  //defaults
+  unsigned high_shift = 16;
+  unsigned low_shift = 16;
+  unsigned count = 1000000;
+  //Reading in user arguments
+  if (argc > 1)
+    high_shift = atoi(argv[1]);
+  if (argc > 2)
+    low_shift = atoi(argv[2]);
+  if (argc > 3)
+    count = atoi(argv[3]);
+  if (high_shift > 16)
+    high_shift = 16;
+  if (low_shift > 16)
+    low_shift = 16;
+  std::ofstream ofile;
+  ofile.open("input.txt", std::ios_base::out | std::ios_base::binary |
+             std::ios_base::trunc);
+  if (ofile.bad()) {
+    printf("could not open input.txt for writing!\n");
+    return 1;
+  }
+  //buffering file output for speed
+  unsigned uDivideFactor = 1000;
+  //Skipping buffering for small files
+  if (count < uDivideFactor * 100)
+    uDivideFactor = count;
+  unsigned * pNumbers = static_cast<unsigned *>(malloc(uDivideFactor * 
+                                                       sizeof(unsigned)));
+  //Generating semirandom numbers
+  unsigned mask = 0;
+  unsigned one = 1;
+  for (unsigned u = 0; u < low_shift; ++u) {
+    mask += one << u;
+  }
+  for (unsigned u = 0; u < high_shift; ++u) {
+    mask += one << (16 + u);
+  }
+  for (unsigned u = 0; u < count/uDivideFactor; ++u) {
+    unsigned i = 0;
+    for (; i< uDivideFactor; ++i) {
+      pNumbers[i] = distribution(generator) & mask;
+    }
+    ofile.write(reinterpret_cast<char *>(pNumbers), uDivideFactor * 4 );
+  }
+  ofile.close();
+  return 0;
+}