rust icon indicating copy to clipboard operation
rust copied to clipboard

LinearMap.len is wrong

Open jesse99 opened this issue 13 years ago • 4 comments

This does not return the number of entries in the map. I'm guessing that it instead returns capacity.

jesse99 avatar Dec 24 '12 04:12 jesse99

Looking at the code, it should return the number of entries contained in the map. It definitely doesn't return the capacity but maybe does something wrong while tracking the entry count.

ttaubert avatar Dec 30 '12 14:12 ttaubert

Looked at the code myself. Wasn't clear at first what's going on, but after looking at it more closely expand seems wrong: each time through it's going to increment size by the old capacity.

jesse99 avatar Dec 30 '12 15:12 jesse99

Yeah, you're right. This needs to reset self.size to zero before copying the old entries to their new buckets.

ttaubert avatar Dec 30 '12 15:12 ttaubert

Fixed.

brson avatar Jan 01 '13 06:01 brson