boost::unordered_map missing reserve() like std::unordered_map

后端 未结 1 420
情歌与酒
情歌与酒 2021-01-22 04:41

For my next task I need to use a very big hash; since I have an old compiler I cannot use C++0x std::unordered_map. Ideally I need is a call to reserve

1条回答
  •  花落未央
    2021-01-22 04:48

    reserve can be emulated by rehash as in Table 103 in N3376.

    a.rehash(n) 
    Post: a.bucket_count() > a.size() / a.max_load_factor() 
          and a.bucket_count() >= n.
    
    a.reserve(n) Same as a.rehash(ceil(n / a.max_load_factor()))
    

    0 讨论(0)
提交回复
热议问题