1.思路
1.1 清除
1.2 摧毁
清除后释放头节点。
2. 代码
2.1 DList.h
//清除
void clear(List *list);
//摧毁
void destroy(List *list);
2.2 DList.cpp
void clear(List *list)
{
list->last = list->first;
list->last->next = NULL;
list->first->prior = NULL;
list->size == 0;
}
void destroy(List *list)
{
clear(list);
free(list->first);
list->first = list->last = NULL;
}
2.3 main.cpp
case 12:
clear(&mylist);
break;
case 13:
destroy(&mylist);
break;