heapsort.cxx 972 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. #include <sstream>
  6. #include "json.hpp"
  7. #include "priorityqueue.h"
  8. int main(int argc, char** argv) {
  9. // read JSON file and store in jsonObject
  10. std::ifstream file;
  11. file.open(argv[1]);
  12. nlohmann::json jsonObject;
  13. // Store the contents filename into jsonObject
  14. if (file.is_open()) {
  15. file >> jsonObject;
  16. }
  17. std::string sampleName; // Sample key name to iterate
  18. nlohmann::json outputJSON; // output JSON file
  19. //int currValue = 0; // current key value
  20. int n = jsonObject["metadata"]["arraySize"];
  21. class PriorityQueue sampleHeap;
  22. sampleHeap.initiateHeap(n);
  23. for (auto itr = jsonObject.begin(); itr != jsonObject.end(); ++itr) {
  24. if (sampleName != "metadata") {
  25. for (auto arrayItr = jsonObject[sampleName].begin(); arrayItr != jsonObject[sampleName].end(); ++arrayItr) {
  26. }
  27. }
  28. }
  29. std::cout << outputJSON << std::endl;
  30. file.close();
  31. }