From c5c58fd986259c39813d177c91f7b002f335c620 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 15 Sep 2025 09:02:21 +1000 Subject: [PATCH] fix sll & hashtable bugs --- util.d | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/util.d b/util.d index 5ddb31f..ec89b0a 100644 --- a/util.d +++ b/util.d @@ -139,14 +139,17 @@ DLLPop(T, U)(T* list, U* nil) { U* node = list.first; - if(list.first == list.last) + if (!CheckNil(nil, list.first)) { - list.first = list.last = nil; - } - else - { - list.first = list.first.next; - list.first.prev = nil; + if(list.first == list.last) + { + list.first = list.last = nil; + } + else + { + list.first = list.first.next; + list.first.prev = nil; + } } return node; @@ -518,7 +521,7 @@ Delete(K, V)(HashTable!(K, V)* ht, K key) auto list = GetList(ht, key); auto prev = ht.nil; - for(auto node = list.first; !CheckNil(ht.nil, node); node = node.next) + for(auto node = list.first; !CheckNil(ht.nil, node); prev = node, node = node.next) { if(node.value.key == key) {