You can use this approach whenever the lifetime of the mapping must be tied to the lifetime of the key.
当映射的生命周期必须与键的生命周期联系在一起时,可以使用这种方法。
Deletions are a little more complex, because we also want to delete the reverse mapping for the key we're deleting.
删除函数略微有些复杂,因为我们还想删除正在删除的键的反向映射。
应用推荐