golang map Почему cap() не определена для хэш таблиц и как считается вместимость capacity()
Primary tabs
Forums:
При создании хэш-таблицы в golang можно указать размер:
profile := make(map[string]string, 10)
но при этом функция cap() не работает с мэпами.
It's hard to explain what cap means at all. It's a rough estimate of the size of the underlying storage and that's about it.
Unlike cap on slices and chans, it is not a guarantee about being able to store that much without resizing / blocking.
-- неплохо бы добавить тут объяснение проблемы.
Подробнее см. по ссылкам ниже
Что еще почитать
- Go Maps Explained: How Key-Value Pairs Are Actually Stored: https://victoriametrics.com/blog/go-map/
- proposal: language: allow getting capacity of map? #52157 https://github.com/golang/go/issues/52157
- Log in to post comments
- 45 reads