Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "lista.h"
- bool lista::empty() const{
- if (this->wezilosc()==0)
- return true;
- else return false;
- }
- void lista::dodajPocz(const int nr, const std::string imie, const std::string naz, int rok, std::string kier, std::string spec){
- Wezel* v = new Wezel;
- this->iloscel++;
- v->nralbumu=nr;
- v->imie = imie;
- v ->nazwisko=naz;
- v -> rokstudiow = rok;
- v -> kierunek = kier;
- v -> specjalnosc = spec;
- if (iloscel==1){
- tail=v;
- head = v;
- return;
- }
- v->poprzedni = NULL;
- v->nast = head;
- head->poprzedni = v;
- head = v;
- }
- void lista::dodajKoniec (const int nr, const std::string imie, const std::string naz, int rok, std::string kier, std::string spec){
- Wezel* v = new Wezel;
- this->iloscel++;
- v->nralbumu=nr;
- v->imie = imie;
- v ->nazwisko=naz;
- v -> rokstudiow = rok;
- v -> kierunek = kier;
- v -> specjalnosc = spec;
- v->nast = NULL;
- if (iloscel==1){
- head=v;
- tail=v;
- return;
- }
- tail->nast=v;
- v->poprzedni=tail;
- tail = v;
- v->nast = NULL;
- }
- void lista::pokazliste(){
- Wezel *temp = tail;
- while(temp){
- std::cout << temp;
- temp = temp->poprzedni;
- }
- delete temp;
- }
- 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){
- Wezel *v = new Wezel;
- Wezel *tmp = head;
- v->nralbumu=nr;
- v->imie = imie;
- v ->nazwisko=naz;
- v -> rokstudiow = rok;
- v -> kierunek = kier;
- v -> specjalnosc = spec;
- while (tmp->nast){
- if(tmp->nralbumu==album)
- break;
- tmp = tmp->nast;
- }
- v->nast = tmp->nast;
- v->poprzedni=tmp;
- tmp->nast->poprzedni=v;
- tmp->nast = v;
- this->iloscel++;
- }
- void lista::Kasuj(int nr){
- Wezel* tmp= head;
- while (tmp->nast){
- if(tmp->nralbumu==nr)
- break;
- tmp = tmp->nast;
- }
- if(tmp->nralbumu==head->nralbumu){
- tmp->nast->poprzedni=NULL;
- //delete head;
- head=tmp->nast;
- }else if(tmp->nralbumu==tail->nralbumu){
- tmp->poprzedni->nast=NULL;
- //delete tail;
- tail = tmp->poprzedni;
- }else{
- tmp->poprzedni->nast=tmp->nast;
- tmp->nast->poprzedni=tmp->poprzedni;
- //delete tmp;
- }
- }
- void lista::wczytajwiele(int ilosc){
- int i = 0;
- for (i=0; i<ilosc; i++){
- Wezel* v = new Wezel;
- std::cin >> v;
- dodajPocz(v->nralbumu, v->imie, v->nazwisko, v->rokstudiow, v->kierunek, v->specjalnosc);
- }
- }
- Wezel* lista::wyszukaj(int nr){
- Wezel* tmp= head;
- while (tmp){
- if(tmp->nralbumu==nr)
- return tmp;
- tmp = tmp->nast;
- }
- }
- Wezel* lista::wyszukaj2(std::string imie){
- Wezel* tmp= head;
- while (tmp->nast){
- if(tmp->imie==imie)
- return tmp;
- tmp = tmp->nast;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement