LO27/LibList/list.h

100 lines
1.9 KiB
Objective-C

#ifndef LIST_H
#define LIST_H
#import <CellElement.h>
#define SUCCESS 0
#define FAILURE 1
typedef struct ListElement ListElement;
struct ListElement {
void *data;
ListElement *next;
ListElement *previous;
};
typedef struct List {
ListElement *head;
ListElement *tail;
int size;
} List;
/*
* Create a new list
* @return a pointer of list
*/
List * CreateList();
/*
* Insert an element at the begining of a list
* @param list pointer of a list
* @param data any type of data
* @param size size of the data
* @return status of the operation
*/
int unshift(List* list, cellElement* data);
/*
* Insert an element at the end of a list
* @param list pointer of a list
* @param data any type of data
* @param size size of the data
* @return status of the operation
*/
int push(List* list, cellElement* data, int size);
/*
* Get an element in a given list
* @param list as a pointer
* @param nb the number of the element (can be negative)
* @return an element
*/
ListElement * GetElement(List *list, int nb);
/*
* Delete an element with a pointer of element in the list
* @param list as a pointer
* @param element of the list as a pointer
* @return status of the operation
*/
int PopPtnList(List *list, ListElement *element);
/*
* Delete an element with a position in the list
* @param list as a pointer
* @param position of the element
* @return status of the operation
*/
int RemoveElement(List *list, int nb);
/*
* Delete the first element of the list
* @param list as a pointer
* @return status of the operation
*/
int shift(List *list);
/*
* Delete the last element of the list
* @param list as a pointer
* @return status of the operation
*/
int pop(List *list);
/*
* Delete every elements in a list
* @param list as a pointer
* @return status of the operation
*/
int DeleteListContent(List *list);
/*
* Free a list
* @param list as a pointer
* @return status of the operation
*/
int FreeList(List *list);
#endif /* LIST_H */