Advertisement
Mikhail-Podbolotov

Untitled

May 8th, 2024
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include "library.h"
  2.  
  3. List::List()
  4. {
  5.     Start = nullptr;
  6.     End = nullptr;
  7. }
  8.  
  9. List::~List()
  10. {
  11.     Function* prom;
  12.     Function* t = Start;
  13.     while (t != 0) {
  14.         prom = t;
  15.         t = t->Next;
  16.         delete prom;
  17.     }
  18. }
  19.  
  20. void List::addFunction(string& name, bool isRecursive)
  21. {
  22.     Function* Temp = new Function;
  23.     if (!InList(name)) {
  24.         Temp->name = name;
  25.         Temp->isRecursive = isRecursive;
  26.         Temp->Next = nullptr;
  27.         if (Start == nullptr) {
  28.             Start = End = Temp;
  29.         }
  30.         else {
  31.             End->Next = Temp;
  32.             End = Temp;
  33.         }
  34.     }
  35. }
  36.  
  37. void List::PrintR(std::ofstream& file)
  38. {
  39.     Function* t = Start;
  40.     while (t != 0) {
  41.         if (t->isRecursive) {
  42.             file << t->name << endl;
  43.         }
  44.         t = t->Next;
  45.     }
  46. }
  47.  
  48. void List::PrintNR(std::ofstream& file)
  49. {
  50.     Function* t = Start;
  51.     while (t != 0) {
  52.         if (!t->isRecursive) {
  53.             file << t->name << endl;
  54.         }
  55.         t = t->Next;
  56.     }
  57. }
  58.  
  59. bool List::InList(string& name)
  60. {
  61.     Function* t = Start;
  62.     while (t != 0) {
  63.         if (t->name == name) {
  64.             return true;
  65.         }
  66.         t = t->Next;
  67.     }
  68.     return false;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement