Return to Snippet

Revision: 60623
at November 12, 2012 03:27 by nkuzir


Initial Code
#include <string>
using namespace std;



struct zivotinje{
  int sifra;
  char  vrsta[50];
  char naziv[50];
  int cijena;
  string datum;
};




struct tlista {
       zivotinje c;
       tlista *next;
       };
       
tlista *l=new tlista;
typedef tlista *tip;
   
       
tlista *FirstL (tlista *l) {
    return l->next;   
}

tlista *EndL (tlista *l) {
    tlista *zadnji=l;
    while (zadnji->next!=NULL) zadnji=zadnji->next;
    return zadnji->next;   
}
tlista *NextL (tlista *p, tlista *l) {
    return p->next;
}
tlista *PreviousL (tlista *p, tlista *l) {
    tlista *temp=l;
    while (temp->next!=p) {
          temp=temp->next;
          }
    return temp;
}
tlista *LocateL (zivotinje a, tlista *l) {
    tlista *temp=l->next;
    while (temp) {
          if (a.sifra==temp->c.sifra) return temp;
          temp=temp->next;
          }
    return EndL(l);
}
void InsertL (zivotinje x, tlista *p, tlista *l) {
     tlista *novi=new tlista;
     p=PreviousL(p, l);
     novi->c=x;
     novi->next=p->next;  
     p->next=novi;   
}
void DeleteL (tlista *p, tlista *l) {
     p=PreviousL(p, l);
     tlista *temp=p->next;
     p->next=temp->next;
     delete temp;     
}
zivotinje RetrieveL (tlista *p, tlista *l) {
    return p->c;   
}


void *DeleteAllL (tlista *l) {
     while (l->next) {
           tlista *temp=l->next;
           l->next=temp->next;
           delete temp;
           }
     delete l;
}
void *InitL (tlista *l) {
     l->next=NULL;     
}

Initial URL

                                

Initial Description
Lista implementirana pomoću pokazivača.

Initial Title
lista_pokazivac.h

Initial Tags
podataka

Initial Language
C++