Advertisement
Qanar

LL Class_main.cpp

Apr 11th, 2022
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <chrono>
  3. #include <thread>
  4. #include <optional>
  5.  
  6. #include "LinkedList.h"
  7. #include "LinkedList.cpp"
  8.  
  9.  
  10. template <class T>
  11. void printMaybe(std::optional<T> maybeSomething) {
  12.     if (maybeSomething)
  13.         std::cout << "SOMETHIN: " << *maybeSomething << std::endl;
  14.     else
  15.         std::cout << "NUFFIN" << std::endl;
  16. }
  17.  
  18. int main()
  19. {
  20.     std::optional<int> last;
  21.     LinkedList<int>* ll = new LinkedList<int>();
  22.    
  23.     int myarray[] = { 76, 105, 107, 101, 32, 116, 104, 101, 32, 108, 101, 103, 101, 110, 100, 32, 111, 102, 32, 116, 104, 101, 32, 80, 104, 111, 101, 110, 105, 120, 44, 32, 104, 117, 104, 10, 65, 108, 108, 32, 101, 110, 100, 115, 32, 119, 105, 116, 104, 32, 98, 101, 103, 105, 110, 110, 105, 110, 103, 115, 10, 87, 104, 97, 116, 32, 107, 101, 101, 112, 115, 32, 116, 104, 101, 32, 112, 108, 97, 110, 101, 116, 32, 115, 112, 105, 110, 110, 105, 110, 103, 44, 32, 97, 104, 10, 84, 104, 101, 32, 102, 111, 114, 99, 101, 32, 102, 114, 111, 109, 32, 116, 104, 101, 32, 98, 101, 103, 105, 110, 110, 105, 110, 103, 44, 32, 104, 109, 44, 32, 108, 111, 118, 101, 10, 10,  87, 101, 39, 118, 101, 32, 99, 111, 109, 101, 32, 116, 111, 111, 32, 102, 97, 114, 10, 84, 111, 32, 103, 105, 118, 101, 32, 117, 112, 32, 119, 104, 111, 32, 119, 101, 32, 97, 114, 101, 10, 83, 111, 32, 108, 101, 116, 39, 115, 32, 114, 97, 105, 115, 101, 32, 116, 104, 101, 32, 98, 97, 114, 10, 65, 110, 100, 32, 111, 117, 114, 32, 99, 117, 112, 115, 32, 116, 111, 32, 116, 104, 101, 32, 115, 116, 97, 114, 115, 10, 10, 83, 104, 101, 39, 115, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 39, 116, 105, 108, 32, 116, 104, 101, 32, 115, 117, 110, 10, 73, 39, 109, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 115, 111, 109, 101, 10, 83, 104, 101, 39, 115, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 102, 111, 114, 32, 103, 111, 111, 100, 32, 102, 117, 110, 10, 73, 39, 109, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 108, 117, 99, 107, 121, 10, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 39, 116, 105, 108, 32, 116, 104, 101, 32, 115, 117, 110, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 115, 111, 109, 101, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 102, 111, 114, 32, 103, 111, 111, 100, 32, 102, 117, 110, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 108, 117, 99, 107, 121, 10, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 108, 117, 99, 107, 121, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 108, 117, 99, 107, 121, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 108, 117, 99, 107, 121, 10, 87, 101, 39, 114, 101, 32, 117, 112, 32, 97, 108, 108, 32, 110, 105, 103, 104, 116, 32, 116, 111, 32, 103, 101, 116, 32, 108, 117, 99, 107, 121 };
  24.     LinkedList<int>* longus = new LinkedList<int>(myarray, sizeof(myarray) / sizeof(int));
  25.    
  26.     std::cout << "Size: " << longus->getSize() << std::endl;
  27.    
  28.    
  29.     for (unsigned int i = 0; i < longus->getSize(); i++) {
  30.         std::optional<int> meinRTL = longus->getAt(i);
  31.         if (meinRTL) {
  32.             char meinChar = (char) *meinRTL;
  33.             std::cout << meinChar;
  34.         } else
  35.             std::cout << "KeinRTL" << std::endl;
  36.    
  37.         std::this_thread::sleep_for(std::chrono::milliseconds(75));
  38.     }
  39.    
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement