change evict to delete in [kv]

This commit is contained in:
Judah Caruso 2025-05-30 01:00:09 -06:00
parent 682b141356
commit 62f5d8394b

View file

@ -45,8 +45,8 @@ set :: (kv: *Kv, key: kv.Key, value: kv.Value) {
slot.value = value; slot.value = value;
} }
// @note(judah): we use 'evict' instead of 'remove' because it's a keyword... // @note(judah): we use 'delete' instead of 'remove' because it's a keyword...
evict :: (kv: *Kv, key: kv.Key) -> kv.Value, bool { delete :: (kv: *Kv, key: kv.Key) -> kv.Value, bool {
slot, ok, idx := find_slot(kv, kv.hash_proc(key)); slot, ok, idx := find_slot(kv, kv.hash_proc(key));
if !ok return mem.zero_of(kv.Value), false; if !ok return mem.zero_of(kv.Value), false;
@ -145,7 +145,7 @@ hash :: #import "jc/hash";
} }
for 0..ITERATIONS if it % 2 == 0 { for 0..ITERATIONS if it % 2 == 0 {
_, ok := evict(*values, it); _, ok := delete(*values, it);
test.expect(t, ok); test.expect(t, ok);
} }
@ -164,12 +164,12 @@ hash :: #import "jc/hash";
test.expect(t, values.count == 3); test.expect(t, values.count == 3);
test.expect(t, values.slots.allocated == values.number_of_items_to_allocate_initially); test.expect(t, values.slots.allocated == values.number_of_items_to_allocate_initially);
// evicting something that doesn't exist should do nothing // deleting something that doesn't exist should do nothing
_, ok := evict(*values, 0); _, ok := delete(*values, 0);
test.expect(t, !ok); test.expect(t, !ok);
test.expect(t, values.count == 3); test.expect(t, values.count == 3);
evict(*values, 2); delete(*values, 2);
test.expect(t, values.count == 2); test.expect(t, values.count == 2);
}); });