impl insert and merge

This commit is contained in:
lukas-heiligenbrunner 2022-06-01 11:02:45 +02:00
parent 4b96909c5c
commit 21e05fda58

27
List.h
View File

@ -78,8 +78,12 @@ int length(List *list) {
return _length(list->head); return _length(list->head);
} }
void insert(List *list, int position) { void insert(List *list, void* elem, int position) {
Node* insertpos = _traverseToPos(list->head, position);
Node* newnode = _newNode(insertpos->next, insertpos, elem);
insertpos->next = newnode;
insertpos->next->next->prev = newnode;
} }
void delete(List *list, int position) { void delete(List *list, int position) {
@ -113,16 +117,19 @@ void deleteList(List *list) {
free(list); free(list);
} }
Node *first(List *list) {
return list->head;
}
Node *last(List *list) {
return _traverseToLast(list->head);
}
List *merge(List *list1, List *list2) { List *merge(List *list1, List *list2) {
return NULL; Node* end = last(list1);
} end->next = list2->head;
list2->head->prev = end;
void *first(List *list) { return list1;
return list->head->dta;
}
void *last(List *list) {
return _traverseToLast(list->head)->dta;
} }
void print(List *list, char *typeFormatter) { void print(List *list, char *typeFormatter) {