Skip to content

Commit f9a32bc

Browse files
committed
fix: fix an error in erase
1 parent 4d567c5 commit f9a32bc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

stl/ww_hashtable.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,13 @@ template <
772772
}
773773
if (prev == nullptr) {
774774
// 说明first是桶的第一个节点,直接销毁链表
775-
erase(_get_key(*first));
775+
_buckets[first_bucket] = nullptr;
776+
while (cur != nullptr) {
777+
node_pointer next = cur->_next;
778+
_destroy_node(cur);
779+
cur = next;
780+
--_num_elements;
781+
}
776782
} else {
777783
// 说明first不是桶的第一个节点,从prev开始销毁
778784
node_pointer cur = first._node;

0 commit comments

Comments
 (0)