Add code generation for doubly linked list
This commit is contained in:
15
codegen/dbl_list/snippets/node_to_list
Normal file
15
codegen/dbl_list/snippets/node_to_list
Normal file
@@ -0,0 +1,15 @@
|
||||
{T}List output = {{.first = node, .last = node, .total_size = node->string->size, .node_count = 1}};
|
||||
|
||||
while (output.first->prev != NULL) {{
|
||||
output.total_size += output.first->prev->string->size;
|
||||
output.first = output.first->prev;
|
||||
++(output.node_count);
|
||||
}}
|
||||
|
||||
while (output.last->next != NULL) {{
|
||||
output.total_size += output.last->next->string->size;
|
||||
output.last = output.last->next;
|
||||
++(output.node_count);
|
||||
}}
|
||||
|
||||
return output;
|
Reference in New Issue
Block a user