1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

map: add 3 DenseArray methods for bootstrapping (#7113)

This commit is contained in:
Nick Treleaven
2020-12-03 19:12:53 +00:00
committed by GitHub
parent 6c100a0bc3
commit d590ce7675
3 changed files with 26 additions and 14 deletions

View File

@@ -117,6 +117,23 @@ fn new_dense_array(value_bytes int) DenseArray {
}
}
[inline]
fn (d &DenseArray) key(i int) voidptr {
return unsafe {voidptr(d.keys + i)}
}
// for cgen
[inline]
fn (d &DenseArray) value(i int) voidptr {
return unsafe {voidptr(d.values + i * d.value_bytes)}
}
[inline]
fn (d &DenseArray) has_index(i int) bool {
pkey := unsafe {d.keys + i}
return pkey.str != 0
}
// Push element to array and return index
// The growth-factor is roughly 1.125 `(x + (x >> 3))`
[inline]