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);
}
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) {
@ -113,16 +117,19 @@ void deleteList(List *list) {
free(list);
}
Node *first(List *list) {
return list->head;
}
Node *last(List *list) {
return _traverseToLast(list->head);
}
List *merge(List *list1, List *list2) {
return NULL;
}
void *first(List *list) {
return list->head->dta;
}
void *last(List *list) {
return _traverseToLast(list->head)->dta;
Node* end = last(list1);
end->next = list2->head;
list2->head->prev = end;
return list1;
}
void print(List *list, char *typeFormatter) {