Advertisement
Guest User

lista.cpp

a guest
Mar 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. #include "lista.h"
  2.  
  3. bool lista::empty() const{
  4. if (this->wezilosc()==0)
  5. return true;
  6. else return false;
  7. }
  8. void lista::dodajPocz(const int nr, const std::string imie, const std::string naz, int rok, std::string kier, std::string spec){
  9. Wezel* v = new Wezel;
  10. this->iloscel++;
  11. v->nralbumu=nr;
  12. v->imie = imie;
  13. v ->nazwisko=naz;
  14. v -> rokstudiow = rok;
  15. v -> kierunek = kier;
  16. v -> specjalnosc = spec;
  17. if (iloscel==1){
  18. tail=v;
  19. head = v;
  20. return;
  21. }
  22. v->poprzedni = NULL;
  23. v->nast = head;
  24. head->poprzedni = v;
  25. head = v;
  26. }
  27. void lista::dodajKoniec (const int nr, const std::string imie, const std::string naz, int rok, std::string kier, std::string spec){
  28. Wezel* v = new Wezel;
  29. this->iloscel++;
  30. v->nralbumu=nr;
  31. v->imie = imie;
  32. v ->nazwisko=naz;
  33. v -> rokstudiow = rok;
  34. v -> kierunek = kier;
  35. v -> specjalnosc = spec;
  36. v->nast = NULL;
  37. if (iloscel==1){
  38. head=v;
  39. tail=v;
  40. return;
  41. }
  42. tail->nast=v;
  43. v->poprzedni=tail;
  44. tail = v;
  45. v->nast = NULL;
  46. }
  47. void lista::pokazliste(){
  48. Wezel *temp = tail;
  49. while(temp){
  50. std::cout << temp;
  51. temp = temp->poprzedni;
  52. }
  53. delete temp;
  54. }
  55. void lista::WstawZa(const int nr, const std::string imie, const std::string naz, int rok, std::string kier, std::string spec, const int album){
  56. Wezel *v = new Wezel;
  57. Wezel *tmp = head;
  58. v->nralbumu=nr;
  59. v->imie = imie;
  60. v ->nazwisko=naz;
  61. v -> rokstudiow = rok;
  62. v -> kierunek = kier;
  63. v -> specjalnosc = spec;
  64. while (tmp->nast){
  65. if(tmp->nralbumu==album)
  66. break;
  67. tmp = tmp->nast;
  68. }
  69. v->nast = tmp->nast;
  70. v->poprzedni=tmp;
  71. tmp->nast->poprzedni=v;
  72. tmp->nast = v;
  73. this->iloscel++;
  74. }
  75. void lista::Kasuj(int nr){
  76. Wezel* tmp= head;
  77. while (tmp->nast){
  78. if(tmp->nralbumu==nr)
  79. break;
  80. tmp = tmp->nast;
  81. }
  82. if(tmp->nralbumu==head->nralbumu){
  83. tmp->nast->poprzedni=NULL;
  84. //delete head;
  85. head=tmp->nast;
  86. }else if(tmp->nralbumu==tail->nralbumu){
  87. tmp->poprzedni->nast=NULL;
  88. //delete tail;
  89. tail = tmp->poprzedni;
  90. }else{
  91. tmp->poprzedni->nast=tmp->nast;
  92. tmp->nast->poprzedni=tmp->poprzedni;
  93. //delete tmp;
  94. }
  95. }
  96. void lista::wczytajwiele(int ilosc){
  97. int i = 0;
  98. for (i=0; i<ilosc; i++){
  99. Wezel* v = new Wezel;
  100. std::cin >> v;
  101. dodajPocz(v->nralbumu, v->imie, v->nazwisko, v->rokstudiow, v->kierunek, v->specjalnosc);
  102. }
  103. }
  104. Wezel* lista::wyszukaj(int nr){
  105. Wezel* tmp= head;
  106. while (tmp){
  107. if(tmp->nralbumu==nr)
  108. return tmp;
  109. tmp = tmp->nast;
  110. }
  111. }
  112. Wezel* lista::wyszukaj2(std::string imie){
  113. Wezel* tmp= head;
  114. while (tmp->nast){
  115. if(tmp->imie==imie)
  116. return tmp;
  117. tmp = tmp->nast;
  118. }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement