# Posted By

sejstefic on 01/14/11

# Statistics

Viewed 238 times
Favorited by 0 user(s)

# Implementacija liste pomocu polja

/ Published in: C++
`struct list {		elementtype value;		struct list *next;	};  typedef list *element; element FirstL(list *L){	return(L->next);}  element EndL(list *L){	list *l;	l=L;	while (l->next != NULL) {		l=l->next;	}	return(l);}  element NextL(element p, list *L){	if (p->next == NULL) {		cout << "Nepostojeci element NEXT";		exit(0);	}	else {		list *l;		l=p->next;		return(l);	}}  element PreviousL(element p, list *L){	list *l;	l=L;	while ((l->next != NULL) && (l->next != p))		l=l->next;	if (l->next != NULL)		return(l);	else {		cout << "Nepostojeci element PREV";		system("pause");        exit(0);	}}  element LocateL(elementtype x, list *L){	list *l;	l=L;	while ((l->next != NULL) && (l->next->value != x))		l=l->next;	return(l);}  void InsertL(elementtype x, element p, list *L){	list *l;	l=new list;	l->next=p->next;	p->next=l;	l->value = p->value;	p->value = x; }  void DeleteL(element p, list *L){	element l;	p=PreviousL(p,L);     if (p->next != NULL) {		l=p->next;		p->next=p->next->next;		delete l;	}	else {		cout << "Nepostojeci element DELETE";		system("pause");		exit(0);	}}  elementtype RetrieveL(element p, list *L){	if (p->next != NULL) {		elementtype x;		x=p->value;		return(x);	}	else {		cout << "Nepostojeci element RETRIVER";		system("pause");		exit(0);	}}  void DeleteAllL(list *L){	element l;	while (L->next != NULL) {		l=L->next;		L->next = L->next->next;		delete l;	}}  void InitL(list *L){	list *l;	l = new list;	L->next=l;	l->next=NULL; }`