2015-09-25 48 views
0

我想知道两件事情......一旦容器已被填充并且您知道不会添加任何新项目,是否以类似于shrink_to_fit()的方式调整无序容器的大小?可能这不是你通常想要做的事情,因为这个桶只是我猜的指针大小。所以......无论如何,在大多数情况下,在调整大小的过程中赢得的空间不会太大。无序容器的shrink_to_fit()?

其次......会有什么功能有rehash(<bucketcount>)。但是是否还有一个类似于shrink_to_fit的无序容器功能,它可以删除所有空桶并相应地对容器进行相应的删除操作?

回答

2

你想看看load_factor

这里只有

void max_load_factor(float ml); 

,而不是min_load_factor,所以你不能让你在找什么,除非元素移动到一个新的容器。

decltype(orig) shrunk(std::make_move_iterator(orig.begin()), 
     std::make_move_iterator(orig.end());