Get deleted key and value for delete_key

This commit is contained in:
gingerBill
2022-11-11 11:19:34 +00:00
parent 033525fe13
commit b475481788
2 changed files with 15 additions and 5 deletions
+5 -2
View File
@@ -300,8 +300,11 @@ shrink_map :: proc(m: ^$T/map[$K]$V, loc := #caller_location) -> (did_shrink: bo
delete_key :: proc(m: ^$T/map[$K]$V, key: K) -> (deleted_key: K, deleted_value: V) {
if m != nil {
key := key
_ = map_erase_dynamic((^Raw_Map)(m), map_info(T), uintptr(&key))
// TODO(bill) old key and value
old_k, old_v, ok := map_erase_dynamic((^Raw_Map)(m), map_info(T), uintptr(&key))
if ok {
deleted_key = (^K)(old_k)^
deleted_value = (^V)(old_v)^
}
}
return
}