📄 test.c
字号:
#include "list.h"
#include "node.h"
#include "string.h"
int main(void)
{
linklist my_list;
linklist my_list_two;
items my_item;
int search_node;
strcpy(my_item.msg, "hello world");
list_init(&my_list_two);
list_init(&my_list);
search_node = 0;
#if 0
list_onshow(my_list);
#endif
#if 1
list_insert_at(my_list, 0, &my_item);
strcpy(my_item.msg, "1");
list_insert_at(my_list, 0, &my_item);
strcpy(my_item.msg, "2");
list_insert_at(my_list, 0, &my_item);
strcpy(my_item.msg, "3");
list_insert_at(my_list, 0, &my_item);
strcpy(my_item.msg, "4");
list_insert_at(my_list, 4, &my_item);
#endif
#if 1
list_onshow(my_list);
#endif
#if 0
list_remove_all(my_list);
list_onshow(my_list);
#endif
#if 0
list_destroy(&my_list);
#endif
#if 0
printf("the count of the list is %d\n", list_count(my_list));
#endif
#if 0
if (list_is_empty(my_list))
{
printf("the list is empty!\n");
}
#endif
#if 0
if (list_remove_at(my_list, 0))
{
printf("after remove:\n");
list_onshow(my_list);
}
#endif
#if 0
printf("dispaly the get at node:\n");
node_data_display(list_get_at(my_list, 0));
#endif
#if 0
printf("reset the node:\n");
strcpy(my_item.msg, "i like");
if (list_set_at(my_list, 0, &my_item))
{
list_onshow(my_list);
}
#endif
#if 0
printf("list add head:\n");
strcpy(my_item.msg, "cherish");
if (list_add_head(my_list, &my_item))
{
printf("the count of the list is %d\n", list_count(my_list));
list_onshow(my_list);
}
#endif
#if 0
printf("list add tail:\n");
strcpy(my_item.msg, "leaf");
if (list_add_tail(my_list, &my_item))
{
printf("the count of the list is %d\n", list_count(my_list));
list_onshow(my_list);
}
#endif
#if 0
printf("list remove at :\n");
if (list_remove_at(my_list, 0))
{
printf("list remove successfully!\n");
list_onshow(my_list);
}
#endif
#if 0
printf("list remove head :\n");
if (list_remove_head(my_list))
{
printf("list remove successfully!\n");
list_onshow(my_list);
}
#endif
#if 0
printf("list remove tail :\n");
if (list_remove_tail(my_list))
{
printf("list remove successfully!\n");
list_onshow(my_list);
}
#endif
#if 0
printf("list get head:\n");
node_data_display(list_get_head(my_list));
#endif
#if 0
printf("list get tail:\n");
node_data_display(list_get_tail(my_list));
#endif
#if 0
printf("list append:\n");
#if 0
strcpy(my_item.msg, "he");
list_insert_at(my_list_two, 0, &my_item);
strcpy(my_item.msg, "she");
list_insert_at(my_list_two, 0, &my_item);
strcpy(my_item.msg, "you");
list_insert_at(my_list_two, 0, &my_item);
#endif
list_append(my_list, my_list_two);
printf("my list destination afer append:\n");
list_onshow(my_list);
printf("list append source afer append:\n");
list_onshow(my_list_two);
#endif
#if 0
strcpy(my_item.msg, "hello world");
search_node = list_search(my_list, &my_item);
printf("the search node number is %d\n", search_node);
#endif
#if 0
printf("the list after swapped:\n");
list_swap_node(my_list, 0, 1);
list_onshow(my_list);
#endif
#if 0
printf("the list after sorted:\n");
if (list_sort(my_list, '<') == 1)
{
list_onshow(my_list);
}
#endif
#if 0
printf("the list tries to reverse:\n");
list_reverse(my_list);
list_onshow(my_list);
#endif
#if 0
strcpy(my_item.msg, "3");
list_insert_at(my_list, 0, &my_item);
strcpy(my_item.msg, "hello world");
list_insert_at(my_list, 6, &my_item);
list_onshow(my_list);
printf("the list tries to diff:\n");
list_diff(my_list);
list_onshow(my_list);
#endif
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -