std::unordered_map insert with hint

后端 未结 2 882
攒了一身酷
攒了一身酷 2020-12-10 23:46

std::map has an insert method that takes a \"hint\" iterator that will reduce the insertion time from log(n) to constant time if the hint is correc

2条回答
  •  执笔经年
    2020-12-11 00:28

    The hint allows the unordered map implementation to do a value compare first to see if the hint works. This avoids having to do the hash function which can be more costly than a compare operation.

提交回复
热议问题