diff --git a/list/list.h b/list/list.h index 9c74c6d..180081a 100644 --- a/list/list.h +++ b/list/list.h @@ -41,6 +41,9 @@ unsigned long long getId(void); int insertInHead(List *p_list, Node *p_node); int insertInTail(List *p_list, Node *p_node); +/*交换函数*/ +int exchangeLocation(Node *p_node,Node *t_node); + /*移除函数*/ int removeById(List *p_list, unsigned long id); int removeByNode(List *p_list, Node *p_node); @@ -467,4 +470,18 @@ int isListEmpty(List *p_list){ return 0; // want to make a list empty. } +int exchangeLocation(Node *p_node,Node *t_node){ + Node *temp_next = p_node->next; + Node *temp_last = p_node->last; + p_node->last->next = t_node; + p_node->next->last = t_node; + t_node->last->next = p_node; + t_node->next->last = p_node; + p_node->next = t_node->next; + p_node->last = t_node->last; + t_node->next = temp_next; + t_node->last = temp_last; + return 0; +} + #endif