Merge branch 'develop' of https://www.github.com/MapleSign/ZE-Standard-Libraries into conflict
Solved the conflict.
This commit is contained in:
commit
bc6058abbe
66
list/list.h
66
list/list.h
@ -58,3 +58,69 @@ int releaseList(List *p_list){
|
||||
free(p_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int removeById(List *p_list, unsigned long id){
|
||||
Node *tmp = p_list->head;
|
||||
if(tmp == NULL) return -1;//这说明p_list指向空列表
|
||||
do{
|
||||
if(tmp->id == id) {
|
||||
tmp->last->next = tmp->next;
|
||||
tmp->next->last = tmp->last;
|
||||
return 1;//找到了
|
||||
}
|
||||
else{
|
||||
tmp = tmp->next;
|
||||
}
|
||||
} while(tmp != NULL);
|
||||
|
||||
return 0;//没找到
|
||||
}
|
||||
|
||||
int removeByNode(List *p_list, Node *p_node){
|
||||
Node *tmp = p_list->head;
|
||||
if(tmp == NULL)
|
||||
return -1;//这说明p_list指向空列表
|
||||
|
||||
do{
|
||||
if(tmp == p_node){
|
||||
tmp->last->next = tmp->next;
|
||||
tmp->next->last = tmp->last;
|
||||
return 1;//找到了
|
||||
}
|
||||
else{
|
||||
tmp = tmp->next;
|
||||
}
|
||||
}while(tmp != NULL);
|
||||
|
||||
return 0;//没找到
|
||||
}
|
||||
|
||||
int popFromHead(List *p_list){
|
||||
if(p_list->head == NULL)
|
||||
return -1;
|
||||
|
||||
if(p_list->head->next == NULL){
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
}
|
||||
else{
|
||||
p_list->head->next->last = NULL;
|
||||
p_list->head = p_list->head->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int popFromTail(List *p_list){
|
||||
if(p_list->head == NULL)
|
||||
return -1;
|
||||
|
||||
if(p_list->head->next == NULL){
|
||||
p_list->head = NULL;
|
||||
p_list->tail = NULL;
|
||||
}
|
||||
else{
|
||||
p_list->tail->last->next = NULL;
|
||||
p_list->tail = p_list->tail->last;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user