diff --git a/code/grime_linked_list.odin b/code/grime_linked_list.odin index 5df853a..933a3d2 100644 --- a/code/grime_linked_list.odin +++ b/code/grime_linked_list.odin @@ -3,10 +3,23 @@ package sectr LL_Node :: struct ( $ Type : typeid ) { - value : ^Type, - next : ^LL_Node(Type), + next : ^Type, } +ll_push :: #force_inline proc "contextless" ( list_ptr : ^(^ ($ Type)), node : ^Type ) { + list := (list_ptr^) + node.next = list + (list_ptr^) = node +} + +ll_pop :: #force_inline proc "contextless" ( list_ptr : ^(^ ($ Type)) ) -> ( node : ^Type ) { + list := (list_ptr^) + (list_ptr^) = list.next + return list +} + +//region Intrusive Doubly-Linked-List + DLL_Node :: struct ( $ Type : typeid ) #raw_union { using _ : struct { left, right : ^Type, @@ -102,3 +115,5 @@ dll_full_insert_raw :: proc "contextless" ( null : ^($ Type), parent, pos, node dll_full_push_back :: proc "contextless" ( null : ^($ Type), parent, node : ^ Type ) { dll_full_insert_raw( null, parent, parent.last, node ) } + +//endregion Intrusive Doubly-Linked-List