Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why not Map#removeAll(Collection<?>)?

Why doesn't the Map interface in Java have a removeAll(Collection<?> c) method to remove keys, like it has map.remove(Object)?

I know I can always do map.keySet().removeAll(..) .. but is this a reason that Map doesn't have removeAll() and encourages us to go with map.keySet().removeAll(..) ?

like image 648
Premraj Avatar asked Apr 28 '11 10:04

Premraj


People also ask

Why Is Maps not working?

You may need to update your Google Maps app, connect to a stronger Wi-Fi signal, recalibrate the app, or check your location services. You can also reinstall the Google Maps app if it isn't working, or simply restart your iPhone or Android phone. Visit Business Insider's homepage for more stories.

Why is map not accurate?

Though all areas are the correct size relative to each other, most land masses are distorted in order to make it so. Land masses appear stretched — horizontally at the poles and vertically at the Equator — meaning that, though countries are roughly the correct size, they are by no means the right shape.

What does the phrase the map is not the territory mean?

“The map is not the territory” is a phrase coined by the Polish-American philosopher and engineer Alfred Korzybski. He used it to convey the fact that people often confuse models of reality with reality itself. According to Korzybski, models stand to represent things, but they are not identical to those things.

Why is Google Maps not showing a map?

Update your browser If you're not running the latest browser version, Google Maps may not work properly. Check if there's a newer browser version available and install it. Speaking of browsers, switch to a different browser and check if the issue persists. If you're not running Chrome already, go ahead and install it.


1 Answers

The philosophy behind the collections APIs is to be as small and simple as possible. The Collection views on Map allow you to perform this operation already, so there is no need for an extra method.

The keySet method returns a view of the Map. Operations on the key set are reflected on the map.

The more general question on interface design: Why doesn't interface X have convenient method Y? is addressed in more depth by Martin Fowler's discussion of MinimalInterface vs HumaneInterface.

like image 140
z7sg Ѫ Avatar answered Oct 26 '22 22:10

z7sg Ѫ