mirror of
				https://gitlab.com/klmp200/LO27.git
				synced 2025-10-31 10:43:04 +00:00 
			
		
		
		
	Renommage des fonctions de listes
This commit is contained in:
		| @@ -27,7 +27,7 @@ | ||||
| #define SUCCESS 0 | ||||
| #define FAILURE 1 | ||||
|  | ||||
| List * CreateList() { | ||||
| List * createList() { | ||||
| 	List *list = malloc(sizeof(*list)); | ||||
|  | ||||
| 	if(list != NULL){ | ||||
| @@ -99,7 +99,7 @@ int push(List *list, cellElement *data){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| ListElement * GetElement(List *list, int nb){ | ||||
| ListElement * getElement(List *list, int nb){ | ||||
| 	ListElement *current = NULL; | ||||
| 	int i; | ||||
|  | ||||
| @@ -129,7 +129,7 @@ ListElement * GetElement(List *list, int nb){ | ||||
| 	return current; | ||||
| } | ||||
|  | ||||
| int PopPtnList(List *list, ListElement *element){ | ||||
| int popPtnList(List *list, ListElement *element){ | ||||
| 	int ok = SUCCESS; | ||||
|  | ||||
| 	if (list != NULL && element != NULL){ | ||||
| @@ -158,12 +158,12 @@ int PopPtnList(List *list, ListElement *element){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int RemoveElement(List *list, int nb){ | ||||
| int removeElement(List *list, int nb){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement *toDelete = GetElement(list, nb); | ||||
| 	ListElement *toDelete = getElement(list, nb); | ||||
|  | ||||
| 	if (toDelete != NULL){ | ||||
| 		ok = PopPtnList(list, toDelete); | ||||
| 		ok = popPtnList(list, toDelete); | ||||
| 	} else { | ||||
| 		ok = FAILURE; | ||||
| 	} | ||||
| @@ -171,14 +171,14 @@ int RemoveElement(List *list, int nb){ | ||||
| } | ||||
|  | ||||
| int shift(List *list){ | ||||
| 	return RemoveElement(list, 0); | ||||
| 	return removeElement(list, 0); | ||||
| } | ||||
|  | ||||
| int pop(List *list){ | ||||
| 	return RemoveElement(list, -1); | ||||
| 	return removeElement(list, -1); | ||||
| } | ||||
|  | ||||
| int DeleteListContent(List *list){ | ||||
| int deleteListContent(List *list){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement * current = NULL; | ||||
| 	ListElement * toDelete = NULL; | ||||
| @@ -205,11 +205,11 @@ int DeleteListContent(List *list){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int FreeList(List *list){ | ||||
| int freeList(List *list){ | ||||
| 	int ok = SUCCESS; | ||||
|  | ||||
| 	if (list != NULL){ | ||||
| 		ok = DeleteListContent(list); | ||||
| 		ok = deleteListContent(list); | ||||
| 		if (ok == SUCCESS){ | ||||
| 			free(list); | ||||
| 		} | ||||
| @@ -219,7 +219,7 @@ int FreeList(List *list){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| ListElement * GetElementPos(List *list, int pos){ | ||||
| ListElement * getElementPos(List *list, int pos){ | ||||
| 	ListElement * el = list->head; | ||||
| 	while (el != NULL && el->pos != pos){ | ||||
| 		el = el->next; | ||||
| @@ -227,19 +227,19 @@ ListElement * GetElementPos(List *list, int pos){ | ||||
| 	return el; | ||||
| } | ||||
|  | ||||
| int RemoveElementPos(List *list, int pos){ | ||||
| int removeElementPos(List *list, int pos){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement *toDelete = GetElementPos(list, pos); | ||||
| 	ListElement *toDelete = getElementPos(list, pos); | ||||
|  | ||||
| 	if (toDelete != NULL){ | ||||
| 		ok = PopPtnList(list, toDelete); | ||||
| 		ok = popPtnList(list, toDelete); | ||||
| 	} else { | ||||
| 		ok = FAILURE; | ||||
| 	} | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int InsertBeforeElement(List *list, ListElement *eli, ListElement *elp){ | ||||
| int insertBeforeElement(List *list, ListElement *eli, ListElement *elp){ | ||||
| 	int ok = SUCCESS; | ||||
|  | ||||
| 	if (list != NULL){ | ||||
| @@ -260,7 +260,7 @@ int InsertBeforeElement(List *list, ListElement *eli, ListElement *elp){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int InsertAfterElement(List *list, ListElement *eli, ListElement *elb){ | ||||
| int insertAfterElement(List *list, ListElement *eli, ListElement *elb){ | ||||
| 	int ok = SUCCESS; | ||||
|  | ||||
| 	if (list != NULL){ | ||||
| @@ -281,16 +281,16 @@ int InsertAfterElement(List *list, ListElement *eli, ListElement *elb){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int InsertBefore(List *list, cellElement *data, int nb){ | ||||
| int insertBefore(List *list, cellElement *data, int nb){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement *newElement = NULL; | ||||
| 	ListElement *eli = GetElement(list, nb); | ||||
| 	ListElement *eli = getElement(list, nb); | ||||
| 	if (eli != NULL){ | ||||
| 		newElement = malloc(sizeof(*newElement)); | ||||
| 		if (newElement != NULL){ | ||||
| 			newElement->pos = -1; | ||||
| 			newElement->data = data; | ||||
| 			ok = InsertBeforeElement(list, newElement, eli); | ||||
| 			ok = insertBeforeElement(list, newElement, eli); | ||||
| 		} else { | ||||
| 			ok = FAILURE; | ||||
| 		} | ||||
| @@ -300,16 +300,16 @@ int InsertBefore(List *list, cellElement *data, int nb){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int InsertAfter(List *list, cellElement *data, int nb){ | ||||
| int insertAfter(List *list, cellElement *data, int nb){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement *newElement = NULL; | ||||
| 	ListElement *elb = GetElement(list, nb); | ||||
| 	ListElement *elb = getElement(list, nb); | ||||
| 	if (elb != NULL){ | ||||
| 		newElement = malloc(sizeof(*newElement)); | ||||
| 		if (newElement != NULL){ | ||||
| 			newElement->pos = -1; | ||||
| 			newElement->data = data; | ||||
| 			ok = InsertAfterElement(list, newElement, elb); | ||||
| 			ok = insertAfterElement(list, newElement, elb); | ||||
| 		} else { | ||||
| 			ok = FAILURE; | ||||
| 		} | ||||
| @@ -319,16 +319,16 @@ int InsertAfter(List *list, cellElement *data, int nb){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int InsertBeforePos(List *list, cellElement *data, int pos){ | ||||
| int insertBeforePos(List *list, cellElement *data, int pos){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement *newElement = NULL; | ||||
| 	ListElement *eli = GetElementPos(list, pos); | ||||
| 	ListElement *eli = getElementPos(list, pos); | ||||
| 	if (eli != NULL){ | ||||
| 		newElement = malloc(sizeof(*newElement)); | ||||
| 		if (newElement != NULL){ | ||||
| 			newElement->pos = -1; | ||||
| 			newElement->data = data; | ||||
| 			ok = InsertBeforeElement(list, newElement, eli); | ||||
| 			ok = insertBeforeElement(list, newElement, eli); | ||||
| 		} else { | ||||
| 			ok = FAILURE; | ||||
| 		} | ||||
| @@ -338,16 +338,16 @@ int InsertBeforePos(List *list, cellElement *data, int pos){ | ||||
| 	return ok; | ||||
| } | ||||
|  | ||||
| int InsertAfterPos(List *list, cellElement *data, int pos){ | ||||
| int insertAfterPos(List *list, cellElement *data, int pos){ | ||||
| 	int ok = SUCCESS; | ||||
| 	ListElement *newElement = NULL; | ||||
| 	ListElement *elb = GetElementPos(list, pos); | ||||
| 	ListElement *elb = getElementPos(list, pos); | ||||
| 	if (elb != NULL){ | ||||
| 		newElement = malloc(sizeof(*newElement)); | ||||
| 		if (newElement != NULL){ | ||||
| 			newElement->pos = -1; | ||||
| 			newElement->data = data; | ||||
| 			ok = InsertAfterElement(list, newElement, elb); | ||||
| 			ok = insertAfterElement(list, newElement, elb); | ||||
| 		} else { | ||||
| 			ok = FAILURE; | ||||
| 		} | ||||
|   | ||||
| @@ -62,7 +62,7 @@ typedef struct List { | ||||
|  * | ||||
|  * @return List a pointer of list | ||||
|  */ | ||||
| List * CreateList(); | ||||
| List * createList(); | ||||
|  | ||||
| /** | ||||
|  * Insert an element at the begining of a list | ||||
| @@ -86,7 +86,7 @@ int push(List* list, cellElement* data); | ||||
|  * @param nb the number of the element (can be negative) | ||||
|  * @return List an element | ||||
|  */ | ||||
| ListElement * GetElement(List *list, int nb); | ||||
| ListElement * getElement(List *list, int nb); | ||||
|  | ||||
| /** | ||||
|  * Delete an element with a pointer of element in the list | ||||
| @@ -94,7 +94,7 @@ ListElement * GetElement(List *list, int nb); | ||||
|  * @param element of the list as a pointer | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int PopPtnList(List *list, ListElement *element); | ||||
| int popPtnList(List *list, ListElement *element); | ||||
|  | ||||
| /** | ||||
|  * Delete an element with a position in the list | ||||
| @@ -102,7 +102,7 @@ int PopPtnList(List *list, ListElement *element); | ||||
|  * @param nb position of the element | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int RemoveElement(List *list, int nb); | ||||
| int removeElement(List *list, int nb); | ||||
|  | ||||
| /** | ||||
|  * Delete the first element of the list | ||||
| @@ -123,14 +123,14 @@ int pop(List *list); | ||||
|  * @param list as a pointer | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int DeleteListContent(List *list); | ||||
| int deleteListContent(List *list); | ||||
|  | ||||
| /** | ||||
|  * Free a list | ||||
|  * @param list as a pointer | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int FreeList(List *list); | ||||
| int freeList(List *list); | ||||
|  | ||||
| /** | ||||
|  * Find the first element with the given pos value | ||||
| @@ -138,7 +138,7 @@ int FreeList(List *list); | ||||
|  * @param pos the pos value to find | ||||
|  * @return ListElement the found element can return NULL | ||||
|  */ | ||||
| ListElement * GetElementPos(List *list, int pos); | ||||
| ListElement * getElementPos(List *list, int pos); | ||||
|  | ||||
| /** | ||||
|  * Delete the first element of a list with the given pos | ||||
| @@ -146,7 +146,7 @@ ListElement * GetElementPos(List *list, int pos); | ||||
|  * @param pos pos value of the element | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int RemoveElementPos(List *list, int pos); | ||||
| int removeElementPos(List *list, int pos); | ||||
|  | ||||
| /** | ||||
|  * Insert an element in a list before the given element | ||||
| @@ -155,7 +155,7 @@ int RemoveElementPos(List *list, int pos); | ||||
|  * @param elp the previous element in the list | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int InsertBeforeElement(List *list, ListElement *eli, ListElement *elp); | ||||
| int insertBeforeElement(List *list, ListElement *eli, ListElement *elp); | ||||
|  | ||||
| /** | ||||
|  * Insert an element in a list after the given element | ||||
| @@ -164,7 +164,7 @@ int InsertBeforeElement(List *list, ListElement *eli, ListElement *elp); | ||||
|  * @param elb the before element in the list | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int InsertAfterElement(List *list, ListElement *eli, ListElement *elb); | ||||
| int insertAfterElement(List *list, ListElement *eli, ListElement *elb); | ||||
|  | ||||
| /** | ||||
|  * Insert an element in a list before the given position | ||||
| @@ -173,7 +173,7 @@ int InsertAfterElement(List *list, ListElement *eli, ListElement *elb); | ||||
|  * @param nb the position in list to find | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int InsertBefore(List *list, cellElement *data, int nb); | ||||
| int insertBefore(List *list, cellElement *data, int nb); | ||||
|  | ||||
| /** | ||||
|  * Insert an element in a list after the given position | ||||
| @@ -182,7 +182,7 @@ int InsertBefore(List *list, cellElement *data, int nb); | ||||
|  * @param nb the position in list to find | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int InsertAfter(List *list, cellElement *data, int nb); | ||||
| int insertAfter(List *list, cellElement *data, int nb); | ||||
|  | ||||
| /** | ||||
|  * Insert an element in a list before the first element with the given pos | ||||
| @@ -191,7 +191,7 @@ int InsertAfter(List *list, cellElement *data, int nb); | ||||
|  * @param pos the first pos in list to find | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int InsertBeforePos(List *list, cellElement *data, int pos); | ||||
| int insertBeforePos(List *list, cellElement *data, int pos); | ||||
|  | ||||
| /** | ||||
|  * Insert an element in a list after the first element with the given pos | ||||
| @@ -200,6 +200,6 @@ int InsertBeforePos(List *list, cellElement *data, int pos); | ||||
|  * @param pos the first pos in list to find | ||||
|  * @return int status of the operation | ||||
|  */ | ||||
| int InsertAfterPos(List *list, cellElement *data, int pos); | ||||
| int insertAfterPos(List *list, cellElement *data, int pos); | ||||
|  | ||||
| #endif /* LIST_H */ | ||||
|   | ||||
| @@ -67,8 +67,8 @@ Matrix CreateMatrix(){ | ||||
| 	Matrix matrix; | ||||
| 	matrix.colCount = 0; | ||||
| 	matrix.rowCount = 0; | ||||
| 	matrix.cols = CreateList(); | ||||
| 	matrix.rows = CreateList(); | ||||
| 	matrix.cols = createList(); | ||||
| 	matrix.rows = createList(); | ||||
| 	return matrix; | ||||
| } | ||||
|  | ||||
| @@ -91,7 +91,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){ | ||||
| 	elem = CreateCellElem(); | ||||
| 	SetPositionIndex(elem,ColPos,RowPos); | ||||
|  | ||||
| 	Row = GetElementPos(matrix.rows,RowPos); | ||||
| 	Row = getElementPos(matrix.rows,RowPos); | ||||
| 	if (Row != NULL && Row->data != NULL){ | ||||
|  | ||||
| 		if (Row->data->colIndex == ColPos){ | ||||
| @@ -117,7 +117,7 @@ bool CreateMatrixElem(Matrix matrix, int ColPos, int RowPos){ | ||||
| 		matrix.rows->tail->pos = RowPos; | ||||
| 	} | ||||
|  | ||||
| 	Col = GetElementPos(matrix.cols,ColPos); | ||||
| 	Col = getElementPos(matrix.cols,ColPos); | ||||
| 	if (Col != NULL && Col->data != NULL){ | ||||
|  | ||||
| 		if (Col->data->rowIndex == RowPos){ | ||||
| @@ -157,7 +157,7 @@ cellElement * FindMatrixElem(Matrix matrix, int ColPos, int RowPos){ | ||||
| 	ListElement * Row = NULL; | ||||
| 	cellElement * elem = NULL; | ||||
|  | ||||
| 	Row = GetElementPos(matrix.rows,RowPos); | ||||
| 	Row = getElementPos(matrix.rows,RowPos); | ||||
| 	if (Row == NULL){ | ||||
| 		return NULL; | ||||
| 	} | ||||
| @@ -182,12 +182,12 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){ | ||||
| 		return 0; | ||||
| 	} | ||||
|  | ||||
| 	Row = GetElementPos(matrix.rows,RowPos); | ||||
| 	Row = getElementPos(matrix.rows,RowPos); | ||||
| 	if (Row == NULL){ | ||||
| 		return -1; | ||||
| 	} | ||||
| 	if (Row->data == NULL){ | ||||
| 		RemoveElementPos(matrix.rows,RowPos); | ||||
| 		removeElementPos(matrix.rows,RowPos); | ||||
| 		return -1; | ||||
| 	} | ||||
|  | ||||
| @@ -206,16 +206,16 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){ | ||||
|  | ||||
| 	} | ||||
| 	if (Row->data == NULL){ | ||||
| 		RemoveElementPos(matrix.rows,RowPos); | ||||
| 		removeElementPos(matrix.rows,RowPos); | ||||
| 	} | ||||
|  | ||||
|  | ||||
| 	Col = GetElementPos(matrix.cols,ColPos); | ||||
| 	Col = getElementPos(matrix.cols,ColPos); | ||||
| 	if (Col == NULL){ | ||||
| 		return -2; | ||||
| 	} | ||||
| 	if (Col->data == NULL){ | ||||
| 		RemoveElementPos(matrix.cols,ColPos); | ||||
| 		removeElementPos(matrix.cols,ColPos); | ||||
| 		return -1; | ||||
| 	} | ||||
| 	if (Col->data->rowIndex == RowPos){ | ||||
| @@ -232,7 +232,7 @@ int SupprMatrixElem(Matrix matrix, int ColPos, int RowPos){ | ||||
| 		} | ||||
| 	} | ||||
| 		if (Col->data == NULL){ | ||||
| 		RemoveElementPos(matrix.cols,ColPos); | ||||
| 		removeElementPos(matrix.cols,ColPos); | ||||
| 	} | ||||
|  | ||||
| 	FreeCellElement(elem); | ||||
| @@ -306,8 +306,8 @@ Matrix freeMatrix(Matrix matrix){ | ||||
| 		 | ||||
| 	} | ||||
|  | ||||
| 	FreeList(matrix.cols); | ||||
| 	FreeList(matrix.rows); | ||||
| 	freeList(matrix.cols); | ||||
| 	freeList(matrix.rows); | ||||
| 	return matrix; | ||||
| } | ||||
|  | ||||
| @@ -621,7 +621,7 @@ bool isColumnEmpty(Matrix matrix,int nb){ | ||||
| 		return true; | ||||
| 	} | ||||
| 	 | ||||
| 	Col = GetElementPos(matrix.cols,nb); | ||||
| 	Col = getElementPos(matrix.cols,nb); | ||||
| 	if (Col == NULL || Col->data == NULL){ | ||||
| 		return true; | ||||
| 	} | ||||
| @@ -638,7 +638,7 @@ bool isRowEmpty(Matrix matrix,int nb){ | ||||
| 	if (matrix.cols->size == 0 || matrix.rows->size == 0){ | ||||
| 		return true; | ||||
| 	} | ||||
| 	Row = GetElementPos(matrix.rows,nb); | ||||
| 	Row = getElementPos(matrix.rows,nb); | ||||
| 	if (Row == NULL || Row->data == NULL){ | ||||
| 		return true; | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user