java - How to remove elements of one map from another map? -
hashmap<string, string> foo = new hashmap<string, string>(); hashmap<string, string> baar = new hashmap<string, string>(); how remove items found in baar foo?
you can try:
foo.keyset().removeall(baar.keyset()) changes map's keyset() reflected in map itself.
if want remove exact mappings (not based on keys), can use same approach entryset() instead:
foo.entryset().removeall(baar.entryset());
Comments
Post a Comment