wheelsmanx

AOC DAY 4 PART 1 header.h

May 24th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1.  
  2. #pragma once
  3. #include <iostream>
  4. #include <string>
  5. #include <vector>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <algorithm>
  9.  
  10. using namespace std;
  11.  
  12. string Uni_str(string input) {
  13. string returnObject = "";
  14.  
  15. for (int i = 0; i < input.length(); i++) {
  16. if (strchr(returnObject.c_str(), input[i])) {}else{
  17. returnObject = returnObject + input[i];
  18. }
  19. }
  20. return returnObject;
  21. }
  22.  
  23.  
  24. vector <int> String2Int(vector <string> tempVector) {
  25. stringstream tempSS;
  26. vector <int> tempIntVector;
  27. int tempInt;
  28. for (int i = 0; i < tempVector.size(); i++) {
  29. tempSS << tempVector.at(i);
  30. tempSS >> tempInt;
  31. tempIntVector.push_back(tempInt);
  32. }
  33. return tempIntVector;
  34. }
  35.  
  36. int String2Int(string userInput) {
  37. stringstream tempSS;
  38. int tempInt;
  39. tempSS << userInput;
  40. tempSS >> tempInt;
  41. return tempInt;
  42. }
  43.  
  44. vector <string> cstringsplit(string input, string delimeter) {
  45. int delimSize = delimeter.length();
  46. int inputSize = input.length();
  47. string buffer;
  48. vector <string> v;
  49. for (int i = 0; i < inputSize; i++) {
  50. if (input.substr(i, delimSize) != delimeter) {
  51. buffer += input[i];
  52. }
  53. else {
  54. v.push_back(buffer);
  55. buffer = "";
  56. i = i + delimSize - 1;
  57. }
  58. }
  59. v.push_back(buffer);
  60. buffer = "";
  61. return v;
  62. }
  63.  
  64. vector<string> getInputFile(string location) {
  65. // good example getFile("C:\\temp\\New Text Document.txt");
  66. ifstream fileInput;
  67. vector<string> tempVector;
  68. string tempString;
  69. fileInput.open(location);
  70. while (!fileInput.eof())
  71. {
  72. getline(fileInput, tempString);
  73. tempVector.push_back(tempString);
  74. tempString = " ";
  75. }
  76. return tempVector;
  77. }
  78.  
  79. void vout(vector<string> temp) { for (string c : temp) { cout << c << endl; } }
  80. void vout(vector<char> temp) { for (char c : temp) { cout << c << endl; } }
  81. void vout(vector<int> temp) { for (int c : temp) { cout << c << endl; } }
  82. void vout(vector<bool> temp) { for (bool c : temp) { cout << c << endl; } }
Advertisement
Add Comment
Please, Sign In to add comment