Add code generation for doubly linked list
This commit is contained in:
29
codegen/dbl_list/snippets/list_insert
Normal file
29
codegen/dbl_list/snippets/list_insert
Normal file
@@ -0,0 +1,29 @@
|
||||
if (!list || !node || !(node->string)) {{
|
||||
return;
|
||||
}}
|
||||
|
||||
if (index == 0) {{
|
||||
wapp_str8_list_push_front(list, node);
|
||||
return;
|
||||
}} else if (index == list->node_count) {{
|
||||
wapp_str8_list_push_back(list, node);
|
||||
return;
|
||||
}}
|
||||
|
||||
{T}Node *dst_node = wapp_str8_list_get(list, index);
|
||||
if (!dst_node) {{
|
||||
return;
|
||||
}}
|
||||
|
||||
{T}List node_list = {Tlower}_node_to_list(node);
|
||||
|
||||
list->total_size += node_list.total_size;
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
{T}Node *prev = dst_node->prev;
|
||||
|
||||
dst_node->prev = node_list.last;
|
||||
prev->next = node_list.first;
|
||||
|
||||
node_list.first->prev = prev;
|
||||
node_list.last->next = dst_node;
|
Reference in New Issue
Block a user