Skip to content
Snippets Groups Projects
Commit fb2d3458 authored by Romain Andres's avatar Romain Andres
Browse files

tp

parent 6102ad3e
No related branches found
No related tags found
No related merge requests found
......@@ -91,4 +91,3 @@ For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
test
\ No newline at end of file
File added
#include <stdio.h>
#include <stdlib.h>
struct node_t {
unsigned long int key;
void* val;
......
src/bst.o 0 → 100644
File added
File added
#include <stdio.h>
#include <stdlib.h>
struct cell_t {
void* val;
unsigned long int id;
struct cell_t* next;
};
typedef struct cell_t* list_t;
list_t list_empty() {
return NULL;
}
int list_is_empty(list_t l) {
return l == NULL;
}
list_t list_push(list_t l, void* x) {
list_t newCase = malloc(sizeof(struct cell_t));
newCase->val = x;
newCase->id = l->id+1;
newCase->next = l;
return newCase;
}
// renvoie la liste sans le premier element
list_t list_tail(list_t l) {
return l->next;
}
// renvoie ce qui a dans la liste en premier et l'enleve de la liste
//donc ca supprime donc ca free
//modifie la liste pour que elle pointe au suivant
void* list_pop(list_t* l) {
if( list_is_empty(*l)) {
return NULL;
}
/*
struct cell_t* aRenvoyer = l->next;
free(l);
return aRenvoyer;
*/
void * val = (*l)->val;
list_t newL = (*l)->next;
free(*l);
*l = newL;
return val;
/*
list_t liste = *l;
void * val = list_top(liste);
free(liste);
*/
//*l = list_tail(liste);
//return val;
}
//retourne le premier element (sa valeur ?)
void* list_top(list_t l) {
return l-> val;
}
void list_destroy(list_t l, void (*free)(void*)){
//detruit la liste
//free_void permet de dealouer val
void list_destroy(list_t l, void (*free_void)(void*)) {
list_t currentCase;
while(l->next != NULL) {
currentCase = l->next;
free_void(l->val);
free(l);
l = currentCase;
}
}
// return the found element or NULL
void* list_in(list_t l, void* x, int (*eq)(void*, void*)) {
}
unsigned long int list_len(list_t l) {
}
File added
File added
......@@ -44,6 +44,7 @@ int main(){
return 0;
} else {
l = list_push(l, p);
//i++
}
}
}
......
File added
#include <assert.h>
#include <stdio.h>
#include "linked_list.h"
#include "list.h"
#include "bignum.h"
void test_emptyness() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment