简体   繁体   中英

how to remove entry from hashmap by Value?

I need a method to remove a entryset from hashmap by it's value. Is there a simple method without iteration?

There's a simple method, but it'll use iteration internally. (There's no way around that.)

map.values().remove(valueToRemove);

Not in HashMap but google-guava has a BiMap and you could do it like below pseudo-code

BiMap m=new HashBiMap();
m.inverse().remove(valueYouWantToRemove)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM