Revision: 60651
Updated Code
at November 13, 2012 23:01 by dfilipov
Updated Code
struct s_datum { unsigned int dan; unsigned int mjesec; unsigned int godina; }; struct s_zapis { short sifra; char vrsta[50]; char naziv[50]; float cijena; s_datum datum; }; struct lista { s_zapis zapis; lista *NEXT; }; typedef lista *element; element EndL(lista *L) { lista *LAST = L; while (LAST->NEXT) LAST = LAST->NEXT; return LAST; } element FirstL(lista *L) { if (L->NEXT) return L; else return EndL(L); } element NextL(element p, lista *L) { if (p->NEXT) return p->NEXT; else return EndL(L); } element PreviousL(element p, lista *L) { if (p==L) return 0; lista *prev = L; while (prev->NEXT) { if (prev->NEXT == p) return prev; prev = prev->NEXT; } return FirstL(L); } element LocateL(s_zapis X, lista *L) { lista *flow = L->NEXT; while (flow) { if (!strcmp(flow->zapis.vrsta, X.vrsta)) return flow; else if (!strcmp(flow->zapis.naziv, X.naziv)) return flow; flow = flow->NEXT; } return EndL(L); } bool InsertL(s_zapis X, element p, lista *L) { if (L) { element novi = new lista; novi->zapis = X; novi->NEXT = p->NEXT; p->NEXT = novi; return true; } else return false; } bool DeleteL(element p, lista *L) { element prev, flow; flow = p; if (p == FirstL(L)) { L->NEXT = flow->NEXT; delete flow; return true; } else if (p != FirstL(L)){ prev = PreviousL(flow, L); prev->NEXT = flow->NEXT; delete flow; return true; } else return false; } s_zapis RetrieveL(element p, lista *L) { return p->zapis; } lista *InitL(lista *L) { L = new lista; L->NEXT = NULL; return L; }
Revision: 60650
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 12, 2012 04:48 by dfilipov
Initial Code
struct s_datum { unsigned int dan; unsigned int mjesec; unsigned int godina; }; struct s_zapis { short sifra; char vrsta[50]; char naziv[50]; float cijena; s_datum datum; }; struct lista { s_zapis zapis; lista *NEXT; }; typedef lista *element; element EndL(lista *L) { lista *LAST = L; while (LAST->NEXT) LAST = LAST->NEXT; return LAST; } element FirstL(lista *L) { if (L->NEXT) return L; else return EndL(L); } element NextL(element p, lista *L) { if (p->NEXT) return p->NEXT; else return EndL(L); } element PreviousL(element p, lista *L) { if (p==L) return 0; lista *prev = L; while (prev->NEXT) { if (prev->NEXT == p) return prev; prev = prev->NEXT; } return FirstL(L); } element LocateL(s_zapis X, lista *L) { lista *flow = L->NEXT; while (flow) { if (!strcmp(flow->zapis.vrsta, X.vrsta)) return flow; else if (!strcmp(flow->zapis.naziv, X.naziv)) return flow; flow = flow->NEXT; } return EndL(L); } bool InsertL(s_zapis X, element p, lista *L) { if (p) { element novi = new lista; novi->zapis = X; novi->NEXT = NULL; if (p->NEXT) novi->NEXT = p->NEXT; p->NEXT = novi; return 1; } else return false; } bool DeleteL(element p, lista *L) { element prev, flow; flow = p; if (p == FirstL(L)) { L->NEXT = flow->NEXT; delete flow; return true; } else if (p != FirstL(L)){ prev = PreviousL(flow, L); prev->NEXT = flow->NEXT; delete flow; return true; } else return false; } s_zapis RetrieveL(element p, lista *L) { return p->zapis; } lista *InitL(lista *L) { L = new lista; L->NEXT = NULL; return L; }
Initial URL
Initial Description
Zaglavlje lista_pokazivac.h
Initial Title
SP Zadatak 1 - implementacija pomocu pokazivaca
Initial Tags
podataka
Initial Language
C++