impl insert and merge
This commit is contained in:
parent
4b96909c5c
commit
21e05fda58
27
List.h
27
List.h
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user