martinus / unordered_dense

A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion
MIT License
898 stars 72 forks source link

[BUG] erase_if returns an incorrect value #76

Closed sultim-t closed 1 year ago

sultim-t commented 1 year ago

Describe the bug erase_if returns current_size - old_size which is a negative value that is cast to an unsigned size_t on return. https://github.com/martinus/unordered_dense/blob/fefa511ca94b145eca1e102da46ecb27cd03846c/include/ankerl/unordered_dense.h#L1910

To Reproduce Steps to reproduce the behavior:

  1. Call erase_if

Expected behavior erase_if should return old_size - current_size, not current_size - old_size

System (please complete the following information):

Additional context None.

martinus commented 1 year ago

Ha, you are of course correct, this is a bug. It seems whenever I don't have a test for something I'll do it wrong. I'll create a new release with the fix.

martinus commented 1 year ago

I've created release v4.0.1 with this fix. Thanks!