更快地找到Map的给定值的关键? [英] Faster way to find out the key for given value from Map?

查看:140
本文介绍了更快地找到Map的给定值的关键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从HashMap中找出给定值的关键字,目前我必须通过所有的密钥并检查其在map中的值,是否有更快的方法?

I want to find out the key for given value from HashMap, currently I have to go through all keys and check its value in map, is there a faster way?

推荐答案

不,没有更快的方式(没有引入其他数据结构)。如果你经常需要这样做,请重新考虑你的设计。也许你想要另一个 HashMap ,其键是另一个 HashMap 的值?

No, there is not a faster way (without introducing other data structures). If you need to do this often, reconsider your design. Maybe you want another HashMap whose keys are the values of the other HashMap?

这篇关于更快地找到Map的给定值的关键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆