LKedward / fhash

fpm package implementing a hash table with support for generic keys and values.
https://lkedward.github.io/fhash/
MIT License
38 stars 8 forks source link

stats initial value #7

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi @LKedward. In the following code I'd expect the output _numitems : 0

program main
use fhash
implicit none

type(fhash_tbl_t) :: tbl
integer :: num_buckets, num_items, num_collisions, max_depth

call tbl%stats(num_buckets, num_items, num_collisions, max_depth)
print *, 'num_items:', num_items

end program main

The result is a big number:

fhash

This happens on Windows 10.

ghost commented 3 years ago
num_items = 0

at line 7 solves the problem. 😇

LKedward commented 3 years ago

Hi @brocolis , thanks for reporting. This is a bug because you shouldn't need to initialise num_items before calling tbl%stats. I'll start on a fix.

LKedward commented 3 years ago

Thanks for finding this @brocolis, I've now fixed it in the latest version so you shouldn't need to add num_items=0 anymore.

I think with fpm you can run fpm update to update your fhash dependency.