Searching for a key that is not present in the hash-map, inserts the key into the map

39 views
Skip to first unread message

Sayan Goswami

unread,
Apr 14, 2016, 10:43:40 PM4/14/16
to google-sparsehash
Hi,

I have a sparsehashmap with uint64_t key type and a pointer to a structure as the value type. 

If I have value_t * value = map[key] and the key is not present in the map, a <key, NULL> pair seems to be inserted automatically into it which messes up the size().

Is this behaviour expected?

Thanks,

Sayan

Geoff Pike

unread,
Apr 14, 2016, 11:40:24 PM4/14/16
to google-s...@googlegroups.com
Yes, it is expected. You may want to use find() or count().

Geoff

Sayan Goswami

unread,
Apr 15, 2016, 12:47:25 AM4/15/16
to google-sparsehash
Thanks for your quick response.. 
Reply all
Reply to author
Forward
0 new messages