]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/sort/example/stringsample.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / sort / example / stringsample.cpp
index 17299d1136472347518a365e32da42a5e0d78ac0..eb30033827bb61256711aa399492b2c6fd983541 100644 (file)
@@ -1,85 +1,85 @@
-// spreadsort string sorting example.\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/sort/spreadsort/string_sort.hpp>\r
-#include <time.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <algorithm>\r
-#include <vector>\r
-#include <iostream>\r
-#include <fstream>\r
-#include <string>\r
-using std::string;\r
-using namespace boost::sort::spreadsort;\r
-\r
-#define DATA_TYPE string\r
-\r
-//Pass in an argument to test std::sort\r
-int main(int argc, const char ** argv) {\r
-  std::ifstream indata;\r
-  std::ofstream outfile;\r
-  bool stdSort = false;\r
-  unsigned loopCount = 1;\r
-  for (int u = 1; u < argc; ++u) {\r
-    if (std::string(argv[u]) == "-std")\r
-      stdSort = true;\r
-    else\r
-      loopCount = atoi(argv[u]);\r
-  }\r
-  double total = 0.0;\r
-  //Run multiple loops, if requested\r
-  std::vector<DATA_TYPE> array;\r
-  for (unsigned u = 0; u < loopCount; ++u) {\r
-    indata.open("input.txt", std::ios_base::in | std::ios_base::binary);  \r
-    if (indata.bad()) {\r
-      printf("input.txt could not be opened\n");\r
-      return 1;\r
-    }\r
-    DATA_TYPE inval;\r
-    while (!indata.eof() ) {\r
-      indata >> inval;\r
-      array.push_back(inval);\r
-    }\r
-      \r
-    indata.close();\r
-    clock_t start, end;\r
-    double elapsed;\r
-    start = clock();\r
-    if (stdSort)\r
-      //std::sort(&(array[0]), &(array[0]) + uCount);\r
-      std::sort(array.begin(), array.end());\r
-    else\r
-      //string_sort(&(array[0]), &(array[0]) + uCount);\r
-      string_sort(array.begin(), array.end());\r
-    end = clock();\r
-    elapsed = static_cast<double>(end - start);\r
-    if (stdSort)\r
-      outfile.open("standard_sort_out.txt", std::ios_base::out |\r
-                   std::ios_base::binary | std::ios_base::trunc);\r
-    else\r
-      outfile.open("boost_sort_out.txt", std::ios_base::out |\r
-                   std::ios_base::binary | std::ios_base::trunc);\r
-    if (outfile.good()) {\r
-      for (unsigned u = 0; u < array.size(); ++u)\r
-        outfile << array[u] << "\n";\r
-      outfile.close();\r
-    }\r
-    total += elapsed;\r
-    array.clear();\r
-  }\r
-  if (stdSort)\r
-    printf("std::sort elapsed time %f\n", total / CLOCKS_PER_SEC);\r
-  else\r
-    printf("spreadsort elapsed time %f\n", total / CLOCKS_PER_SEC);\r
-  return 0;\r
-}\r
-\r
-\r
+// spreadsort string sorting example.
+//
+//  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/sort/spreadsort/string_sort.hpp>
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <algorithm>
+#include <vector>
+#include <iostream>
+#include <fstream>
+#include <string>
+using std::string;
+using namespace boost::sort::spreadsort;
+
+#define DATA_TYPE string
+
+//Pass in an argument to test std::sort
+int main(int argc, const char ** argv) {
+  std::ifstream indata;
+  std::ofstream outfile;
+  bool stdSort = false;
+  unsigned loopCount = 1;
+  for (int u = 1; u < argc; ++u) {
+    if (std::string(argv[u]) == "-std")
+      stdSort = true;
+    else
+      loopCount = atoi(argv[u]);
+  }
+  double total = 0.0;
+  //Run multiple loops, if requested
+  std::vector<DATA_TYPE> array;
+  for (unsigned u = 0; u < loopCount; ++u) {
+    indata.open("input.txt", std::ios_base::in | std::ios_base::binary);  
+    if (indata.bad()) {
+      printf("input.txt could not be opened\n");
+      return 1;
+    }
+    DATA_TYPE inval;
+    while (!indata.eof() ) {
+      indata >> inval;
+      array.push_back(inval);
+    }
+      
+    indata.close();
+    clock_t start, end;
+    double elapsed;
+    start = clock();
+    if (stdSort)
+      //std::sort(&(array[0]), &(array[0]) + uCount);
+      std::sort(array.begin(), array.end());
+    else
+      //string_sort(&(array[0]), &(array[0]) + uCount);
+      string_sort(array.begin(), array.end());
+    end = clock();
+    elapsed = static_cast<double>(end - start);
+    if (stdSort)
+      outfile.open("standard_sort_out.txt", std::ios_base::out |
+                   std::ios_base::binary | std::ios_base::trunc);
+    else
+      outfile.open("boost_sort_out.txt", std::ios_base::out |
+                   std::ios_base::binary | std::ios_base::trunc);
+    if (outfile.good()) {
+      for (unsigned u = 0; u < array.size(); ++u)
+        outfile << array[u] << "\n";
+      outfile.close();
+    }
+    total += elapsed;
+    array.clear();
+  }
+  if (stdSort)
+    printf("std::sort elapsed time %f\n", total / CLOCKS_PER_SEC);
+  else
+    printf("spreadsort elapsed time %f\n", total / CLOCKS_PER_SEC);
+  return 0;
+}
+
+