mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
hashmap: new and fast hashmap with dynamic size
This commit is contained in:

committed by
Alexander Medvednikov

parent
219239eadc
commit
6fd175d9be
@ -3,7 +3,7 @@ module hashmap
|
||||
import rand
|
||||
|
||||
fn test_random_strings() {
|
||||
mut m := new_hashmap(1000)
|
||||
mut m := new_hashmap()
|
||||
for i in 0..1000 {
|
||||
mut buf := []byte
|
||||
for j in 0..10 {
|
||||
@ -21,12 +21,11 @@ fn test_random_strings() {
|
||||
|
||||
fn test_large_hashmap() {
|
||||
N := 300 * 1000
|
||||
mut nums := new_hashmap(N)
|
||||
mut nums := new_hashmap()
|
||||
for i := 0; i < N; i++ {
|
||||
key := i.str()
|
||||
nums.set(key, i)
|
||||
}
|
||||
println('nr collisions: $nums.nr_collisions')
|
||||
for i := 0; i < N; i++ {
|
||||
key := i.str()
|
||||
assert nums.get(key) == i
|
||||
|
Reference in New Issue
Block a user